https://github.com/inbelic updated https://github.com/llvm/llvm-project/pull/145828
>From e616ddee9cfaaaf6ffff97e4bd83d18e2d10ea86 Mon Sep 17 00:00:00 2001 From: Finn Plummer <canadienf...@gmail.com> Date: Fri, 27 Jun 2025 16:39:13 +0000 Subject: [PATCH 1/5] update `setDefaultFlags` --- .../clang/Parse/ParseHLSLRootSignature.h | 4 +- clang/lib/Parse/ParseDeclCXX.cpp | 3 +- clang/lib/Parse/ParseHLSLRootSignature.cpp | 14 +- clang/test/AST/HLSL/RootSignatures-AST.hlsl | 12 +- .../Parse/ParseHLSLRootSignatureTest.cpp | 201 +++++++++++++++--- .../llvm/Frontend/HLSL/HLSLRootSignature.h | 20 +- .../Frontend/HLSLRootSignatureDumpTest.cpp | 72 ++++++- 7 files changed, 285 insertions(+), 41 deletions(-) diff --git a/clang/include/clang/Parse/ParseHLSLRootSignature.h b/clang/include/clang/Parse/ParseHLSLRootSignature.h index 18cd1f379e62c..66a5a3b7eaad0 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 @@ -187,6 +188,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 bd5c28b1992c4..6b0564dca6f45 100644 --- a/clang/lib/Parse/ParseDeclCXX.cpp +++ b/clang/lib/Parse/ParseDeclCXX.cpp @@ -4956,7 +4956,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 18d3644114eef..96d3999ff2acb 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 @@ -199,7 +201,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() { ExpectedReg = TokenKind::uReg; break; } - Descriptor.setDefaultFlags(); + Descriptor.setDefaultFlags(Version); auto Params = parseRootDescriptorParams(ExpectedReg); if (!Params.has_value()) @@ -318,7 +320,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 8831198e4b9c2..45ae5e2d5b19c 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(); @@ -149,7 +152,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(); @@ -252,7 +255,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(); @@ -337,7 +340,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(); @@ -412,7 +415,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(); @@ -443,7 +446,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(); @@ -500,7 +503,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(); @@ -553,7 +556,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(); @@ -627,7 +630,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(); @@ -637,6 +640,152 @@ 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 = llvm::dxbc::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 = + llvm::dxbc::DescriptorRangeFlags::DescriptorsVolatile | + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::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, + llvm::dxbc::DescriptorRangeFlags::None); + + ASSERT_TRUE(Consumer->isSatisfied()); +} + // Invalid Parser Tests TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) { @@ -651,7 +800,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); @@ -671,7 +820,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); @@ -691,7 +840,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); @@ -716,7 +865,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); @@ -738,7 +887,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); @@ -760,7 +909,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); @@ -784,7 +933,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); @@ -806,7 +955,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); @@ -830,7 +979,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); @@ -856,7 +1005,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); @@ -879,7 +1028,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); @@ -901,7 +1050,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); @@ -922,7 +1071,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); @@ -943,7 +1092,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) { 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); @@ -964,7 +1113,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) { 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); @@ -985,7 +1134,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) { 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_underflow); @@ -1009,7 +1158,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) { 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_non_zero_flag); diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h index 3e959829a20bf..5db8f88f40e25 100644 --- a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h +++ b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h @@ -50,7 +50,14 @@ struct RootDescriptor { dxbc::ShaderVisibility Visibility = dxbc::ShaderVisibility::All; dxbc::RootDescriptorFlags Flags; - void setDefaultFlags() { + void setDefaultFlags(dxbc::RootSignatureVersion Version) { + if (Version == dxbc::RootSignatureVersion::V1_0) { + Flags = dxbc::RootDescriptorFlags::DataVolatile; + return; + } + + assert(Version == llvm::dxbc::RootSignatureVersion::V1_1 && + "Specified an invalid root signature version"); switch (Type) { case DescriptorType::CBuffer: case DescriptorType::SRV: @@ -83,7 +90,16 @@ struct DescriptorTableClause { uint32_t Offset = DescriptorTableOffsetAppend; dxbc::DescriptorRangeFlags Flags; - void setDefaultFlags() { + void setDefaultFlags(dxbc::RootSignatureVersion Version) { + if (Version == dxbc::RootSignatureVersion::V1_0) { + Flags = dxbc::DescriptorRangeFlags::DescriptorsVolatile; + if (Type != ClauseType::Sampler) + Flags |= dxbc::DescriptorRangeFlags::DataVolatile; + return; + } + + assert(Version == dxbc::RootSignatureVersion::V1_1 && + "Specified an invalid root signature version"); switch (Type) { case ClauseType::CBuffer: case ClauseType::SRV: diff --git a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp index ca2c296efc99b..4cf46988fc309 100644 --- a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp +++ b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp @@ -17,7 +17,7 @@ TEST(HLSLRootSignatureTest, DescriptorCBVClauseDump) { DescriptorTableClause Clause; Clause.Type = ClauseType::CBuffer; Clause.Reg = {RegisterType::BReg, 0}; - Clause.setDefaultFlags(); + Clause.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_1); std::string Out; llvm::raw_string_ostream OS(Out); @@ -100,6 +100,40 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) { EXPECT_EQ(Out, Expected); } +TEST(HLSLRootSignatureTest, DescriptorCBVV10ClauseDump) { + DescriptorTableClause Clause; + Clause.Type = ClauseType::CBuffer; + Clause.Reg = {RegisterType::BReg, 0}; + Clause.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0); + + std::string Out; + llvm::raw_string_ostream OS(Out); + OS << Clause; + OS.flush(); + + std::string Expected = "CBV(b0, numDescriptors = 1, space = 0, " + "offset = DescriptorTableOffsetAppend, " + "flags = DescriptorsVolatile | DataVolatile)"; + EXPECT_EQ(Out, Expected); +} + +TEST(HLSLRootSignatureTest, DescriptorSamplerV10ClauseDump) { + DescriptorTableClause Clause; + Clause.Type = ClauseType::Sampler; + Clause.Reg = {RegisterType::SReg, 0}; + Clause.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0); + + std::string Out; + llvm::raw_string_ostream OS(Out); + OS << Clause; + OS.flush(); + + std::string Expected = "Sampler(s0, numDescriptors = 1, space = 0, offset = " + "DescriptorTableOffsetAppend, " + "flags = DescriptorsVolatile)"; + EXPECT_EQ(Out, Expected); +} + TEST(HLSLRootSignatureTest, DescriptorTableDump) { DescriptorTable Table; Table.NumClauses = 4; @@ -119,7 +153,7 @@ TEST(HLSLRootSignatureTest, RootCBVDump) { RootDescriptor Descriptor; Descriptor.Type = DescriptorType::CBuffer; Descriptor.Reg = {RegisterType::BReg, 0}; - Descriptor.setDefaultFlags(); + Descriptor.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_1); std::string Out; llvm::raw_string_ostream OS(Out); @@ -132,6 +166,40 @@ TEST(HLSLRootSignatureTest, RootCBVDump) { EXPECT_EQ(Out, Expected); } +TEST(HLSLRootSignatureTest, RootSRV10Dump) { + RootDescriptor Descriptor; + Descriptor.Type = DescriptorType::SRV; + Descriptor.Reg = {RegisterType::TReg, 0}; + Descriptor.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0); + + std::string Out; + llvm::raw_string_ostream OS(Out); + OS << Descriptor; + OS.flush(); + + std::string Expected = "RootSRV(t0, space = 0, " + "visibility = All, " + "flags = DataVolatile)"; + EXPECT_EQ(Out, Expected); +} + +TEST(HLSLRootSignatureTest, RootUAVV10Dump) { + RootDescriptor Descriptor; + Descriptor.Type = DescriptorType::UAV; + Descriptor.Reg = {RegisterType::UReg, 0}; + Descriptor.setDefaultFlags(llvm::dxbc::RootSignatureVersion::V1_0); + + std::string Out; + llvm::raw_string_ostream OS(Out); + OS << Descriptor; + OS.flush(); + + std::string Expected = "RootUAV(u0, space = 0, " + "visibility = All, " + "flags = DataVolatile)"; + EXPECT_EQ(Out, Expected); +} + TEST(HLSLRootSignatureTest, RootSRVDump) { RootDescriptor Descriptor; Descriptor.Type = DescriptorType::SRV; >From 4c45a13647a27c523ce540016e431bb629d41a60 Mon Sep 17 00:00:00 2001 From: Finn Plummer <canadienf...@gmail.com> Date: Fri, 27 Jun 2025 16:50:19 +0000 Subject: [PATCH 2/5] self review: fix typo --- clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp index 45ae5e2d5b19c..d60c26e26cc33 100644 --- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp +++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp @@ -714,7 +714,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) { TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) { // This test checks that the default values are set correctly - // when parsing with root signature version 1.0 + // when parsing with root signature version 1.1 const llvm::StringLiteral Source = R"cc( CBV(b0), SRV(t0), >From dde1e97a55fd5ca5637accb9fc01f7a5e4d6676c Mon Sep 17 00:00:00 2001 From: Finn Plummer <canadienf...@gmail.com> Date: Thu, 3 Jul 2025 21:05:44 +0000 Subject: [PATCH 3/5] review: make version more concise --- .../Parse/ParseHLSLRootSignatureTest.cpp | 89 ++++++++++++------- 1 file changed, 57 insertions(+), 32 deletions(-) diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp index d60c26e26cc33..871f12ef3cce3 100644 --- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp +++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp @@ -29,8 +29,7 @@ using namespace llvm::hlsl::rootsig; namespace { -static const llvm::dxbc::RootSignatureVersion DefVersion = - llvm::dxbc::RootSignatureVersion::V1_1; +using llvm::dxbc::RootSignatureVersion; // Diagnostic helper for helper tests class ExpectedDiagConsumer : public DiagnosticConsumer { @@ -118,7 +117,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseEmptyTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -152,7 +152,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseDTClausesTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -255,7 +256,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseStaticSamplerTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -340,7 +342,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseFloatsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -415,7 +418,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -446,7 +450,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -503,7 +508,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootFlagsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -556,7 +562,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootDescriptorsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -630,7 +637,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidTrailingCommaTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -661,8 +669,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - auto Version = llvm::dxbc::RootSignatureVersion::V1_0; - hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_0, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -733,8 +741,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - auto Version = llvm::dxbc::RootSignatureVersion::V1_1; - hlsl::RootSignatureParser Parser(Version, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test no diagnostics produced Consumer->setNoDiag(); @@ -800,7 +808,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedTokenTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params); @@ -820,7 +829,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseInvalidTokenTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced - invalid token Consumer->setExpected(diag::err_hlsl_unexpected_end_of_params); @@ -840,7 +850,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced - end of stream Consumer->setExpected(diag::err_expected_after); @@ -865,7 +876,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_missing_param); @@ -887,7 +899,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRDParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_missing_param); @@ -909,7 +922,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_missing_param); @@ -933,7 +947,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param); @@ -955,7 +970,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param); @@ -979,7 +995,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param); @@ -1005,7 +1022,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_repeat_param); @@ -1028,7 +1046,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_overflow); @@ -1050,7 +1069,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseOverflowedNegativeNumberTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_overflow); @@ -1071,7 +1091,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedFloatTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_overflow); @@ -1092,7 +1113,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexNegOverflowedFloatTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_overflow); @@ -1113,7 +1135,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexOverflowedDoubleTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_overflow); @@ -1134,7 +1157,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidLexUnderflowFloatTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_number_literal_underflow); @@ -1158,7 +1182,8 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidNonZeroFlagsTest) { hlsl::RootSignatureLexer Lexer(Source, TokLoc); SmallVector<RootElement> Elements; - hlsl::RootSignatureParser Parser(DefVersion, Elements, Lexer, *PP); + hlsl::RootSignatureParser Parser(RootSignatureVersion::V1_1, Elements, Lexer, + *PP); // Test correct diagnostic produced Consumer->setExpected(diag::err_hlsl_rootsig_non_zero_flag); >From 908533d2ca0717734918477048a5e02a28254813 Mon Sep 17 00:00:00 2001 From: Finn Plummer <canadienf...@gmail.com> Date: Thu, 3 Jul 2025 21:32:44 +0000 Subject: [PATCH 4/5] review: fix check-prefixes to ensure errored test fails --- clang/test/AST/HLSL/RootSignatures-AST.hlsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/test/AST/HLSL/RootSignatures-AST.hlsl b/clang/test/AST/HLSL/RootSignatures-AST.hlsl index b8767a18ec719..f4fcba94d3b98 100644 --- a/clang/test/AST/HLSL/RootSignatures-AST.hlsl +++ b/clang/test/AST/HLSL/RootSignatures-AST.hlsl @@ -1,11 +1,11 @@ // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ -// RUN: -disable-llvm-passes -o - %s | FileCheck %s +// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_1 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ // RUN: -fdx-rootsignature-version=rootsig_1_0 \ -// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-V1_0 +// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_0 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -ast-dump \ // RUN: -fdx-rootsignature-version=rootsig_1_1 \ -// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefix=CHECK-V1_1 +// RUN: -disable-llvm-passes -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-V1_1 // This test ensures that the sample root signature is parsed without error and // the Attr AST Node is created succesfully. If an invalid root signature was >From 2ae17f31f8c3f1dac5ca5e7360dfcf4ff42fa8d8 Mon Sep 17 00:00:00 2001 From: Finn Plummer <canadienf...@gmail.com> Date: Thu, 3 Jul 2025 21:33:00 +0000 Subject: [PATCH 5/5] review: fix typo --- clang/test/AST/HLSL/RootSignatures-AST.hlsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/AST/HLSL/RootSignatures-AST.hlsl b/clang/test/AST/HLSL/RootSignatures-AST.hlsl index f4fcba94d3b98..69ed5aeca1335 100644 --- a/clang/test/AST/HLSL/RootSignatures-AST.hlsl +++ b/clang/test/AST/HLSL/RootSignatures-AST.hlsl @@ -60,7 +60,7 @@ // CHECK-SAME: ), // CHECK-SAME: Sampler( // CHECK-SAME: s0, numDescriptors = 4, space = 1, offset = DescriptorTableOffsetAppend, -// CHECK-V1_1-SAME: flags = DescriptorsVolatile +// CHECK-V1_0-SAME: flags = DescriptorsVolatile // CHECK-V1_1-SAME: flags = None // CHECK-SAME: ), // CHECK-SAME: DescriptorTable( _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits