yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9ec6b9168
master
1 2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk 3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj 4 5import modulea; 6 7// Definition of the Foo struct 8// struct Foo 9// { 10// int a; 11// int b; 12// } 13 14// This test demonstrates that whether struct is a C-Style type only depends on the definition of the struct, not the extension. 15// Even we have an explicit constructor defined in extension of Foo, it is still a C-Style type. 16 17extension Foo 18{ 19 __init(int a) 20 { 21 this.a = a + 5; 22 this.b = 3; 23 } 24} 25 26//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 27RWStructuredBuffer<int> outputBuffer; 28 29[shader("compute")] 30[numthreads(1, 1, 1)] 31void computeMain() 32{ 33 34 // This will miss both synthesized constructor and explicit constructor in extension, but it will still fall back 35 // to legacy initializer list because Foo is a C-Style type. 36 Foo foo = {}; 37 //CHECK: BUFFER: 0 38 //CHECK: BUFFER-NEXT: 0 39 outputBuffer[0] = foo.a; 40 outputBuffer[1] = foo.b; 41 42 43 // When providing 1 parameter, it will lookup for the explicit constructor in extension. 44 Foo foo1 = {1}; 45 //CHECK: BUFFER: 6 46 //CHECK: BUFFER-NEXT: 3 47 outputBuffer[2] = foo1.a; 48 outputBuffer[3] = foo1.b; 49}