yum-mirror/slang

Making it easier to work with shaders

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

kaizhangNVFeature/initialize list side branch (#6058)9ec6b9168

master
599 B28 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj -vk
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUFFER):-shaderobj
3
4struct Foo
5{
6    int a;
7}
8
9extension Foo
10{
11    __init(int a)
12    {
13        this.a = a + 5;
14    }
15}
16
17//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
18RWStructuredBuffer<int> outputBuffer;
19
20[shader("compute")]
21[numthreads(1, 1, 1)]
22void computeMain()
23{
24    // it will prefer the explicit constructor defined in the extension instead of the synthesized one in the struct
25    Foo foo = {1.0f};
26    //CHECK: BUFFER: 6
27    outputBuffer[0] = foo.a;
28}