blob: 978f61d9f8ecd106074796531cb141b1c36c83d9 (
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
|
// array-out-of-bounds-2.slang
// Test the specific scenario from the issue (array of size 3, accessing index 3)
//TEST:SIMPLE(filecheck=CHECK): -target spirv -entry computeMain -stage compute
struct SH3_t
{
float coeffs[4];
};
RWStructuredBuffer<float> outputBuffer;
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
SH3_t a[3];
SH3_t b;
for (int i = 0; i < 3; ++i)
{
// This should be fine
outputBuffer[i] = a[i].coeffs[0];
}
// This reproduces the issue - accessing index 3 in array of size 3
//CHECK: error 30029: array index '3' is out of bounds for array of size '3'.
outputBuffer[3] = a[3].coeffs[0];
}
|