Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / d3d / d3d11 / Clear11.h
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     struct MaskedRenderTarget
45     {
46         bool colorMask[4];
47         RenderTarget11 *renderTarget;
48     };
49
50     ID3D11BlendState *getBlendState(const std::vector<MaskedRenderTarget> &rts);
51
52     struct ClearShader
53     {
54         ID3D11InputLayout *inputLayout;
55         ID3D11VertexShader *vertexShader;
56         ID3D11PixelShader *pixelShader;
57     };
58     ClearShader mFloatClearShader;
59     ClearShader mUintClearShader;
60     ClearShader mIntClearShader;
61
62     template <unsigned int vsSize, unsigned int psSize>
63     static ClearShader CreateClearShader(ID3D11Device *device, DXGI_FORMAT colorType, const BYTE (&vsByteCode)[vsSize], const BYTE (&psByteCode)[psSize]);
64
65     struct ClearDepthStencilInfo
66     {
67         bool clearDepth;
68         bool clearStencil;
69         UINT8 stencilWriteMask;
70     };
71     typedef bool (*ClearDepthStencilInfoComparisonFunction)(const ClearDepthStencilInfo&, const ClearDepthStencilInfo &);
72     typedef std::map<ClearDepthStencilInfo, ID3D11DepthStencilState*, ClearDepthStencilInfoComparisonFunction> ClearDepthStencilStateMap;
73     ClearDepthStencilStateMap mClearDepthStencilStates;
74
75     ID3D11DepthStencilState *getDepthStencilState(const gl::ClearParameters &clearParams);
76
77     ID3D11Buffer *mVertexBuffer;
78     ID3D11RasterizerState *mRasterizerState;
79 };
80
81 }
82
83 #endif // LIBGLESV2_RENDERER_CLEAR11_H_