summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-03-23 11:25:51 -0700
committerGitHub <noreply@github.com>2024-03-23 11:25:51 -0700
commitc9df734b836a503dbc09c48bfd54b35facd0f105 (patch)
tree165ecf9668e2f25d71e4327dd24c5de7dfd698dc /tests
parenta23adc221b1ea26db3f3313226b629eb9e308b0f (diff)
Allow anonymous struct. (#3822)
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/anonymous-struct.slang36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/language-feature/anonymous-struct.slang b/tests/language-feature/anonymous-struct.slang
new file mode 100644
index 000000000..35b002b5b
--- /dev/null
+++ b/tests/language-feature/anonymous-struct.slang
@@ -0,0 +1,36 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+static const int a = 3;
+static const struct
+{
+ int b;
+} globalStruct = { a };
+
+int test(int r)
+{
+ return r + 1;
+}
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ struct
+ {
+ int member1;
+ int unusedMember;
+ } tt;
+ var tmp = test(1);
+ static struct
+ {
+ int member2;
+ } uu = {tmp};
+ tt.member1 = test(0);
+ // BUF: 1
+ outputBuffer[0] = tt.member1;
+ // BUF: 2
+ outputBuffer[1] = uu.member2;
+ // BUF: 3
+ outputBuffer[2] = globalStruct.b;
+} \ No newline at end of file