yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskamsvc style bitfield packing (#7963)66301ab90

master
756 B31 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -output-using-type -compile-arg -msvc-style-bitfield-packing
2
3// With MSVC packing, bitfields are packed from MSB to LSB
4// and new backing fields start when type sizes change
5// CHECK:      123
6// CHECK-NEXT: 4567
7// CHECK-NEXT: 0
8// CHECK-NEXT: 0
9
10//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
11RWStructuredBuffer<uint> outputBuffer;
12
13struct S {
14    int foo : 8;   // Packed in bits 31-24
15    uint bar : 24; // Packed in bits 23-0
16};
17
18[numthreads(1, 1, 1)]
19void computeMain()
20{
21    S s;
22    s.foo = 123;
23    s.bar = 4567;
24    outputBuffer[0] = s.foo;
25    outputBuffer[1] = s.bar;
26    s.foo = 0;
27    s.bar = 0;
28    outputBuffer[2] = s.foo;
29    outputBuffer[3] = s.bar;
30}
31