aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Frontend
diff options
context:
space:
mode:
authorFinn Plummer <finn.c.plum@gmail.com>2025-07-04 09:48:24 -0700
committerGitHub <noreply@github.com>2025-07-04 09:48:24 -0700
commit6a948145aa7a55af31e7406842a4f45a86b74eaf (patch)
treeb0f43ac3d753b64a97d197909f0b45a0ca21a4bf /llvm/unittests/Frontend
parentb0473c599b0418c71d15150e0ea19d57df3b98e5 (diff)
downloadllvm-6a948145aa7a55af31e7406842a4f45a86b74eaf.zip
llvm-6a948145aa7a55af31e7406842a4f45a86b74eaf.tar.gz
llvm-6a948145aa7a55af31e7406842a4f45a86b74eaf.tar.bz2
[HLSL][RootSignature] Update `setDefaultFlags` to account for Root Signature Version (#145828)
This pr updates `setDefaultFlags` in `HLSLRootSignature.h` to account for which version it should initialize the default flag values for. - Updates `setDefaultFlags` with a `Version` argument and initializes them to be compliant as described [here](https://github.com/llvm/wg-hlsl/pull/297). - Updates `RootSignatureParser` to retain the `Version` and pass this into `setDefaultFlags` - Updates all uses of `setDefaultFlags` in test-cases - Adds some new unit testing to ensure behaviour is as expected and that the Parser correctly passes down the version Resolves https://github.com/llvm/llvm-project/issues/145820.
Diffstat (limited to 'llvm/unittests/Frontend')
-rw-r--r--llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp72
1 files changed, 70 insertions, 2 deletions
diff --git a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
index 2a32635..98b33fd 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;