| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify |
| 2 |
|
| 3 |
// This test validates the diagnostics that are emitted when a variable with a "resource" type |
| 4 |
// is bound to a register using the register annotation |
| 5 |
|
| 6 |
|
| 7 |
template<typename T> |
| 8 |
struct MyTemplatedSRV { |
| 9 |
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x; |
| 10 |
}; |
| 11 |
|
| 12 |
struct MySRV { |
| 13 |
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x; |
| 14 |
}; |
| 15 |
|
| 16 |
struct MySampler { |
| 17 |
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x; |
| 18 |
}; |
| 19 |
|
| 20 |
struct MyUAV { |
| 21 |
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x; |
| 22 |
}; |
| 23 |
|
| 24 |
struct MyCBuffer { |
| 25 |
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x; |
| 26 |
}; |
| 27 |
|
| 28 |
|
| 29 |
// expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}} |
| 30 |
MySRV invalid : register(i2); |
| 31 |
|
| 32 |
// expected-error@+1 {{binding type 't' only applies to SRV resources}} |
| 33 |
MyUAV a : register(t2, space1); |
| 34 |
|
| 35 |
// expected-error@+1 {{binding type 'u' only applies to UAV resources}} |
| 36 |
MySampler b : register(u2, space1); |
| 37 |
|
| 38 |
// expected-error@+1 {{binding type 'b' only applies to constant buffer resources}} |
| 39 |
MyTemplatedSRV<int> c : register(b2); |
| 40 |
|
| 41 |
// expected-error@+1 {{binding type 's' only applies to sampler state}} |
| 42 |
MyUAV d : register(s2, space1); |
| 43 |
|
| 44 |
// empty binding prefix cases: |
| 45 |
// expected-error@+1 {{expected identifier}} |
| 46 |
MyTemplatedSRV<int> e: register(); |
| 47 |
|
| 48 |
// expected-error@+1 {{expected identifier}} |
| 49 |
MyTemplatedSRV<int> f: register(""); |