diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2019-10-17 12:06:58 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-10-17 12:06:58 -0400 |
| commit | 1102c53513837e7f052730b847270f533876833f (patch) | |
| tree | 1cc6f02cb866966a282af91a805d6ff26de86181 /tests | |
| parent | fb44993b38dd98261f20e718c3e282634902b391 (diff) | |
Feature/gpu unbound array of array (#1083)
* Simple testing of unbounded array of array on GPU.
* Fix problem on CPU targets around NonUniformResourceIndex
Use the unbounded-array-of-array-syntax test for CPU and GPU tests.
Diffstat (limited to 'tests')
4 files changed, 84 insertions, 2 deletions
diff --git a/tests/compute/unbounded-array-of-array-syntax.slang b/tests/compute/unbounded-array-of-array-syntax.slang index fdc04c95e..df1074896 100644 --- a/tests/compute/unbounded-array-of-array-syntax.slang +++ b/tests/compute/unbounded-array-of-array-syntax.slang @@ -1,5 +1,7 @@ //DISABLE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp //TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute +//TEST:CROSS_COMPILE:-target dxbc-assembly -entry computeMain -profile cs_5_1 +//TEST:CROSS_COMPILE:-target spirv-assembly -entry computeMain -profile cs_5_1 //TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer RWStructuredBuffer<int> outputBuffer; @@ -18,7 +20,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) int baseIndex = index >> 2; int innerIndex = index & 3; - RWStructuredBuffer<int> buffer = g_aoa[baseIndex]; + RWStructuredBuffer<int> buffer = g_aoa[NonUniformResourceIndex(baseIndex)]; // Get the size uint bufferCount, bufferStride; diff --git a/tests/compute/unbounded-array-of-array-syntax.slang.glsl b/tests/compute/unbounded-array-of-array-syntax.slang.glsl new file mode 100644 index 000000000..675d00718 --- /dev/null +++ b/tests/compute/unbounded-array-of-array-syntax.slang.glsl @@ -0,0 +1,40 @@ +//TEST_IGNORE_FILE: + +#version 450 +layout(row_major) uniform; +layout(row_major) buffer; +#extension GL_EXT_nonuniform_qualifier : require + +layout(std430, binding = 1) buffer _S1 { + int _data[]; +} g_aoa_0[]; +layout(std430, binding = 0) buffer _S2 { + int _data[]; +} outputBuffer_0; + +layout(local_size_x = 8, local_size_y = 1, local_size_z = 1) in; +void main() +{ + int innerIndex_0; + + int index_0 = int(gl_GlobalInvocationID.x); + + int innerIndex_1 = index_0 & 3; + + uint _S3; + uint _S4; + (_S3) = (g_aoa_0[nonuniformEXT(index_0 >> 2)])._data.length(); (_S4) = 0; + uint bufferCount_0 = _S3; + + if(uint(innerIndex_1) >= bufferCount_0) + { + innerIndex_0 = int(bufferCount_0 - uint(1)); + } + else + { + innerIndex_0 = innerIndex_1; + } + uint _S5 = uint(innerIndex_0); + ((outputBuffer_0)._data[(uint(index_0))]) = ((g_aoa_0[nonuniformEXT(index_0 >> 2)])._data[(_S5)]); + return; +} diff --git a/tests/compute/unbounded-array-of-array-syntax.slang.hlsl b/tests/compute/unbounded-array-of-array-syntax.slang.hlsl new file mode 100644 index 000000000..3fd9ee8ea --- /dev/null +++ b/tests/compute/unbounded-array-of-array-syntax.slang.hlsl @@ -0,0 +1,40 @@ +//TEST_IGNORE_FILE: + +#pragma pack_matrix(column_major) + +RWStructuredBuffer<int > g_aoa_0[] : register(u0, space1); + +RWStructuredBuffer<int > outputBuffer_0 : register(u0); + +[numthreads(8, 1, 1)] +void computeMain(vector<uint,3> dispatchThreadID_0 : SV_DISPATCHTHREADID) +{ + int innerIndex_0; + + int index_0 = (int) dispatchThreadID_0.x; + + int innerIndex_1 = index_0 & 3; + + RWStructuredBuffer<int > buffer_0 = g_aoa_0[NonUniformResourceIndex(index_0 >> 2)]; + + uint _S1; + uint _S2; + + buffer_0.GetDimensions(_S1, _S2); + + uint bufferCount_0 = _S1; + + if((uint) innerIndex_1 >= bufferCount_0) + { + innerIndex_0 = (int) (bufferCount_0 - (uint) 1); + } + else + { + innerIndex_0 = innerIndex_1; + } + + uint _S3 = (uint) innerIndex_0; + outputBuffer_0[(uint) index_0] = buffer_0[_S3]; + return; +} + diff --git a/tests/compute/unbounded-array-of-array.slang b/tests/compute/unbounded-array-of-array.slang index 760740282..079808710 100644 --- a/tests/compute/unbounded-array-of-array.slang +++ b/tests/compute/unbounded-array-of-array.slang @@ -20,7 +20,7 @@ void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) int baseIndex = index >> 2; int innerIndex = index & 3; - RWStructuredBuffer<int> buffer = g_aoa.array[baseIndex]; + RWStructuredBuffer<int> buffer = g_aoa.array[NonUniformResourceIndex(baseIndex)]; // Get the size uint bufferCount, bufferStride; |
