yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
66301ab90
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu 2 3// Default GCC/Clang style packs from LSB to MSB 4// struct S { uint a:4; uint b:8; uint c:4; uint d:16; } 5// Memory layout (32-bit): 6// bits 0-3: a (0x5) 7// bits 4-11: b (0xAB) 8// bits 12-15: c (0xC) 9// bits 16-31: d (0xDEF0) 10// Expected: 0xDEF0CAB5 11 12// CHECK: DEF0CAB5 13 14//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer 15RWStructuredBuffer<uint> outputBuffer; 16 17struct S { 18 uint a : 4; // bits 0-3 19 uint b : 8; // bits 4-11 20 uint c : 4; // bits 12-15 21 uint d : 16; // bits 16-31 22}; 23 24[numthreads(1, 1, 1)] 25void computeMain() 26{ 27 S s; 28 s.a = 0x5; 29 s.b = 0xAB; 30 s.c = 0xC; 31 s.d = 0xDEF0; 32 33 // Write the struct to memory and read it back as uint 34 outputBuffer[0] = *((uint*)&s); 35} 36