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