@@ -47,6 +47,14 @@ bool RootSignatureParser::parse() {
4747 return true ;
4848 Elements.push_back (*Table);
4949 }
50+
51+ if (tryConsumeExpectedToken (
52+ {TokenKind::kw_CBV, TokenKind::kw_SRV, TokenKind::kw_UAV})) {
53+ auto Descriptor = parseRootDescriptor ();
54+ if (!Descriptor.has_value ())
55+ return true ;
56+ Elements.push_back (*Descriptor);
57+ }
5058 } while (tryConsumeExpectedToken (TokenKind::pu_comma));
5159
5260 return consumeExpectedToken (TokenKind::end_of_stream,
@@ -155,6 +163,41 @@ std::optional<RootConstants> RootSignatureParser::parseRootConstants() {
155163 return Constants;
156164}
157165
166+ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor () {
167+ assert ((CurToken.TokKind == TokenKind::kw_CBV ||
168+ CurToken.TokKind == TokenKind::kw_SRV ||
169+ CurToken.TokKind == TokenKind::kw_UAV) &&
170+ " Expects to only be invoked starting at given keyword" );
171+
172+ TokenKind DescriptorKind = CurToken.TokKind ;
173+
174+ if (consumeExpectedToken (TokenKind::pu_l_paren, diag::err_expected_after,
175+ CurToken.TokKind ))
176+ return std::nullopt ;
177+
178+ RootDescriptor Descriptor;
179+ switch (DescriptorKind) {
180+ default :
181+ llvm_unreachable (" Switch for consumed token was not provided" );
182+ case TokenKind::kw_CBV:
183+ Descriptor.Type = DescriptorType::CBuffer;
184+ break ;
185+ case TokenKind::kw_SRV:
186+ Descriptor.Type = DescriptorType::SRV;
187+ break ;
188+ case TokenKind::kw_UAV:
189+ Descriptor.Type = DescriptorType::UAV;
190+ break ;
191+ }
192+
193+ if (consumeExpectedToken (TokenKind::pu_r_paren,
194+ diag::err_hlsl_unexpected_end_of_params,
195+ /* param of=*/ TokenKind::kw_RootConstants))
196+ return std::nullopt ;
197+
198+ return Descriptor;
199+ }
200+
158201std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable () {
159202 assert (CurToken.TokKind == TokenKind::kw_DescriptorTable &&
160203 " Expects to only be invoked starting at given keyword" );
0 commit comments