yum-mirror/slang

Making it easier to work with shaders

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

Ellie HermaszewskaDetect uses of uninitialized resource fields (#7962)ea6f8551a

master
653 B26 linesraw
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl
2
3RWStructuredBuffer<int> outputBuffer;
4
5void useStruct(SomeStruct s)
6{
7    outputBuffer[0] = s.value;
8}
9
10[shader("compute")]
11[numthreads(1,1,1)]
12void computeMain(uint3 threadId : SV_DispatchThreadID)
13{
14    // CHECK: ([[# @LINE+1]]): error {{.*}} cannot default-initialize struct 'SomeStruct' with '{}' because it contains an uninitialized texture field
15    SomeStruct s = {};
16
17    s.value = 10 + threadId.x;
18    useStruct(s);
19}
20
21// CHECK: ([[# @LINE+1]]): note: see definition of struct 'SomeStruct'
22struct SomeStruct
23{
24    int value;
25    Texture1D<float> tex;
26}