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 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - -fsyntax-only %s -verify
// This test validates the diagnostics that are emitted when a variable with a "resource" type
// is bound to a register using the register annotation
template<typename T>
struct MyTemplatedSRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};
struct MySRV {
__hlsl_resource_t [[hlsl::resource_class(SRV)]] x;
};
struct MySampler {
__hlsl_resource_t [[hlsl::resource_class(Sampler)]] x;
};
struct MyUAV {
__hlsl_resource_t [[hlsl::resource_class(UAV)]] x;
};
struct MyCBuffer {
__hlsl_resource_t [[hlsl::resource_class(CBuffer)]] x;
};
// expected-error@+1 {{binding type 'i' ignored. The 'integer constant' binding type is no longer supported}}
MySRV invalid : register(i2);
// expected-error@+1 {{binding type 't' only applies to SRV resources}}
MyUAV a : register(t2, space1);
// expected-error@+1 {{binding type 'u' only applies to UAV resources}}
MySampler b : register(u2, space1);
// expected-error@+1 {{binding type 'b' only applies to constant buffer resources}}
MyTemplatedSRV<int> c : register(b2);
// expected-error@+1 {{binding type 's' only applies to sampler state}}
MyUAV d : register(s2, space1);
// empty binding prefix cases:
// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> e: register();
// expected-error@+1 {{expected identifier}}
MyTemplatedSRV<int> f: register("");
|