1 // 2 // Copyright 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 LIBANGLE_RENDERER_D3D_D3D11_PIXELTRANSFER11_H_ 12 #define LIBANGLE_RENDERER_D3D_D3D11_PIXELTRANSFER11_H_ 13 14 #include <GLES2/gl2.h> 15 16 #include <map> 17 18 #include <libANGLE/angletypes.h> 19 #include "common/platform.h" 20 #include "libANGLE/Error.h" 21 #include "libANGLE/renderer/d3d/d3d11/ResourceManager11.h" 22 23 namespace gl 24 { 25 class Buffer; 26 class Context; 27 } // namespace gl 28 29 namespace rx 30 { 31 class Renderer11; 32 class RenderTargetD3D; 33 34 class PixelTransfer11 35 { 36 public: 37 explicit PixelTransfer11(Renderer11 *renderer); 38 ~PixelTransfer11(); 39 40 // unpack: the source buffer is stored in the unpack state, and buffer strides 41 // offset: the start of the data within the unpack buffer 42 // destRenderTarget: individual slice/layer of a target texture 43 // destinationFormat/sourcePixelsType: determines shaders + shader parameters 44 // destArea: the sub-section of destRenderTarget to copy to 45 angle::Result copyBufferToTexture(const gl::Context *context, 46 const gl::PixelUnpackState &unpack, 47 gl::Buffer *unpackBuffer, 48 unsigned int offset, 49 RenderTargetD3D *destRenderTarget, 50 GLenum destinationFormat, 51 GLenum sourcePixelsType, 52 const gl::Box &destArea); 53 54 private: 55 struct CopyShaderParams 56 { 57 unsigned int FirstPixelOffset; 58 unsigned int PixelsPerRow; 59 unsigned int RowStride; 60 unsigned int RowsPerSlice; 61 float PositionOffset[2]; 62 float PositionScale[2]; 63 int TexLocationOffset[2]; 64 int TexLocationScale[2]; 65 unsigned int FirstSlice; 66 }; 67 68 static void setBufferToTextureCopyParams(const gl::Box &destArea, 69 const gl::Extents &destSize, 70 GLenum internalFormat, 71 const gl::PixelUnpackState &unpack, 72 unsigned int offset, 73 CopyShaderParams *parametersOut); 74 75 angle::Result loadResources(const gl::Context *context); 76 angle::Result buildShaderMap(const gl::Context *context); 77 const d3d11::PixelShader *findBufferToTexturePS(GLenum internalFormat) const; 78 79 Renderer11 *mRenderer; 80 81 bool mResourcesLoaded; 82 std::map<GLenum, d3d11::PixelShader> mBufferToTexturePSMap; 83 d3d11::VertexShader mBufferToTextureVS; 84 d3d11::GeometryShader mBufferToTextureGS; 85 d3d11::Buffer mParamsConstantBuffer; 86 CopyShaderParams mParamsData; 87 88 d3d11::RasterizerState mCopyRasterizerState; 89 d3d11::DepthStencilState mCopyDepthStencilState; 90 }; 91 92 } // namespace rx 93 94 #endif // LIBANGLE_RENDERER_D3D_D3D11_PIXELTRANSFER11_H_ 95