/**
    Copyright (c) 2010 yakiimo02
    Distributed under the New BSD License.
    See included license.txt or http://www.yakiimo3d.com/NewBSDLicense.txt
**/

#pragma once

/**
    @brief   Blend prev frame with current frame.
    @author  yakiimo02
    @date    2010/09/25
*/
class TemporalBlendPass
{
protected:
    struct SCREEN_VERTEX
    {
        D3DXVECTOR4 pos;
        D3DXVECTOR2 tex;
    };

public:
    TemporalBlendPass();
    ~TemporalBlendPass();

    HRESULT OnCreateDevice( ID3D11Device* pd3dDevice );
    HRESULT OnFrameRender( ID3D11Device* pd3dDevice, ID3D11DeviceContext* pd3dImmediateContext, const DXGI_SURFACE_DESC* pBackBufferDesc, 
                            int nBufWidth, int nBufHeight );
    void    OnDestroyDevice();

public:
    inline void SetpSceneTexturePrevSRV( ID3D11ShaderResourceView* pSceneTextureSRV ) { m_pSceneTexturePrevSRV = pSceneTextureSRV; }
    inline void SetpSceneTextureCurSRV( ID3D11ShaderResourceView* pSceneTextureSRV ) { m_pSceneTextureCurSRV = pSceneTextureSRV; }

protected:
    void DrawFullScreenQuad( ID3D11DeviceContext* pd3dImmediateContext, ID3D11PixelShader* pPS, UINT Width, UINT Height );

protected:
    // geometry
    ID3D11InputLayout*          m_pQuadLayout;                  
    ID3D11Buffer*               m_pVB;                          
    // shader
    ID3D11VertexShader*         m_pQuadVS;                      
    ID3D11PixelShader*          m_pQuadPS;                      
    ID3D11SamplerState*         m_pSampleState;           
    ID3D11Buffer*               m_pConstantBuf;                 
    // textures
    ID3D11ShaderResourceView*   m_pSceneTexturePrevSRV;         
    ID3D11ShaderResourceView*   m_pSceneTextureCurSRV;            
};
