diff options
| author | Yong He <yonghe@outlook.com> | 2023-08-23 05:49:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-08-23 20:49:33 +0800 |
| commit | 6437c38e0a3c2c1daf36cb5e543dc0b467fa4b15 (patch) | |
| tree | c117b964ada397d9cac01ff4759bcd16d35c7e20 /tests/cross-compile | |
| parent | cdd5e6666f98903d61118ada5cba51424fd1577c (diff) | |
Lower all ByteAddressBuffer uses for SPIRV. (#3143)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/cross-compile')
| -rw-r--r-- | tests/cross-compile/array-of-buffers.slang.glsl | 11 | ||||
| -rw-r--r-- | tests/cross-compile/array-of-buffers.slang.hlsl | 9 | ||||
| -rw-r--r-- | tests/cross-compile/get-dimensions.slang | 17 | ||||
| -rw-r--r-- | tests/cross-compile/get-dimensions.slang.expected.txt | 2 |
4 files changed, 22 insertions, 17 deletions
diff --git a/tests/cross-compile/array-of-buffers.slang.glsl b/tests/cross-compile/array-of-buffers.slang.glsl index fb1a4be2f..53a826a91 100644 --- a/tests/cross-compile/array-of-buffers.slang.glsl +++ b/tests/cross-compile/array-of-buffers.slang.glsl @@ -15,7 +15,6 @@ struct S_0 { vec4 f_0; }; - layout(binding = 1) layout(std140) uniform _S2 { @@ -27,18 +26,14 @@ layout(std430, binding = 2) readonly buffer StructuredBuffer_S_t_0 { layout(std430, binding = 3) buffer StructuredBuffer_float4_t_0 { vec4 _data[]; } sb2_0[5]; -layout(std430, binding = 4) readonly buffer _S3 -{ +layout(std430, binding = 4) readonly buffer StructuredBuffer_uint_t_0 { uint _data[]; } bb_0[6]; layout(location = 0) -out vec4 _S4; +out vec4 _S3; void main() { - - uint _S5 = ((bb_0[C_0.index_0])._data[(int(C_0.index_0 * 4U))/4]); - _S4 = cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0]._data[C_0.index_0].f_0 + sb2_0[C_0.index_0]._data[C_0.index_0] + vec4(float(_S5)); + _S3 = cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0]._data[C_0.index_0].f_0 + sb2_0[C_0.index_0]._data[C_0.index_0] + vec4(float(bb_0[C_0.index_0]._data[int(C_0.index_0 * 4U) / 4])); return; } - diff --git a/tests/cross-compile/array-of-buffers.slang.hlsl b/tests/cross-compile/array-of-buffers.slang.hlsl index ca4b76bbe..a2c1c6302 100644 --- a/tests/cross-compile/array-of-buffers.slang.hlsl +++ b/tests/cross-compile/array-of-buffers.slang.hlsl @@ -13,7 +13,6 @@ cbuffer C_0 : register(b0) { SLANG_ParameterGroup_C_0 C_0; } - struct S_0 { float4 f_0; @@ -26,9 +25,11 @@ StructuredBuffer<S_0 > sb1_0[int(4)] : register(t0); RWStructuredBuffer<float4 > sb2_0[int(5)] : register(u0); ByteAddressBuffer bb_0[int(6)] : register(t4); - float4 main() : SV_TARGET { - uint _S1 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U)); - return cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0].Load(C_0.index_0).f_0 + sb2_0[C_0.index_0][C_0.index_0] + (float4)float(_S1); + + float4 _S1 = cb_0[C_0.index_0].f_0 + sb1_0[C_0.index_0].Load(C_0.index_0).f_0 + sb2_0[C_0.index_0][C_0.index_0]; + uint _S2 = bb_0[C_0.index_0].Load(int(C_0.index_0 * 4U)); + return _S1 + (float4)float(_S2); } + diff --git a/tests/cross-compile/get-dimensions.slang b/tests/cross-compile/get-dimensions.slang index 65c2a1a70..27cbb18de 100644 --- a/tests/cross-compile/get-dimensions.slang +++ b/tests/cross-compile/get-dimensions.slang @@ -10,7 +10,7 @@ struct Thing float b; }; -//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer RWStructuredBuffer<int> outputBuffer; //TEST_INPUT:ubuffer(data=[7 2 9 53], stride=4):name buffer0 @@ -25,13 +25,16 @@ RWStructuredBuffer<float> buffer2; //TEST_INPUT:ubuffer(data=[1 0 3 0 7 0], stride=8):name buffer3 RWStructuredBuffer<Thing> buffer3; -[numthreads(4, 1, 1)] +//TEST_INPUT:ubuffer(data=[1 0 3 0 7 6], stride=0):name buffer4 +RWByteAddressBuffer buffer4; + +[numthreads(5, 1, 1)] void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) { int index = int(dispatchThreadID.x); int last = -1; - uint count, stride; + uint count = 0, stride = 0; if (index == 0) { buffer0.GetDimensions(count, stride); @@ -47,13 +50,17 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) buffer2.GetDimensions(count, stride); last = int(buffer2.Load(int(count - 1))); } - else + else if (index == 3) { buffer3.GetDimensions(count, stride); last = buffer3.Load(int(count - 1)).a; } - + else + { + buffer4.GetDimensions(count); + last = buffer4.Load(count - 4); + } outputBuffer[index * 2] = int(count); outputBuffer[index * 2 + 1] = last; }
\ No newline at end of file diff --git a/tests/cross-compile/get-dimensions.slang.expected.txt b/tests/cross-compile/get-dimensions.slang.expected.txt index b90b9551c..87709651c 100644 --- a/tests/cross-compile/get-dimensions.slang.expected.txt +++ b/tests/cross-compile/get-dimensions.slang.expected.txt @@ -6,3 +6,5 @@ 0 3 7 +18 +6 |
