Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / angle / src / libGLESv2 / renderer / d3d / d3d11 / Blit11.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 // Blit11.cpp: Texture copy utility class.
8
9 #ifndef LIBGLESV2_BLIT11_H_
10 #define LIBGLESV2_BLIT11_H_
11
12 #include "common/angleutils.h"
13 #include "libGLESv2/angletypes.h"
14
15 namespace rx
16 {
17 class Renderer11;
18
19 enum Filter
20 {
21     Point,
22     Linear,
23 };
24
25 class Blit11
26 {
27   public:
28     explicit Blit11(Renderer11 *renderer);
29     ~Blit11();
30
31     bool swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
32                         GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
33
34     bool copyTexture(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
35                      ID3D11RenderTargetView *dest, const gl::Box &destArea, const gl::Extents &destSize,
36                      const gl::Rectangle *scissor, GLenum destFormat, GLenum filter);
37
38     bool copyStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
39                      ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
40                      const gl::Rectangle *scissor);
41
42     bool copyDepth(ID3D11ShaderResourceView *source, const gl::Box &sourceArea, const gl::Extents &sourceSize,
43                    ID3D11DepthStencilView *dest, const gl::Box &destArea, const gl::Extents &destSize,
44                    const gl::Rectangle *scissor);
45
46     bool copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
47                           ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
48                           const gl::Rectangle *scissor);
49
50   private:
51     rx::Renderer11 *mRenderer;
52
53     struct BlitParameters
54     {
55         GLenum mDestinationFormat;
56         bool mSignedInteger;
57         bool m3DBlit;
58     };
59
60     bool copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubresource, const gl::Box &sourceArea, const gl::Extents &sourceSize,
61                           ID3D11Resource *dest, unsigned int destSubresource, const gl::Box &destArea, const gl::Extents &destSize,
62                           const gl::Rectangle *scissor, bool stencilOnly);
63
64     static bool compareBlitParameters(const BlitParameters &a, const BlitParameters &b);
65
66     typedef void (*WriteVertexFunction)(const gl::Box &sourceArea, const gl::Extents &sourceSize,
67                                         const gl::Box &destArea, const gl::Extents &destSize,
68                                         void *outVertices, unsigned int *outStride, unsigned int *outVertexCount,
69                                         D3D11_PRIMITIVE_TOPOLOGY *outTopology);
70
71     struct Shader
72     {
73         WriteVertexFunction mVertexWriteFunction;
74         ID3D11InputLayout *mInputLayout;
75         ID3D11VertexShader *mVertexShader;
76         ID3D11GeometryShader *mGeometryShader;
77         ID3D11PixelShader *mPixelShader;
78     };
79
80     typedef bool (*BlitParametersComparisonFunction)(const BlitParameters&, const BlitParameters &);
81     typedef std::map<BlitParameters, Shader, BlitParametersComparisonFunction> BlitShaderMap;
82     BlitShaderMap mBlitShaderMap;
83
84     void add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
85     void add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
86
87     struct SwizzleParameters
88     {
89         GLenum mDestinationType;
90         D3D11_SRV_DIMENSION mViewDimension;
91     };
92
93     static bool compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b);
94
95     typedef bool (*SwizzleParametersComparisonFunction)(const SwizzleParameters&, const SwizzleParameters &);
96     typedef std::map<SwizzleParameters, Shader, SwizzleParametersComparisonFunction> SwizzleShaderMap;
97     SwizzleShaderMap mSwizzleShaderMap;
98
99     void addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps);
100
101     void buildShaderMap();
102     void clearShaderMap();
103
104     ID3D11Buffer *mVertexBuffer;
105     ID3D11SamplerState *mPointSampler;
106     ID3D11SamplerState *mLinearSampler;
107     ID3D11RasterizerState *mScissorEnabledRasterizerState;
108     ID3D11RasterizerState *mScissorDisabledRasterizerState;
109     ID3D11DepthStencilState *mDepthStencilState;
110
111     ID3D11InputLayout *mQuad2DIL;
112     ID3D11VertexShader *mQuad2DVS;
113     ID3D11PixelShader *mDepthPS;
114
115     ID3D11InputLayout *mQuad3DIL;
116     ID3D11VertexShader *mQuad3DVS;
117     ID3D11GeometryShader *mQuad3DGS;
118
119     ID3D11Buffer *mSwizzleCB;
120
121     DISALLOW_COPY_AND_ASSIGN(Blit11);
122 };
123
124 }
125
126 #endif   // LIBGLESV2_BLIT11_H_