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.
7 // Blit11.cpp: Texture copy utility class.
9 #ifndef LIBGLESV2_BLIT11_H_
10 #define LIBGLESV2_BLIT11_H_
12 #include "common/angleutils.h"
13 #include "libGLESv2/angletypes.h"
28 explicit Blit11(Renderer11 *renderer);
31 bool swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
32 GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
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);
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);
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);
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);
51 rx::Renderer11 *mRenderer;
55 GLenum mDestinationFormat;
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);
64 static bool compareBlitParameters(const BlitParameters &a, const BlitParameters &b);
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);
73 WriteVertexFunction mVertexWriteFunction;
74 ID3D11InputLayout *mInputLayout;
75 ID3D11VertexShader *mVertexShader;
76 ID3D11GeometryShader *mGeometryShader;
77 ID3D11PixelShader *mPixelShader;
80 typedef bool (*BlitParametersComparisonFunction)(const BlitParameters&, const BlitParameters &);
81 typedef std::map<BlitParameters, Shader, BlitParametersComparisonFunction> BlitShaderMap;
82 BlitShaderMap mBlitShaderMap;
84 void add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
85 void add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
87 struct SwizzleParameters
89 GLenum mDestinationType;
90 D3D11_SRV_DIMENSION mViewDimension;
93 static bool compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b);
95 typedef bool (*SwizzleParametersComparisonFunction)(const SwizzleParameters&, const SwizzleParameters &);
96 typedef std::map<SwizzleParameters, Shader, SwizzleParametersComparisonFunction> SwizzleShaderMap;
97 SwizzleShaderMap mSwizzleShaderMap;
99 void addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps);
101 void buildShaderMap();
102 void clearShaderMap();
104 ID3D11Buffer *mVertexBuffer;
105 ID3D11SamplerState *mPointSampler;
106 ID3D11SamplerState *mLinearSampler;
107 ID3D11RasterizerState *mScissorEnabledRasterizerState;
108 ID3D11RasterizerState *mScissorDisabledRasterizerState;
109 ID3D11DepthStencilState *mDepthStencilState;
111 ID3D11InputLayout *mQuad2DIL;
112 ID3D11VertexShader *mQuad2DVS;
113 ID3D11PixelShader *mDepthPS;
115 ID3D11InputLayout *mQuad3DIL;
116 ID3D11VertexShader *mQuad3DVS;
117 ID3D11GeometryShader *mQuad3DGS;
119 ID3D11Buffer *mSwizzleCB;
121 DISALLOW_COPY_AND_ASSIGN(Blit11);
126 #endif // LIBGLESV2_BLIT11_H_