summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/type-legalize-global-with-init.slang39
-rw-r--r--tests/compute/type-legalize-global-with-init.slang.expected.txt4
2 files changed, 43 insertions, 0 deletions
diff --git a/tests/compute/type-legalize-global-with-init.slang b/tests/compute/type-legalize-global-with-init.slang
new file mode 100644
index 000000000..0763fd897
--- /dev/null
+++ b/tests/compute/type-legalize-global-with-init.slang
@@ -0,0 +1,39 @@
+// type-legalize-global-with-init.slang
+//
+// Confirm that type legalization can handle a global constant
+// with a resource type or a type that recursively contains
+// resources.
+//
+//TEST(compute):COMPARE_COMPUTE:
+//
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):dxbinding(0),glbinding(0),out
+RWStructuredBuffer<uint> outputBuffer;
+
+//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4):dxbinding(1),glbinding(0)
+RWStructuredBuffer<uint> inputBuffer;
+
+static const RWStructuredBuffer<uint> gBuffer = inputBuffer;
+
+struct Stuff
+{
+ RWStructuredBuffer<uint> a;
+ RWStructuredBuffer<uint> b;
+}
+
+static const Stuff gStuff = { inputBuffer, inputBuffer };
+
+uint test(uint x)
+{
+ return gBuffer[x]
+ + gStuff.a[x + 1] * 16
+ + gStuff.b[x + 2] * 256;
+}
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ let tid = dispatchThreadID.x;
+ let inVal = tid;
+ let outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/compute/type-legalize-global-with-init.slang.expected.txt b/tests/compute/type-legalize-global-with-init.slang.expected.txt
new file mode 100644
index 000000000..893b7d009
--- /dev/null
+++ b/tests/compute/type-legalize-global-with-init.slang.expected.txt
@@ -0,0 +1,4 @@
+321
+432
+543
+654