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 // PixelTransfer11.h: 8 // Buffer-to-Texture and Texture-to-Buffer data transfers. 9 // Used to implement pixel unpack and pixel pack buffers in ES3. 10 11 #ifndef LIBGLESV2_PIXELTRANSFER11_H_ 12 #define LIBGLESV2_PIXELTRANSFER11_H_ 13 14 namespace gl 15 { 16 17 class Buffer; 18 struct Box; 19 struct Extents; 20 struct PixelUnpackState; 21 22 } 23 24 namespace rx 25 { 26 class Renderer11; 27 class RenderTarget; 28 29 class PixelTransfer11 30 { 31 public: 32 explicit PixelTransfer11(Renderer11 *renderer); 33 ~PixelTransfer11(); 34 35 static bool supportsBufferToTextureCopy(GLenum internalFormat); 36 37 // unpack: the source buffer is stored in the unpack state, and buffer strides 38 // offset: the start of the data within the unpack buffer 39 // destRenderTarget: individual slice/layer of a target texture 40 // destinationFormat/sourcePixelsType: determines shaders + shader parameters 41 // destArea: the sub-section of destRenderTarget to copy to 42 bool copyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget, 43 GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea); 44 45 private: 46 47 struct CopyShaderParams 48 { 49 unsigned int FirstPixelOffset; 50 unsigned int PixelsPerRow; 51 unsigned int RowStride; 52 unsigned int RowsPerSlice; 53 float PositionOffset[2]; 54 float PositionScale[2]; 55 int TexLocationOffset[2]; 56 int TexLocationScale[2]; 57 }; 58 59 static void setBufferToTextureCopyParams(const gl::Box &destArea, const gl::Extents &destSize, GLenum internalFormat, 60 const gl::PixelUnpackState &unpack, unsigned int offset, CopyShaderParams *parametersOut); 61 62 void buildShaderMap(); 63 ID3D11PixelShader *findBufferToTexturePS(GLenum internalFormat) const; 64 65 Renderer11 *mRenderer; 66 67 std::map<GLenum, ID3D11PixelShader *> mBufferToTexturePSMap; 68 ID3D11VertexShader *mBufferToTextureVS; 69 ID3D11GeometryShader *mBufferToTextureGS; 70 ID3D11Buffer *mParamsConstantBuffer; 71 CopyShaderParams mParamsData; 72 73 ID3D11RasterizerState *mCopyRasterizerState; 74 ID3D11DepthStencilState *mCopyDepthStencilState; 75 76 }; 77 78 } 79 80 #endif // LIBGLESV2_PIXELTRANSFER11_H_ 81