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