| 1 |
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only %s -verify |
| 2 |
// RUN: not %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only %s 2>&1 | FileCheck %s |
| 3 |
|
| 4 |
// Attr test |
| 5 |
|
| 6 |
[RootSignature()] // expected-error {{expected string literal as argument of 'RootSignature' attribute}} |
| 7 |
void bad_root_signature_0() {} |
| 8 |
|
| 9 |
// expected-error@+2 {{expected ')'}} |
| 10 |
// expected-note@+1 {{to match this '('}} |
| 11 |
[RootSignature("", "")] |
| 12 |
void bad_root_signature_1() {} |
| 13 |
|
| 14 |
[RootSignature(""), RootSignature("DescriptorTable()")] // expected-error {{attribute 'RootSignature' cannot appear more than once on a declaration}} |
| 15 |
void bad_root_signature_2() {} |
| 16 |
|
| 17 |
[RootSignature(""), RootSignature("")] // expected-warning {{attribute 'RootSignature' is already applied}} |
| 18 |
void bad_root_signature_3() {} |
| 19 |
|
| 20 |
// expected-error@+1 {{invalid parameter of RootSignature}} |
| 21 |
[RootSignature("DescriptorTable(), invalid")] |
| 22 |
void bad_root_signature_4() {} |
| 23 |
|
| 24 |
// expected-error@+1 {{expected ')' or ','}} |
| 25 |
[RootSignature("RootConstants(b0 num32BitConstants = 1)")] |
| 26 |
void bad_root_signature_5() {} |
| 27 |
|
| 28 |
#define MultiLineRootSignature \ |
| 29 |
"CBV(b0)," \ |
| 30 |
"RootConstants(num32BitConstants = 3, b0, invalid)" |
| 31 |
|
| 32 |
// CHECK: [[@LINE-2]]:44: note: expanded from macro 'MultiLineRootSignature' |
| 33 |
// CHECK-NEXT: [[@LINE-3]] | "RootConstants(num32BitConstants = 3, b0, invalid)" |
| 34 |
// CHECK-NEXT: | ^ |
| 35 |
// expected-error@+1 {{invalid parameter of RootConstants}} |
| 36 |
[RootSignature(MultiLineRootSignature)] |
| 37 |
void bad_root_signature_6() {} |
| 38 |
|
| 39 |
// expected-error@+1 {{expected end of stream or ','}} |
| 40 |
[RootSignature("RootFlags() RootConstants(b0, num32BitConstants = 1)")] |
| 41 |
void bad_root_signature_7() {} |
| 42 |
|
| 43 |
// expected-error@+1 {{invalid parameter of RootConstants}} |
| 44 |
[RootSignature("RootConstants(b0, num32BitConstantsTypo = 1))")] |
| 45 |
void bad_root_signature_8() {} |
| 46 |
|
| 47 |
// expected-error@+1 {{invalid parameter of UAV}} |
| 48 |
[RootSignature("UAV(b3")] |
| 49 |
void bad_root_signature_9() {} |
| 50 |
|
| 51 |
// expected-error@+1 {{invalid parameter of SRV}} |
| 52 |
[RootSignature("DescriptorTable(SRV(s1, invalid))")] |
| 53 |
void bad_root_signature_10() {} |
| 54 |
|
| 55 |
// expected-error@+1 {{invalid parameter of DescriptorTable}} |
| 56 |
[RootSignature("DescriptorTable(invalid))")] |
| 57 |
void bad_root_signature_11() {} |
| 58 |
|
| 59 |
// expected-error@+1 {{expected integer literal after '+'}} |
| 60 |
[RootSignature("CBV(space = +invalid))")] |
| 61 |
void bad_root_signature_12() {} |
| 62 |
|
| 63 |
// expected-error@+1 {{expected integer literal after '='}} |
| 64 |
[RootSignature("CBV(space = invalid))")] |
| 65 |
void bad_root_signature_13() {} |
| 66 |
|
| 67 |
// expected-error@+1 {{expected '(' after UAV}} |
| 68 |
[RootSignature("UAV invalid")] |
| 69 |
void bad_root_signature_14() {} |
| 70 |
|
| 71 |
// expected-error@+1 {{invalid value of visibility}} |
| 72 |
[RootSignature("StaticSampler(s0, visibility = visibility_typo)")] |
| 73 |
void bad_root_signature_15() {} |
| 74 |
|
| 75 |
// expected-error@+1 {{invalid value of filter}} |
| 76 |
[RootSignature("StaticSampler(s0, filter = filter_typo)")] |
| 77 |
void bad_root_signature_16() {} |
| 78 |
|
| 79 |
// expected-error@+1 {{invalid value of addressU}} |
| 80 |
[RootSignature("StaticSampler(s0, addressU = addressU_typo)")] |
| 81 |
void bad_root_signature_17() {} |
| 82 |
|
| 83 |
// expected-error@+1 {{invalid value of addressV}} |
| 84 |
[RootSignature("StaticSampler(s0, addressV = addressV_typo)")] |
| 85 |
void bad_root_signature_18() {} |
| 86 |
|
| 87 |
// expected-error@+1 {{invalid value of comparisonFunc}} |
| 88 |
[RootSignature("StaticSampler(s0, comparisonFunc = comparisonFunc_typo)")] |
| 89 |
void bad_root_signature_19() {} |
| 90 |
|
| 91 |
// expected-error@+1 {{invalid value of borderColor}} |
| 92 |
[RootSignature("StaticSampler(s0, borderColor = borderColor_typo)")] |
| 93 |
void bad_root_signature_20() {} |
| 94 |
|
| 95 |
// expected-error@+1 {{invalid value of flags}} |
| 96 |
[RootSignature("CBV(b0, flags = DATA_VOLATILE | root_descriptor_flag_typo)")] |
| 97 |
void bad_root_signature_21() {} |
| 98 |
|
| 99 |
// expected-error@+1 {{invalid value of flags}} |
| 100 |
[RootSignature("DescriptorTable(SRV(t0, flags = descriptor_range_flag_typo)")] |
| 101 |
void bad_root_signature_22() {} |
| 102 |
|
| 103 |
// expected-error@+1 {{invalid value of RootFlags}} |
| 104 |
[RootSignature("RootFlags(local_root_signature | root_flag_typo)")] |
| 105 |
void bad_root_signature_23() {} |
| 106 |
|
| 107 |
#define DemoMultipleErrorsRootSignature \ |
| 108 |
"CBV(b0, space = invalid)," \ |
| 109 |
"StaticSampler()" \ |
| 110 |
"DescriptorTable(" \ |
| 111 |
" visibility = SHADER_VISIBILITY_ALL," \ |
| 112 |
" visibility = SHADER_VISIBILITY_DOMAIN," \ |
| 113 |
")," \ |
| 114 |
"SRV(t0, space = 28947298374912374098172)" \ |
| 115 |
"UAV(u0, flags = 3)" \ |
| 116 |
"DescriptorTable(Sampler(s0 flags = DATA_VOLATILE))," \ |
| 117 |
"CBV(b0),," |
| 118 |
|
| 119 |
// expected-error@+7 {{expected integer literal after '='}} |
| 120 |
// expected-error@+6 {{did not specify mandatory parameter 's register'}} |
| 121 |
// expected-error@+5 {{specified the same parameter 'visibility' multiple times}} |
| 122 |
// expected-error@+4 {{integer literal is too large to be represented as a 32-bit signed integer type}} |
| 123 |
// expected-error@+3 {{flag value is neither a literal 0 nor a named value}} |
| 124 |
// expected-error@+2 {{expected ')' or ','}} |
| 125 |
// expected-error@+1 {{invalid parameter of RootSignature}} |
| 126 |
[RootSignature(DemoMultipleErrorsRootSignature)] |
| 127 |
void multiple_errors() {} |
| 128 |
|
| 129 |
#define DemoGranularityRootSignature \ |
| 130 |
"CBV(b0, reported_diag, flags = skipped_diag)," \ |
| 131 |
"DescriptorTable( " \ |
| 132 |
" UAV(u0, reported_diag), " \ |
| 133 |
" SRV(t0, skipped_diag), " \ |
| 134 |
")," \ |
| 135 |
"StaticSampler(s0, reported_diag, SRV(t0, reported_diag)" \ |
| 136 |
"" |
| 137 |
|
| 138 |
// expected-error@+4 {{invalid parameter of CBV}} |
| 139 |
// expected-error@+3 {{invalid parameter of UAV}} |
| 140 |
// expected-error@+2 {{invalid parameter of StaticSampler}} |
| 141 |
// expected-error@+1 {{invalid parameter of SRV}} |
| 142 |
[RootSignature(DemoGranularityRootSignature)] |
| 143 |
void granularity_errors() {} |
| 144 |
|
| 145 |
#define TestTableScope \ |
| 146 |
"DescriptorTable( " \ |
| 147 |
" UAV(u0, reported_diag), " \ |
| 148 |
" SRV(t0, skipped_diag), " \ |
| 149 |
" Sampler(s0, skipped_diag), " \ |
| 150 |
")," \ |
| 151 |
"CBV(s0, reported_diag)" |
| 152 |
|
| 153 |
// expected-error@+2 {{invalid parameter of UAV}} |
| 154 |
// expected-error@+1 {{invalid parameter of CBV}} |
| 155 |
[RootSignature(TestTableScope)] |
| 156 |
void recover_scope_errors() {} |
| 157 |
|
| 158 |
// Basic validation of register value and space |
| 159 |
|
| 160 |
// expected-error@+2 {{value must be in the range [0, 4294967294]}} |
| 161 |
// expected-error@+1 {{value must be in the range [0, 4294967279]}} |
| 162 |
[RootSignature("CBV(b4294967295, space = 4294967280)")] |
| 163 |
void basic_validation_0() {} |
| 164 |
|
| 165 |
// expected-error@+2 {{value must be in the range [0, 4294967294]}} |
| 166 |
// expected-error@+1 {{value must be in the range [0, 4294967279]}} |
| 167 |
[RootSignature("RootConstants(b4294967295, space = 4294967280, num32BitConstants = 1)")] |
| 168 |
void basic_validation_1() {} |
| 169 |
|
| 170 |
// expected-error@+2 {{value must be in the range [0, 4294967294]}} |
| 171 |
// expected-error@+1 {{value must be in the range [0, 4294967279]}} |
| 172 |
[RootSignature("StaticSampler(s4294967295, space = 4294967280)")] |
| 173 |
void basic_validation_2() {} |
| 174 |
|
| 175 |
// expected-error@+2 {{value must be in the range [0, 4294967294]}} |
| 176 |
// expected-error@+1 {{value must be in the range [0, 4294967279]}} |
| 177 |
[RootSignature("DescriptorTable(SRV(t4294967295, space = 4294967280))")] |
| 178 |
void basic_validation_3() {} |
| 179 |
|
| 180 |
// expected-error@+2 {{value must be in the range [1, 4294967294]}} |
| 181 |
// expected-error@+1 {{value must be in the range [1, 4294967294]}} |
| 182 |
[RootSignature("DescriptorTable(UAV(u0, numDescriptors = 0)), DescriptorTable(Sampler(s0, numDescriptors = 0))")] |
| 183 |
void basic_validation_4() {} |
| 184 |
|
| 185 |
// expected-error@+2 {{value must be in the range [0, 16]}} |
| 186 |
// expected-error@+1 {{value must be in the range [-16.00, 15.99]}} |
| 187 |
[RootSignature("StaticSampler(s0, maxAnisotropy = 17, mipLODBias = -16.000001)")] |
| 188 |
void basic_validation_5() {} |
| 189 |
|
| 190 |
// expected-error@+1 {{value must be in the range [-16.00, 15.99]}} |
| 191 |
[RootSignature("StaticSampler(s0, mipLODBias = 15.990001)")] |
| 192 |
void basic_validation_6() {} |
| 193 |
|
| 194 |
// expected-error@+1 {{invalid value of flags}} |
| 195 |
[RootSignature("StaticSampler(s0, flags = FLAG_TYPO)")] |
| 196 |
void basic_validation_7() {} |
| 197 |
|
| 198 |
// expected-error@+1 {{sampler and non-sampler resource mixed in descriptor table}} |
| 199 |
[RootSignature("DescriptorTable(Sampler(s0), CBV(b0))")] |
| 200 |
void mixed_resource_table() {} |