| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify |
| 2 |
|
| 3 |
// test semantic validation for register numbers that exceed UINT32_MAX |
| 4 |
|
| 5 |
struct S { |
| 6 |
RWBuffer<float> A[4]; |
| 7 |
RWBuffer<int> B[10]; |
| 8 |
}; |
| 9 |
|
| 10 |
// do some more nesting |
| 11 |
struct S2 { |
| 12 |
S a[3]; |
| 13 |
}; |
| 14 |
|
| 15 |
// test that S.A carries the register number over the limit and emits the error |
| 16 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 17 |
S s : register(u4294967294); // UINT32_MAX - 1 |
| 18 |
|
| 19 |
// test the error is also triggered when analyzing S.B |
| 20 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 21 |
S s2 : register(u4294967289); |
| 22 |
|
| 23 |
|
| 24 |
// test the error is also triggered when analyzing S2.a[1].B |
| 25 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 26 |
S2 s3 : register(u4294967275); |
| 27 |
|
| 28 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 29 |
RWBuffer<float> Buf[10][10] : register(u4294967234); |
| 30 |
|
| 31 |
// test a standard resource array |
| 32 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 33 |
RWBuffer<float> Buf2[10] : register(u4294967294); |
| 34 |
|
| 35 |
// test directly an excessively high register number. |
| 36 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 37 |
RWBuffer<float> A : register(u9995294967294); |
| 38 |
|
| 39 |
// test a cbuffer directly with an excessively high register number. |
| 40 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 41 |
cbuffer MyCB : register(b9995294967294) { |
| 42 |
float F[4]; |
| 43 |
int I[10]; |
| 44 |
}; |
| 45 |
|
| 46 |
struct MySRV { |
| 47 |
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x; |
| 48 |
}; |
| 49 |
|
| 50 |
struct MySampler { |
| 51 |
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x; |
| 52 |
}; |
| 53 |
|
| 54 |
struct MyUAV { |
| 55 |
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x; |
| 56 |
}; |
| 57 |
|
| 58 |
// test that different resource classes don't contribute to the |
| 59 |
// maximum limit |
| 60 |
struct MyResources { |
| 61 |
MySRV TheSRV[10]; // t |
| 62 |
MySampler TheSampler[20]; // s |
| 63 |
MyUAV TheUAV[40]; // u |
| 64 |
}; |
| 65 |
|
| 66 |
// no failures here, since only the SRV contributes to the count, |
| 67 |
// and the count + 10 does not exceed uint32 max. |
| 68 |
MyResources M : register(t4294967284); |
| 69 |
|
| 70 |
// three failures, since each of the three resources exceed the limit |
| 71 |
// expected-error@+3 {{register number should not exceed 4294967295}} |
| 72 |
// expected-error@+2 {{register number should not exceed 4294967295}} |
| 73 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 74 |
MyResources M2 : register(t4294967294) : register(s4294967294) : register(u4294967294); |
| 75 |
|
| 76 |
// one failure here, just because the final UAV exceeds the limit. |
| 77 |
// expected-error@+1 {{register number should not exceed 4294967295}} |
| 78 |
MyResources M3 : register(t2) : register(s3) : register(u4294967280); |
| 79 |
|
| 80 |
|
| 81 |
// expected-error@+1 {{register number should be an integer}} |
| 82 |
RWBuffer<float> Buf3[10][10] : register(ud); |
| 83 |
|
| 84 |
// this should work |
| 85 |
RWBuffer<float> GoodBuf : register(u4294967295); |
| 86 |
|
| 87 |
// no errors expected, all 100 register numbers are occupied here |
| 88 |
RWBuffer<float> GoodBufArray[10][10] : register(u4294967194); |
| 89 |
|
| 90 |
|