[llvm-branch-commits] [clang] [llvm] [HLSL][RootSignature] Update `setDefaultFlags` to account for Root Signature Version (PR #145828)
Finn Plummer via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Thu Jul 3 14:33:19 PDT 2025
https://github.com/inbelic updated https://github.com/llvm/llvm-project/pull/145828
>From 471a4a556ad0653792e39c99da2423d5e3ed933f Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:39:13 +0000
Subject: [PATCH 01/10] update `setDefaultFlags`
---
.../llvm/Frontend/HLSL/HLSLRootSignature.h | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h b/llvm/include/llvm/Frontend/HLSL/HLSLRootSignature.h
index f552040ab31cc..0579c1b5f9c25 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:
>From af70ea275d057f15b80223c11eb11174764da0ff Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:39:43 +0000
Subject: [PATCH 02/10] update unit testing
---
.../Frontend/HLSLRootSignatureDumpTest.cpp | 72 ++++++++++++++++++-
1 file changed, 70 insertions(+), 2 deletions(-)
diff --git a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
index e090f6bae470f..76ac285735d05 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);
@@ -93,6 +93,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;
@@ -112,7 +146,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);
@@ -125,6 +159,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 9befc49f08f715c46d36b21733c7dff9babde6ec Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:40:05 +0000
Subject: [PATCH 03/10] update parser to invoke with version
---
clang/include/clang/Parse/ParseHLSLRootSignature.h | 4 +++-
clang/lib/Parse/ParseDeclCXX.cpp | 3 ++-
clang/lib/Parse/ParseHLSLRootSignature.cpp | 14 ++++++++------
3 files changed, 13 insertions(+), 8 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 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 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())
>From 53f54bf67be500c434ae50326f1e52dccbff754a Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:40:12 +0000
Subject: [PATCH 04/10] update parser tests
---
.../Parse/ParseHLSLRootSignatureTest.cpp | 200 +++++++++++++++---
1 file changed, 174 insertions(+), 26 deletions(-)
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index ba42895afce6c..492b25832c687 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();
@@ -246,7 +249,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();
@@ -331,7 +334,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();
@@ -406,7 +409,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();
@@ -436,7 +439,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();
@@ -492,7 +495,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();
@@ -533,7 +536,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();
@@ -605,7 +608,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();
@@ -615,6 +618,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) {
@@ -629,7 +777,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);
@@ -649,7 +797,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);
@@ -669,7 +817,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);
@@ -694,7 +842,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);
@@ -716,7 +864,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);
@@ -738,7 +886,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);
@@ -762,7 +910,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);
@@ -784,7 +932,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);
@@ -808,7 +956,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);
@@ -834,7 +982,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);
@@ -857,7 +1005,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);
@@ -879,7 +1027,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);
@@ -900,7 +1048,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);
@@ -921,7 +1069,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);
@@ -942,7 +1090,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);
@@ -963,7 +1111,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);
@@ -987,7 +1135,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);
>From 6d99014992e199daa50604675b36e461f07d4493 Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:40:22 +0000
Subject: [PATCH 05/10] fix testcase with updated defaults
---
clang/test/AST/HLSL/RootSignatures-AST.hlsl | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
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
>From a8c6a63c997c85d86fc12a8fe23a4f5818b897c1 Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:45:42 +0000
Subject: [PATCH 06/10] rebase corrections
---
.../Parse/ParseHLSLRootSignatureTest.cpp | 23 ++++++++++---------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
index 492b25832c687..a6123d6e43426 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -647,7 +647,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
ASSERT_FALSE(Parser.parse());
- auto DefRootDescriptorFlag = RootDescriptorFlags::DataVolatile;
+ 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);
@@ -663,8 +663,9 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
ASSERT_EQ(std::get<RootDescriptor>(Elem).Type, DescriptorType::UAV);
ASSERT_EQ(std::get<RootDescriptor>(Elem).Flags, DefRootDescriptorFlag);
- auto ValidNonSamplerFlags = DescriptorRangeFlags::DescriptorsVolatile |
- DescriptorRangeFlags::DataVolatile;
+ 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);
@@ -684,7 +685,7 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion10Test) {
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);
+ llvm::dxbc::DescriptorRangeFlags::DescriptorsVolatile);
ASSERT_TRUE(Consumer->isSatisfied());
}
@@ -722,43 +723,43 @@ TEST_F(ParseHLSLRootSignatureTest, ValidVersion11Test) {
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);
+ 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,
- RootDescriptorFlags::DataStaticWhileSetAtExecute);
+ 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,
- RootDescriptorFlags::DataVolatile);
+ 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,
- DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+ 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,
- DescriptorRangeFlags::DataStaticWhileSetAtExecute);
+ 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,
- DescriptorRangeFlags::DataVolatile);
+ 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,
- DescriptorRangeFlags::None);
+ llvm::dxbc::DescriptorRangeFlags::None);
ASSERT_TRUE(Consumer->isSatisfied());
}
>From f417057109dc973fb5a1861891287dfc7b413c71 Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Fri, 27 Jun 2025 16:50:19 +0000
Subject: [PATCH 07/10] 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 a6123d6e43426..861089c4790b0 100644
--- a/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
+++ b/clang/unittests/Parse/ParseHLSLRootSignatureTest.cpp
@@ -692,7 +692,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 9a0a9a2686f62c2a2ed6baa611f2f5960f5980f7 Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Thu, 3 Jul 2025 21:05:44 +0000
Subject: [PATCH 08/10] 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 861089c4790b0..19c89e2239a22 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();
@@ -151,7 +151,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();
@@ -249,7 +250,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();
@@ -334,7 +336,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();
@@ -409,7 +412,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();
@@ -439,7 +443,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();
@@ -495,7 +500,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();
@@ -536,7 +542,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();
@@ -608,7 +615,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();
@@ -639,8 +647,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();
@@ -711,8 +719,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();
@@ -778,7 +786,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);
@@ -798,7 +807,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);
@@ -818,7 +828,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);
@@ -843,7 +854,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);
@@ -865,7 +877,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);
@@ -887,7 +900,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);
@@ -911,7 +925,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);
@@ -933,7 +948,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);
@@ -957,7 +973,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);
@@ -983,7 +1000,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);
@@ -1006,7 +1024,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);
@@ -1028,7 +1047,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);
@@ -1049,7 +1069,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);
@@ -1070,7 +1091,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);
@@ -1091,7 +1113,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);
@@ -1112,7 +1135,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);
@@ -1136,7 +1160,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 82b649b2f1e8f09c8581c61bb72935dd62073efb Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Thu, 3 Jul 2025 21:32:44 +0000
Subject: [PATCH 09/10] 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 ca0d6cfa945d5921e824147805e82f430594a51d Mon Sep 17 00:00:00 2001
From: Finn Plummer <canadienfinn at gmail.com>
Date: Thu, 3 Jul 2025 21:33:00 +0000
Subject: [PATCH 10/10] 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(
More information about the llvm-branch-commits
mailing list