summaryrefslogtreecommitdiff
path: root/tests/language-feature/bitfield/msvc-simple.slang
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2025-07-31 15:23:13 +0800
committerGitHub <noreply@github.com>2025-07-31 07:23:13 +0000
commit66301ab9068c5705e5a2bcbf2eaadfb28e8bb084 (patch)
tree3682e0224df6706bcf70f58e37873c1d078c785c /tests/language-feature/bitfield/msvc-simple.slang
parentdb59c22cfb774e984a207a074f13870b78ec0071 (diff)
msvc style bitfield packing (#7963)
Closes https://github.com/shader-slang/slang/issues/3646 New tests rather than just adding another TEST line to existing tests so that we get the msvc- prefix in the output of slang-test
Diffstat (limited to 'tests/language-feature/bitfield/msvc-simple.slang')
-rw-r--r--tests/language-feature/bitfield/msvc-simple.slang31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/language-feature/bitfield/msvc-simple.slang b/tests/language-feature/bitfield/msvc-simple.slang
new file mode 100644
index 000000000..4651626b8
--- /dev/null
+++ b/tests/language-feature/bitfield/msvc-simple.slang
@@ -0,0 +1,31 @@
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type -compile-arg -msvc-style-bitfield-packing
+
+// With MSVC packing, bitfields are packed from MSB to LSB
+// and new backing fields start when type sizes change
+// CHECK: 123
+// CHECK-NEXT: 4567
+// CHECK-NEXT: 0
+// CHECK-NEXT: 0
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+struct S {
+ int foo : 8; // Packed in bits 31-24
+ uint bar : 24; // Packed in bits 23-0
+};
+
+[numthreads(1, 1, 1)]
+void computeMain()
+{
+ S s;
+ s.foo = 123;
+ s.bar = 4567;
+ outputBuffer[0] = s.foo;
+ outputBuffer[1] = s.bar;
+ s.foo = 0;
+ s.bar = 0;
+ outputBuffer[2] = s.foo;
+ outputBuffer[3] = s.bar;
+}
+