blob: b02be1af0454af389f16b38e6eef473a9b5a7f05 (
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
27
28
29
30
31
32
33
34
35
|
//TEST:SIMPLE(filecheck=SPV): -target spirv
//TEST:SIMPLE(filecheck=HLSL): -target hlsl -profile cs_6_0 -entry computeMain
struct MyData
{
int a[0][0][0];
}
uniform MyData* myData;
uniform int * output;
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
// These are all ill-formed, but we want to still ensure our backend
// can handle them gracefully without crashing.
// In actual user code, any access to 0-sized arrays should be protected
// by a `if` statement that checks the size before accessing.
// The condition would then evaluate to false and causing all the accessing
// code to be optimized out.
// Use runtime values to access the 0-sized array to avoid triggering
// the new out-of-bounds diagnostic for constant indices
uint runtimeIndex = dispatchThreadID.x;
InterlockedAdd(myData.a[runtimeIndex][runtimeIndex][runtimeIndex], 1);
myData.a[runtimeIndex][runtimeIndex][runtimeIndex] += 1;
output[0] = myData.a[runtimeIndex][runtimeIndex][runtimeIndex];
}
//SPV: OpEntryPoint
//SPV-NOT: OpAtomic
//SPV-NOT: OpStore
//SPV-NOT: OpLoad
//HLSL: computeMain
|