Hash :
398c5a2a
Author :
Date :
2015-01-16T17:17:47
Support for 3D texture transfers with a non-null z offset. Also fixes the unpack buffer offset which must be in pixel instead of bytes in the shader parameter. BUG=angle:508 Change-Id: I908460a76c300d96054a02206e1f2e3ad2b8e9d0 Reviewed-on: https://chromium-review.googlesource.com/241440 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Gregoire Payen de La Garanderie <Gregory.Payen@imgtec.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
Buffer<float4> Buffer4F : register(t0);
Buffer<int4> Buffer4I : register(t0);
Buffer<uint4> Buffer4UI : register(t0);
struct VS_OUTPUT
{
float4 position : SV_Position;
uint index : TEXCOORD0;
uint slice : LAYER;
};
struct GS_OUTPUT
{
float4 position : SV_Position;
uint index : TEXCOORD0;
uint slice : SV_RenderTargetArrayIndex;
};
cbuffer BufferCopyParams : register(b0)
{
uint FirstPixelOffset;
uint PixelsPerRow;
uint RowStride;
uint RowsPerSlice;
float2 PositionOffset;
float2 PositionScale;
int2 TexLocationOffset;
int2 TexLocationScale;
uint FirstSlice;
}
void ComputePositionAndIndex(uint vertexID, out VS_OUTPUT outVertex)
{
uint PixelsPerSlice = PixelsPerRow * RowsPerSlice;
uint SliceStride = RowStride * RowsPerSlice;
uint slice = vertexID / PixelsPerSlice;
uint sliceOffset = slice * PixelsPerSlice;
uint row = (vertexID - sliceOffset) / PixelsPerRow;
uint col = vertexID - sliceOffset - (row * PixelsPerRow);
float2 coords = float2(float(col), float(row));
outVertex.position = float4(PositionOffset + PositionScale * coords, 0.0f, 1.0f);
outVertex.index = FirstPixelOffset + slice * SliceStride + row * RowStride + col;
outVertex.slice = FirstSlice + slice;
}
void VS_BufferToTexture(in uint vertexID : SV_VertexID, out VS_OUTPUT outVertex)
{
ComputePositionAndIndex(vertexID, outVertex);
}
[maxvertexcount(1)]
void GS_BufferToTexture(point VS_OUTPUT inVertex[1], inout PointStream<GS_OUTPUT> outStream)
{
GS_OUTPUT outVertex;
outVertex.position = inVertex[0].position;
outVertex.index = inVertex[0].index;
outVertex.slice = inVertex[0].slice;
outStream.Append(outVertex);
}
float4 PS_BufferToTexture_4F(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
{
return Buffer4F.Load(inIndex);
}
int4 PS_BufferToTexture_4I(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
{
return Buffer4I.Load(inIndex);
}
uint4 PS_BufferToTexture_4UI(in float4 inPosition : SV_Position, in uint inIndex : TEXCOORD0) : SV_Target
{
return Buffer4UI.Load(inIndex);
}