From 2420f47b56647d33e5dbb6730718905a767c7244 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Fri, 11 Oct 2019 14:35:07 -0400 Subject: CPU unsized array documentation and another example (#1080) * WIP: Unsized arrays on CPU. * unbounded-array-of-array working on CPU. * Test that has an unbounded array of array directly (ie without wrapping with ParameterBlock). Test works on CPU. * Remove some left over comments. * Added documention on unsized array usage on CPU targets. --- .../compute/unbounded-array-of-array-syntax.slang | 32 ++++++++++++++++++++++ ...ounded-array-of-array-syntax.slang.expected.txt | 8 ++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/compute/unbounded-array-of-array-syntax.slang create mode 100644 tests/compute/unbounded-array-of-array-syntax.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/unbounded-array-of-array-syntax.slang b/tests/compute/unbounded-array-of-array-syntax.slang new file mode 100644 index 000000000..fdc04c95e --- /dev/null +++ b/tests/compute/unbounded-array-of-array-syntax.slang @@ -0,0 +1,32 @@ +//DISABLE_TEST:CPU_REFLECTION: -profile cs_5_0 -entry computeMain -target cpp +//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute + +//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):dxbinding(0),glbinding(0),out,name outputBuffer +RWStructuredBuffer outputBuffer; + +//TEST_INPUT:array(size=2):name g_aoa +RWStructuredBuffer g_aoa[]; + +//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):name=g_aoa[0] +//TEST_INPUT:ubuffer(data=[8 17 34], stride=4):name=g_aoa[1] + +[numthreads(8, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + int index = int(dispatchThreadID.x); + + int baseIndex = index >> 2; + int innerIndex = index & 3; + + RWStructuredBuffer buffer = g_aoa[baseIndex]; + + // Get the size + uint bufferCount, bufferStride; + buffer.GetDimensions(bufferCount, bufferStride); + + if (innerIndex >= bufferCount) + { + innerIndex = bufferCount - 1; + } + outputBuffer[index] = buffer[innerIndex]; +} \ No newline at end of file diff --git a/tests/compute/unbounded-array-of-array-syntax.slang.expected.txt b/tests/compute/unbounded-array-of-array-syntax.slang.expected.txt new file mode 100644 index 000000000..aeec8496c --- /dev/null +++ b/tests/compute/unbounded-array-of-array-syntax.slang.expected.txt @@ -0,0 +1,8 @@ +1 +2 +3 +4 +8 +11 +22 +22 -- cgit v1.2.3