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"
14 #include "libGLESv2/Error.h"
25 explicit Blit11(Renderer11 *renderer);
28 gl::Error swizzleTexture(ID3D11ShaderResourceView *source, ID3D11RenderTargetView *dest, const gl::Extents &size,
29 GLenum swizzleRed, GLenum swizzleGreen, GLenum swizzleBlue, GLenum swizzleAlpha);
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);
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);
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);
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);
48 rx::Renderer11 *mRenderer;
52 GLenum mDestinationFormat;
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);
61 static bool compareBlitParameters(const BlitParameters &a, const BlitParameters &b);
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);
70 WriteVertexFunction mVertexWriteFunction;
71 ID3D11InputLayout *mInputLayout;
72 ID3D11VertexShader *mVertexShader;
73 ID3D11GeometryShader *mGeometryShader;
74 ID3D11PixelShader *mPixelShader;
77 typedef bool (*BlitParametersComparisonFunction)(const BlitParameters&, const BlitParameters &);
78 typedef std::map<BlitParameters, Shader, BlitParametersComparisonFunction> BlitShaderMap;
79 BlitShaderMap mBlitShaderMap;
81 void add2DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
82 void add3DBlitShaderToMap(GLenum destFormat, bool signedInteger, ID3D11PixelShader *ps);
84 struct SwizzleParameters
86 GLenum mDestinationType;
87 D3D11_SRV_DIMENSION mViewDimension;
90 static bool compareSwizzleParameters(const SwizzleParameters &a, const SwizzleParameters &b);
92 typedef bool (*SwizzleParametersComparisonFunction)(const SwizzleParameters&, const SwizzleParameters &);
93 typedef std::map<SwizzleParameters, Shader, SwizzleParametersComparisonFunction> SwizzleShaderMap;
94 SwizzleShaderMap mSwizzleShaderMap;
96 void addSwizzleShaderToMap(GLenum destType, D3D11_SRV_DIMENSION viewDimension, ID3D11PixelShader *ps);
98 void buildShaderMap();
99 void clearShaderMap();
101 ID3D11Buffer *mVertexBuffer;
102 ID3D11SamplerState *mPointSampler;
103 ID3D11SamplerState *mLinearSampler;
104 ID3D11RasterizerState *mScissorEnabledRasterizerState;
105 ID3D11RasterizerState *mScissorDisabledRasterizerState;
106 ID3D11DepthStencilState *mDepthStencilState;
108 ID3D11InputLayout *mQuad2DIL;
109 ID3D11VertexShader *mQuad2DVS;
110 ID3D11PixelShader *mDepthPS;
112 ID3D11InputLayout *mQuad3DIL;
113 ID3D11VertexShader *mQuad3DVS;
114 ID3D11GeometryShader *mQuad3DGS;
116 ID3D11Buffer *mSwizzleCB;
118 DISALLOW_COPY_AND_ASSIGN(Blit11);
123 #endif // LIBGLESV2_BLIT11_H_