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