@@ -240,16 +240,18 @@ std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
240
240
DescriptorTable Table;
241
241
std::optional<llvm::dxbc::ShaderVisibility> Visibility;
242
242
243
- // Iterate as many Clauses as possible
244
- do {
243
+ // Iterate as many Clauses as possible, until we hit ')'
244
+ while (! peekExpectedToken (TokenKind::pu_r_paren)) {
245
245
if (tryConsumeExpectedToken ({TokenKind::kw_CBV, TokenKind::kw_SRV,
246
246
TokenKind::kw_UAV, TokenKind::kw_Sampler})) {
247
+ // DescriptorTableClause - CBV, SRV, UAV, or Sampler
247
248
auto Clause = parseDescriptorTableClause ();
248
249
if (!Clause.has_value ())
249
250
return std::nullopt;
250
251
Elements.push_back (*Clause);
251
252
Table.NumClauses ++;
252
253
} else if (tryConsumeExpectedToken (TokenKind::kw_visibility)) {
254
+ // visibility = SHADER_VISIBILITY
253
255
if (Visibility.has_value ()) {
254
256
reportDiag (diag::err_hlsl_rootsig_repeat_param) << CurToken.TokKind ;
255
257
return std::nullopt;
@@ -262,17 +264,21 @@ std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
262
264
if (!Visibility.has_value ())
263
265
return std::nullopt;
264
266
}
265
- } while (tryConsumeExpectedToken (TokenKind::pu_comma));
266
267
267
- // Fill in optional visibility
268
- if (Visibility.has_value ())
269
- Table.Visibility = Visibility.value ();
268
+ // ',' denotes another element, otherwise, expected to be at ')'
269
+ if (!tryConsumeExpectedToken (TokenKind::pu_comma))
270
+ break ;
271
+ }
270
272
271
273
if (consumeExpectedToken (TokenKind::pu_r_paren,
272
274
diag::err_hlsl_unexpected_end_of_params,
273
275
/* param of=*/ TokenKind::kw_DescriptorTable))
274
276
return std::nullopt;
275
277
278
+ // Fill in optional visibility
279
+ if (Visibility.has_value ())
280
+ Table.Visibility = Visibility.value ();
281
+
276
282
return Table;
277
283
}
278
284
0 commit comments