@@ -130,10 +130,14 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
130
130
const llvm::StringLiteral Source = R"cc(
131
131
DescriptorTable(
132
132
CBV(b0),
133
- SRV(space = 3, t42),
133
+ SRV(space = 3, t42, flags = 0 ),
134
134
visibility = SHADER_VISIBILITY_PIXEL,
135
135
Sampler(s987, space = +2),
136
- UAV(u4294967294)
136
+ UAV(u4294967294,
137
+ flags = Descriptors_Volatile | Data_Volatile
138
+ | Data_Static_While_Set_At_Execute | Data_Static
139
+ | Descriptors_Static_Keeping_Buffer_Bounds_Checks
140
+ )
137
141
),
138
142
DescriptorTable()
139
143
)cc" ;
@@ -159,6 +163,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
159
163
RegisterType::BReg);
160
164
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Reg .Number , 0u );
161
165
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Space , 0u );
166
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Flags ,
167
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute);
162
168
163
169
Elem = Elements[1 ];
164
170
ASSERT_TRUE (std::holds_alternative<DescriptorTableClause>(Elem));
@@ -167,6 +173,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
167
173
RegisterType::TReg);
168
174
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Reg .Number , 42u );
169
175
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Space , 3u );
176
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Flags ,
177
+ DescriptorRangeFlags::None);
170
178
171
179
Elem = Elements[2 ];
172
180
ASSERT_TRUE (std::holds_alternative<DescriptorTableClause>(Elem));
@@ -175,6 +183,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
175
183
RegisterType::SReg);
176
184
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Reg .Number , 987u );
177
185
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Space , 2u );
186
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Flags ,
187
+ DescriptorRangeFlags::None);
178
188
179
189
Elem = Elements[3 ];
180
190
ASSERT_TRUE (std::holds_alternative<DescriptorTableClause>(Elem));
@@ -183,6 +193,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
183
193
RegisterType::UReg);
184
194
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Reg .Number , 4294967294u );
185
195
ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Space , 0u );
196
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Flags ,
197
+ DescriptorRangeFlags::ValidFlags);
186
198
187
199
Elem = Elements[4 ];
188
200
ASSERT_TRUE (std::holds_alternative<DescriptorTable>(Elem));
@@ -199,6 +211,35 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
199
211
ASSERT_TRUE (Consumer->isSatisfied ());
200
212
}
201
213
214
+ TEST_F (ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
215
+ // This test will checks we can set the valid enum for Sampler descriptor
216
+ // range flags
217
+ const llvm::StringLiteral Source = R"cc(
218
+ DescriptorTable(Sampler(s0, flags = DESCRIPTORS_VOLATILE))
219
+ )cc" ;
220
+
221
+ TrivialModuleLoader ModLoader;
222
+ auto PP = createPP (Source, ModLoader);
223
+ auto TokLoc = SourceLocation ();
224
+
225
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
226
+ SmallVector<RootElement> Elements;
227
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
228
+
229
+ // Test no diagnostics produced
230
+ Consumer->setNoDiag ();
231
+
232
+ ASSERT_FALSE (Parser.parse ());
233
+
234
+ RootElement Elem = Elements[0 ];
235
+ ASSERT_TRUE (std::holds_alternative<DescriptorTableClause>(Elem));
236
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Type , ClauseType::Sampler);
237
+ ASSERT_EQ (std::get<DescriptorTableClause>(Elem).Flags ,
238
+ DescriptorRangeFlags::ValidSamplerFlags);
239
+
240
+ ASSERT_TRUE (Consumer->isSatisfied ());
241
+ }
242
+
202
243
TEST_F (ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
203
244
// This test will checks we can handling trailing commas ','
204
245
const llvm::StringLiteral Source = R"cc(
@@ -383,4 +424,28 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
383
424
ASSERT_TRUE (Consumer->isSatisfied ());
384
425
}
385
426
427
+ TEST_F (ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) {
428
+ // This test will check that parsing fails when a non-zero integer literal
429
+ // is given to flags
430
+ const llvm::StringLiteral Source = R"cc(
431
+ DescriptorTable(
432
+ CBV(b0, flags = 3)
433
+ )
434
+ )cc" ;
435
+
436
+ TrivialModuleLoader ModLoader;
437
+ auto PP = createPP (Source, ModLoader);
438
+ auto TokLoc = SourceLocation ();
439
+
440
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
441
+ SmallVector<RootElement> Elements;
442
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
443
+
444
+ // Test correct diagnostic produced
445
+ Consumer->setExpected (diag::err_expected);
446
+ ASSERT_TRUE (Parser.parse ());
447
+
448
+ ASSERT_TRUE (Consumer->isSatisfied ());
449
+ }
450
+
386
451
} // anonymous namespace
0 commit comments