yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
3072cfea9
master
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj 3 4struct PartialInit { 5 // warning: not all members are initialized. 6 // members should either be all-uninitialized or all-initialized with 7 // default expr. 8 int x; 9 int y = 1; 10 // compiler synthesizes: 11 // __init(int x = {}, int y = 1); 12} 13 14struct PartialInit2 { 15 int x = 1; 16 int y; 17 // __init(int x, int y = {}); 18} 19//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer 20RWStructuredBuffer<int> outputBuffer; 21void test() 22{ 23 PartialInit p1 = {2}; // calls `__init`, result is `{2,1}`. 24 // BUFFER: 2 25 outputBuffer[0] = p1.x; 26 // BUFFER-NEXT: 1 27 outputBuffer[1] = p1.y; 28 29 30 PartialInit p2 = {2, 3}; // calls `__init`, result is {2, 3} 31 // BUFFER-NEXT: 2 32 outputBuffer[2] = p2.x; 33 // BUFFER-NEXT: 3 34 outputBuffer[3] = p2.y; 35 36 PartialInit2 p3 = {4, 5}; // calls `__init`, result is {4, 5} 37 // BUFFER-NEXT: 4 38 outputBuffer[4] = p3.x; 39 // BUFFER-NEXT: 5 40 outputBuffer[5] = p3.y; 41 42 PartialInit p4 = {}; // calls `__init`, result is {0, 1} 43 // BUFFER-NEXT: 0 44 outputBuffer[6] = p4.x; 45 // BUFFER-NEXT: 1 46 outputBuffer[7] = p4.y; 47 48 PartialInit2 p5 = {}; // calls `__init`, result is {1, 0} 49 // BUFFER-NEXT: 1 50 outputBuffer[8] = p5.x; 51 // BUFFER-NEXT: 0 52 outputBuffer[9] = p5.y; 53} 54 55[shader("compute")] 56void computeMain() 57{ 58 test(); 59}