summaryrefslogtreecommitdiffstats
path: root/tests/diagnostics/uninitialized-resource-field.slang
blob: b2e87effb14c82abf8956c03754176749a18b8e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): -stage compute -entry computeMain -target hlsl

RWStructuredBuffer<int> outputBuffer;

void useStruct(SomeStruct s)
{
    outputBuffer[0] = s.value;
}

[shader("compute")]
[numthreads(1,1,1)]
void computeMain(uint3 threadId : SV_DispatchThreadID)
{
    // CHECK: ([[# @LINE+1]]): error {{.*}} cannot default-initialize struct 'SomeStruct' with '{}' because it contains an uninitialized texture field
    SomeStruct s = {};

    s.value = 10 + threadId.x;
    useStruct(s);
}

// CHECK: ([[# @LINE+1]]): note: see definition of struct 'SomeStruct'
struct SomeStruct
{
    int value;
    Texture1D<float> tex;
}