From 4583e395ad503b63343a14adaeb621dee8a8da71 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Thu, 1 Feb 2018 12:06:06 -0800 Subject: Implement type splitting for raw buffers (#393) * Fix render-test to handle raw buffers I don't know if this fix will work for UAVs that are neither structured nor raw, but it fixes the code that currently only really works if every UAV is structured (since it doesn't set a format). * Make type legalization consider raw buffer types The type layout logic was already handling these, but the type splitting logic in legalization was failing to split structure types that contain, e.g., `RWByteAddressBuffer`. A compute test case has been added to confirm the fix. --- tests/compute/buffer-type-splitting.slang | 29 ++++++++++++++++++++++ .../buffer-type-splitting.slang.expected.txt | 4 +++ 2 files changed, 33 insertions(+) create mode 100644 tests/compute/buffer-type-splitting.slang create mode 100644 tests/compute/buffer-type-splitting.slang.expected.txt (limited to 'tests') diff --git a/tests/compute/buffer-type-splitting.slang b/tests/compute/buffer-type-splitting.slang new file mode 100644 index 000000000..c7577a0b2 --- /dev/null +++ b/tests/compute/buffer-type-splitting.slang @@ -0,0 +1,29 @@ +//TEST(compute):COMPARE_COMPUTE: +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out +//TEST_INPUT:ubuffer(data=[0 2 3 3]):dxbinding(1),glbinding(1) +//TEST_INPUT:ubuffer(data=[4 5 6 7]):dxbinding(2),glbinding(2) +//TEST_INPUT:ubuffer(data=[8 9 10 11]):dxbinding(3),glbinding(3) +//TEST_INPUT:ubuffer(data=[12 13 14 15]):dxbinding(4),glbinding(4) + +RWStructuredBuffer outputBuffer; + +struct S +{ + RWByteAddressBuffer a; + RWByteAddressBuffer b; +}; +S s[2]; + +[numthreads(4, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + uint i = dispatchThreadID.x; + + int val = + s[0].a.Load(i * 4) + + s[1].a.Load(i * 4)*16 + + s[0].b.Load(i * 4)*256 + + s[1].b.Load(i * 4)*4096; + + outputBuffer[i] = val; +} \ No newline at end of file diff --git a/tests/compute/buffer-type-splitting.slang.expected.txt b/tests/compute/buffer-type-splitting.slang.expected.txt new file mode 100644 index 000000000..4bc5fcbf9 --- /dev/null +++ b/tests/compute/buffer-type-splitting.slang.expected.txt @@ -0,0 +1,4 @@ +C840 +D952 +EA63 +FB73 -- cgit v1.2.3