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