-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL][RootSignature] Update setDefaultFlags
to account for Root Signature Version
#145828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-clang Author: Finn Plummer (inbelic) ChangesThis pr updates
Patch is 27.55 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/145828.diff 7 Files Affected:
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h
index afa2c4d8cfe50..b306cb0245b85 100644
--- a/clang/include/clang/Parse/ParseHLSLRootSignature.h
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -27,7 +27,8 @@ namespace hlsl {
class RootSignatureParser {
public:
- RootSignatureParser(SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
+ RootSignatureParser(llvm::dxbc::RootSignatureVersion Version,
+ SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
RootSignatureLexer &Lexer, clang::Preprocessor &PP);
/// Consumes tokens from the Lexer and constructs the in-memory
@@ -191,6 +192,7 @@ class RootSignatureParser {
bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
private:
+ llvm::dxbc::RootSignatureVersion Version;
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
RootSignatureLexer &Lexer;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index c1493a5bfd3b3..f5bf9549c7830 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4957,7 +4957,8 @@ void Parser::ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
// Invoke the root signature parser to construct the in-memory constructs
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
- hlsl::RootSignatureParser Parser(RootElements, Lexer, PP);
+ hlsl::RootSignatureParser Parser(getLangOpts().HLSLRootSigVer, RootElements,
+ Lexer, PP);
if (Parser.parse()) {
T.consumeClose();
return;
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp b/clang/lib/Parse/ParseHLSLRootSignature.cpp
index e510302c3aae0..81b6953ea708f 100644
--- a/clang/lib/Parse/ParseHLSLRootSignature.cpp
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -17,10 +17,12 @@ namespace hlsl {
using TokenKind = RootSignatureToken::Kind;
-RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
- RootSignatureLexer &Lexer,
- Preprocessor &PP)
- : Elements(Elements), Lexer(Lexer), PP(PP), CurToken(SourceLocation()) {}
+RootSignatureParser::RootSignatureParser(
+ llvm::dxbc::RootSignatureVersion Version,
+ SmallVector<RootElement> &Elements, RootSignatureLexer &Lexer,
+ Preprocessor &PP)
+ : Version(Version), Elements(Elements), Lexer(Lexer), PP(PP),
+ CurToken(SourceLocation()) {}
bool RootSignatureParser::parse() {
// Iterate as many RootElements as possible
@@ -198,7 +200,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
ExpectedReg = TokenKind::uReg;
break;
}
- Descriptor.setDefaultFlags();
+ Descriptor.setDefaultFlags(Version);
auto Params = parseRootDescriptorParams(ExpectedReg);
if (!Params.has_value())
@@ -317,7 +319,7 @@ RootSignatureParser::parseDescriptorTableClause() {
ExpectedReg = TokenKind::sReg;
break;
}
- Clause.setDefaultFlags();
+ Clause.setDefaultFlags(Version);
auto Params = parseDescriptorTableClauseParams(ExpectedReg);
if (!Params.has_value())
diff --git a/clang/test/AST/HLSL/RootSignatures-AST.hlsl b/clang/test/AST/HLSL/RootSignatures-AST.hlsl
index 1e60b9367c145..b8767a18ec719 100644
--- a/clang/test/AST/HLSL/RootSignatures-AST.hlsl
+++ b/clang/test/AST/HLSL/RootSignatures-AST.hlsl
@@ -37,13 +37,17 @@
// CHECK-SAME: space = 1, visibility = All, flags = DataStatic
// CHECK-SAME: ),
// CHECK-SAME: RootSRV(t0,
-// CHECK-SAME: space = 0, visibility = All, flags = DataStaticWhileSetAtExecute
+// CHECK-SAME: space = 0, visibility = All,
+// CHECK-V1_0-SAME: flags = DataVolatile
+// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute
// CHECK-SAME: ),
// CHECK-SAME: RootUAV(
// CHECK-SAME: u0, space = 0, visibility = All, flags = DataVolatile
// CHECK-SAME: ),
// CHECK-SAME: CBV(
-// CHECK-SAME: b1, numDescriptors = 1, space = 0, offset = DescriptorTableOffsetAppend, flags = DataStaticWhileSetAtExecute
+// CHECK-SAME: b1, numDescriptors = 1, space = 0, offset = DescriptorTableOffsetAppend,
+// CHECK-V1_0-SAME: flags = DescriptorsVolatile | DataVolatile
+// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute
// CHECK-SAME: ),
// CHECK-SAME: SRV(
// CHECK-SAME: t1, numDescriptors = 8, space = 0, offset = DescriptorTableOffsetAppend, flags = DescriptorsVolatile
@@ -55,7 +59,9 @@
// CHECK-SAME: numClauses = 3, visibility = All
// CHECK-SAME: ),
// CHECK-SAME: Sampler(
-// CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend, flags = None
+// CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend,
+// CHECK-V1_1-SAME: flags = DescriptorsVolatile
+// CHECK-V1_1-SAME: flags = None
// CHECK-SAME: ),
// CHECK-SAME: DescriptorTable(
// CHECK-SAME: numClauses = 1, visibility = All
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 1e46ee35d5d49..6023b7d519b44 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -29,6 +29,9 @@ using namespace llvm::hlsl::rootsig;
namespace {
+static const llvm::dxbc::RootSignatureVersion DefVersion =
+ llvm::dxbc::RootSignatureVersion::V1_1;
+
// Diagnostic helper for helper tests
class ExpectedDiagConsumer : public DiagnosticConsumer {
virtual void anchor() {}
@@ -115,7 +118,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseEmptyTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -148,7 +151,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -244,7 +247,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -318,7 +321,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -393,7 +396,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -423,7 +426,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -477,7 +480,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -517,7 +520,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -585,7 +588,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -595,6 +598,151 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
ASSERT_TRUE(Consumer->isSatisfied());
}
+TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
+ // This test checks that the default values are set correctly
+ // when parsing with root signature version 1.0
+ const llvm::StringLiteral Source = R"cc(
+ CBV(b0),
+ SRV(t0),
+ UAV(u0),
+ DescriptorTable(
+ CBV(b1),
+ SRV(t1),
+ UAV(u1),
+ Sampler(s1),
+ )
+ )cc";
+
+ TrivialModuleLoader ModLoader;
+ auto PP = createPP(Source, ModLoader);
+ auto TokLoc = SourceLocation();
+
+ hlsl::RootSignatureLexer Lexer(Source, TokLoc);
+ SmallVector<RootElement> Elements;
+ auto Version = llvm::dxbc::RootSignatureVersion::V1_0;
+ hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
+
+ // Test no diagnostics produced
+ Consumer->setNoDiag();
+
+ ASSERT_FALSE(Parser.parse());
+
+ auto DefRootDescriptorFlag = RootDescriptorFlags::DataVolatile;
+ RootElement Elem = Elements[0];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ Elem = Elements[1];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::SRV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ Elem = Elements[2];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ auto ValidNonSamplerFlags = DescriptorRangeFlags::DescriptorsVolatile |
+ DescriptorRangeFlags::DataVolatile;
+ Elem = Elements[3];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::CBuffer);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[4];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::SRV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[5];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::UAV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[6];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::Sampler);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DescriptorsVolatile);
+
+ ASSERT_TRUE(Consumer->isSatisfied());
+}
+
+TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
+ // This test checks that the default values are set correctly
+ // when parsing with root signature version 1.0
+ const llvm::StringLiteral Source = R"cc(
+ CBV(b0),
+ SRV(t0),
+ UAV(u0),
+ DescriptorTable(
+ CBV(b1),
+ SRV(t1),
+ UAV(u1),
+ Sampler(s1),
+ )
+ )cc";
+
+ TrivialModuleLoader ModLoader;
+ auto PP = createPP(Source, ModLoader);
+ auto TokLoc = SourceLocation();
+
+ hlsl::RootSignatureLexer Lexer(Source, TokLoc);
+ SmallVector<RootElement> Elements;
+ auto Version = llvm::dxbc::RootSignatureVersion::V1_1;
+ hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
+
+ // Test no diagnostics produced
+ Consumer->setNoDiag();
+
+ ASSERT_FALSE(Parser.parse());
+
+ RootElement Elem = Elements[0];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[1];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::SRV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[2];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataVolatile);
+
+ Elem = Elements[3];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::CBuffer);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[4];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::SRV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[5];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::UAV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataVolatile);
+
+ Elem = Elements[6];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::Sampler);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::None);
+
+ ASSERT_TRUE(Consumer->isSatisfied());
+}
+
// Invalid Parser Tests
TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
@@ -609,7 +757,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -629,7 +777,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced - invalid token
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -649,7 +797,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced - end of stream
Consumer->setExpected(diag::err_expected_after);
@@ -674,7 +822,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -696,7 +844,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -718,7 +866,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -742,7 +890,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -764,7 +912,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -788,7 +936,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -814,7 +962,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -837,7 +985,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -859,7 +1007,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -880,7 +1028,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -901,7 +1049,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::...
[truncated]
|
@llvm/pr-subscribers-hlsl Author: Finn Plummer (inbelic) ChangesThis pr updates
Patch is 27.55 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/145828.diff 7 Files Affected:
diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h
index afa2c4d8cfe50..b306cb0245b85 100644
--- a/clang/include/clang/Parse/ParseHLSLRootSignature.h
+++ b/clang/include/clang/Parse/ParseHLSLRootSignature.h
@@ -27,7 +27,8 @@ namespace hlsl {
class RootSignatureParser {
public:
- RootSignatureParser(SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
+ RootSignatureParser(llvm::dxbc::RootSignatureVersion Version,
+ SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
RootSignatureLexer &Lexer, clang::Preprocessor &PP);
/// Consumes tokens from the Lexer and constructs the in-memory
@@ -191,6 +192,7 @@ class RootSignatureParser {
bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
private:
+ llvm::dxbc::RootSignatureVersion Version;
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
RootSignatureLexer &Lexer;
diff --git a/clang/lib/Parse/ParseDeclCXX.cpp b/clang/lib/Parse/ParseDeclCXX.cpp
index c1493a5bfd3b3..f5bf9549c7830 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4957,7 +4957,8 @@ void Parser::ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
// Invoke the root signature parser to construct the in-memory constructs
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
- hlsl::RootSignatureParser Parser(RootElements, Lexer, PP);
+ hlsl::RootSignatureParser Parser(getLangOpts().HLSLRootSigVer, RootElements,
+ Lexer, PP);
if (Parser.parse()) {
T.consumeClose();
return;
diff --git a/clang/lib/Parse/ParseHLSLRootSignature.cpp b/clang/lib/Parse/ParseHLSLRootSignature.cpp
index e510302c3aae0..81b6953ea708f 100644
--- a/clang/lib/Parse/ParseHLSLRootSignature.cpp
+++ b/clang/lib/Parse/ParseHLSLRootSignature.cpp
@@ -17,10 +17,12 @@ namespace hlsl {
using TokenKind = RootSignatureToken::Kind;
-RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
- RootSignatureLexer &Lexer,
- Preprocessor &PP)
- : Elements(Elements), Lexer(Lexer), PP(PP), CurToken(SourceLocation()) {}
+RootSignatureParser::RootSignatureParser(
+ llvm::dxbc::RootSignatureVersion Version,
+ SmallVector<RootElement> &Elements, RootSignatureLexer &Lexer,
+ Preprocessor &PP)
+ : Version(Version), Elements(Elements), Lexer(Lexer), PP(PP),
+ CurToken(SourceLocation()) {}
bool RootSignatureParser::parse() {
// Iterate as many RootElements as possible
@@ -198,7 +200,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
ExpectedReg = TokenKind::uReg;
break;
}
- Descriptor.setDefaultFlags();
+ Descriptor.setDefaultFlags(Version);
auto Params = parseRootDescriptorParams(ExpectedReg);
if (!Params.has_value())
@@ -317,7 +319,7 @@ RootSignatureParser::parseDescriptorTableClause() {
ExpectedReg = TokenKind::sReg;
break;
}
- Clause.setDefaultFlags();
+ Clause.setDefaultFlags(Version);
auto Params = parseDescriptorTableClauseParams(ExpectedReg);
if (!Params.has_value())
diff --git a/clang/test/AST/HLSL/RootSignatures-AST.hlsl b/clang/test/AST/HLSL/RootSignatures-AST.hlsl
index 1e60b9367c145..b8767a18ec719 100644
--- a/clang/test/AST/HLSL/RootSignatures-AST.hlsl
+++ b/clang/test/AST/HLSL/RootSignatures-AST.hlsl
@@ -37,13 +37,17 @@
// CHECK-SAME: space = 1, visibility = All, flags = DataStatic
// CHECK-SAME: ),
// CHECK-SAME: RootSRV(t0,
-// CHECK-SAME: space = 0, visibility = All, flags = DataStaticWhileSetAtExecute
+// CHECK-SAME: space = 0, visibility = All,
+// CHECK-V1_0-SAME: flags = DataVolatile
+// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute
// CHECK-SAME: ),
// CHECK-SAME: RootUAV(
// CHECK-SAME: u0, space = 0, visibility = All, flags = DataVolatile
// CHECK-SAME: ),
// CHECK-SAME: CBV(
-// CHECK-SAME: b1, numDescriptors = 1, space = 0, offset = DescriptorTableOffsetAppend, flags = DataStaticWhileSetAtExecute
+// CHECK-SAME: b1, numDescriptors = 1, space = 0, offset = DescriptorTableOffsetAppend,
+// CHECK-V1_0-SAME: flags = DescriptorsVolatile | DataVolatile
+// CHECK-V1_1-SAME: flags = DataStaticWhileSetAtExecute
// CHECK-SAME: ),
// CHECK-SAME: SRV(
// CHECK-SAME: t1, numDescriptors = 8, space = 0, offset = DescriptorTableOffsetAppend, flags = DescriptorsVolatile
@@ -55,7 +59,9 @@
// CHECK-SAME: numClauses = 3, visibility = All
// CHECK-SAME: ),
// CHECK-SAME: Sampler(
-// CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend, flags = None
+// CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend,
+// CHECK-V1_1-SAME: flags = DescriptorsVolatile
+// CHECK-V1_1-SAME: flags = None
// CHECK-SAME: ),
// CHECK-SAME: DescriptorTable(
// CHECK-SAME: numClauses = 1, visibility = All
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 1e46ee35d5d49..6023b7d519b44 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -29,6 +29,9 @@ using namespace llvm::hlsl::rootsig;
namespace {
+static const llvm::dxbc::RootSignatureVersion DefVersion =
+ llvm::dxbc::RootSignatureVersion::V1_1;
+
// Diagnostic helper for helper tests
class ExpectedDiagConsumer : public DiagnosticConsumer {
virtual void anchor() {}
@@ -115,7 +118,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseEmptyTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -148,7 +151,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -244,7 +247,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -318,7 +321,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -393,7 +396,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -423,7 +426,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -477,7 +480,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -517,7 +520,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -585,7 +588,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test no diagnostics produced
Consumer->setNoDiag();
@@ -595,6 +598,151 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) {
ASSERT_TRUE(Consumer->isSatisfied());
}
+TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
+ // This test checks that the default values are set correctly
+ // when parsing with root signature version 1.0
+ const llvm::StringLiteral Source = R"cc(
+ CBV(b0),
+ SRV(t0),
+ UAV(u0),
+ DescriptorTable(
+ CBV(b1),
+ SRV(t1),
+ UAV(u1),
+ Sampler(s1),
+ )
+ )cc";
+
+ TrivialModuleLoader ModLoader;
+ auto PP = createPP(Source, ModLoader);
+ auto TokLoc = SourceLocation();
+
+ hlsl::RootSignatureLexer Lexer(Source, TokLoc);
+ SmallVector<RootElement> Elements;
+ auto Version = llvm::dxbc::RootSignatureVersion::V1_0;
+ hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
+
+ // Test no diagnostics produced
+ Consumer->setNoDiag();
+
+ ASSERT_FALSE(Parser.parse());
+
+ auto DefRootDescriptorFlag = RootDescriptorFlags::DataVolatile;
+ RootElement Elem = Elements[0];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ Elem = Elements[1];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::SRV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ Elem = Elements[2];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
+
+ auto ValidNonSamplerFlags = DescriptorRangeFlags::DescriptorsVolatile |
+ DescriptorRangeFlags::DataVolatile;
+ Elem = Elements[3];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::CBuffer);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[4];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::SRV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[5];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::UAV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags, ValidNonSamplerFlags);
+
+ Elem = Elements[6];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::Sampler);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DescriptorsVolatile);
+
+ ASSERT_TRUE(Consumer->isSatisfied());
+}
+
+TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
+ // This test checks that the default values are set correctly
+ // when parsing with root signature version 1.0
+ const llvm::StringLiteral Source = R"cc(
+ CBV(b0),
+ SRV(t0),
+ UAV(u0),
+ DescriptorTable(
+ CBV(b1),
+ SRV(t1),
+ UAV(u1),
+ Sampler(s1),
+ )
+ )cc";
+
+ TrivialModuleLoader ModLoader;
+ auto PP = createPP(Source, ModLoader);
+ auto TokLoc = SourceLocation();
+
+ hlsl::RootSignatureLexer Lexer(Source, TokLoc);
+ SmallVector<RootElement> Elements;
+ auto Version = llvm::dxbc::RootSignatureVersion::V1_1;
+ hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP);
+
+ // Test no diagnostics produced
+ Consumer->setNoDiag();
+
+ ASSERT_FALSE(Parser.parse());
+
+ RootElement Elem = Elements[0];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::CBuffer);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[1];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::SRV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[2];
+ ASSERT_TRUE(std::holds_alternative<RootDescriptor>(Elem));
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
+ ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags,
+ RootDescriptorFlags::DataVolatile);
+
+ Elem = Elements[3];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::CBuffer);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[4];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::SRV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+
+ Elem = Elements[5];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::UAV);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::DataVolatile);
+
+ Elem = Elements[6];
+ ASSERT_TRUE(std::holds_alternative<DescriptorTableClause>(Elem));
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Type, ClauseType::Sampler);
+ ASSERT_EQ(std::get<DescriptorTableClause>(Elem).Flags,
+ DescriptorRangeFlags::None);
+
+ ASSERT_TRUE(Consumer->isSatisfied());
+}
+
// Invalid Parser Tests
TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
@@ -609,7 +757,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -629,7 +777,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced - invalid token
Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params);
@@ -649,7 +797,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced - end of stream
Consumer->setExpected(diag::err_expected_after);
@@ -674,7 +822,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -696,7 +844,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -718,7 +866,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_missing_param);
@@ -742,7 +890,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -764,7 +912,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -788,7 +936,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -814,7 +962,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param);
@@ -837,7 +985,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -859,7 +1007,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -880,7 +1028,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::RootSignatureParser Parser(Elements, Lexer, *PP);
+ hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP);
// Test correct diagnostic produced
Consumer->setExpected(diag::err_hlsl_number_literal_overflow);
@@ -901,7 +1049,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) {
hlsl::RootSignatureLexer Lexer(Source, TokLoc);
SmallVector<RootElement> Elements;
- hlsl::...
[truncated]
|
|
||
TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) { | ||
// This test checks that the default values are set correctly | ||
// when parsing with root signature version 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// when parsing with root signature version 1.0 | |
// when parsing with root signature version 1.1 |
This pr updates
setDefaultFlags
inHLSLRootSignature.h
to account for which version it should initialize the default flag values for.setDefaultFlags
with aVersion
argument and initializes them to be compliant as described here.RootSignatureParser
to retain theVersion
and pass this intosetDefaultFlags
setDefaultFlags
in test-casesResolves #145820.