Home | History | Annotate | Download | only in d3d11
      1 //
      2 // Copyright (c) 2013 The ANGLE Project Authors. All rights reserved.
      3 // Use of this source code is governed by a BSD-style license that can be
      4 // found in the LICENSE file.
      5 //
      6 
      7 // Clear11.h: Framebuffer clear utility class.
      8 
      9 #ifndef LIBGLESV2_RENDERER_CLEAR11_H_
     10 #define LIBGLESV2_RENDERER_CLEAR11_H_
     11 
     12 #include "libGLESv2/angletypes.h"
     13 
     14 namespace gl
     15 {
     16 class Framebuffer;
     17 }
     18 
     19 namespace rx
     20 {
     21 class Renderer11;
     22 class RenderTarget11;
     23 
     24 class Clear11
     25 {
     26   public:
     27     explicit Clear11(Renderer11 *renderer);
     28     ~Clear11();
     29 
     30     // Clears the framebuffer with the supplied clear parameters, assumes that the framebuffer is currently applied.
     31     void clearFramebuffer(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
     32 
     33   private:
     34     Renderer11 *mRenderer;
     35 
     36     struct ClearBlendInfo
     37     {
     38         bool maskChannels[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT][4];
     39     };
     40     typedef bool (*ClearBlendInfoComparisonFunction)(const ClearBlendInfo&, const ClearBlendInfo &);
     41     typedef std::map<ClearBlendInfo, ID3D11BlendState*, ClearBlendInfoComparisonFunction> ClearBlendStateMap;
     42     ClearBlendStateMap mClearBlendStates;
     43 
     44     ID3D11BlendState *getBlendState(const gl::ClearParameters &clearParams, const std::vector<RenderTarget11*>& rts);
     45 
     46     struct ClearShader
     47     {
     48         ID3D11InputLayout *inputLayout;
     49         ID3D11VertexShader *vertexShader;
     50         ID3D11PixelShader *pixelShader;
     51     };
     52     ClearShader mFloatClearShader;
     53     ClearShader mUintClearShader;
     54     ClearShader mIntClearShader;
     55 
     56     template <unsigned int vsSize, unsigned int psSize>
     57     static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
     58 
     59     struct ClearDepthStencilInfo
     60     {
     61         bool clearDepth;
     62         bool clearStencil;
     63         UINT8 stencilWriteMask;
     64     };
     65     typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
     66     typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
     67     ClearDepthStencilStateMap mClearDepthStencilStates;
     68 
     69     ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
     70 
     71     ID3D11Buffer *mVertexBuffer;
     72     ID3D11RasterizerState *mRasterizerState;
     73 };
     74 
     75 }
     76 
     77 #endif // LIBGLESV2_RENDERER_CLEAR11_H_
     78