aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Frontend
diff options
context:
space:
mode:
authorFinn Plummer <finn.c.plum@gmail.com>2025-07-03 14:44:11 -0700
committerGitHub <noreply@github.com>2025-07-03 14:44:11 -0700
commit0ceb0c377a3e67b70965c32e7f21fe8b33f555d2 (patch)
treefedc68679b97a30318da10e7b01ff3f9f7d709c5 /llvm/unittests/Frontend
parent1725cc025e8faa8dc0fd8799bc277e2c0f0f8c1c (diff)
downloadllvm-0ceb0c377a3e67b70965c32e7f21fe8b33f555d2.zip
llvm-0ceb0c377a3e67b70965c32e7f21fe8b33f555d2.tar.gz
llvm-0ceb0c377a3e67b70965c32e7f21fe8b33f555d2.tar.bz2
[NFC][HLSL][DirectX] Let `HLSLRootSignature` reuse the `dxbc` defined enums (#145986)
This pr removes the redundancy of having the same enums defined in both the front-end and back-end of handling root signatures. Since there are many more uses of the enum in the front-end of the code, we will adhere to the naming conventions used in the front-end, to minimize the diff. The macros in `DXContainerConstants.def` are also touched-up to be consistent and to have each macro name follow its respective definition in d3d12.h and searchable by name [here](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/). Additionally, the many `getEnumNames` are moved to `DXContainer` from `HLSLRootSignatureUtils` as they we will want them to be exposed publicly anyways. Changes for each enum follow the pattern of a commit that will make the enum definition in `DXContainer` adhere to above listed naming conventions, followed by a commit to actually use that enum in the front-end. Resolves https://github.com/llvm/llvm-project/issues/145815
Diffstat (limited to 'llvm/unittests/Frontend')
-rw-r--r--llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp62
1 files changed, 43 insertions, 19 deletions
diff --git a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
index dde82ac..ca2c296 100644
--- a/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
+++ b/llvm/unittests/Frontend/HLSLRootSignatureDumpTest.cpp
@@ -37,7 +37,7 @@ TEST(HLSLRootSignatureTest, DescriptorSRVClauseDump) {
Clause.NumDescriptors = NumDescriptorsUnbounded;
Clause.Space = 42;
Clause.Offset = 3;
- Clause.Flags = DescriptorRangeFlags::None;
+ Clause.Flags = llvm::dxbc::DescriptorRangeFlags::None;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -50,13 +50,20 @@ TEST(HLSLRootSignatureTest, DescriptorSRVClauseDump) {
}
TEST(HLSLRootSignatureTest, DescriptorUAVClauseDump) {
+ using llvm::dxbc::DescriptorRangeFlags;
DescriptorTableClause Clause;
Clause.Type = ClauseType::UAV;
Clause.Reg = {RegisterType::UReg, 92374};
Clause.NumDescriptors = 3298;
Clause.Space = 932847;
Clause.Offset = 1;
- Clause.Flags = DescriptorRangeFlags::ValidFlags;
+ auto ValidDescriptorRangeFlags =
+ DescriptorRangeFlags::DescriptorsVolatile |
+ DescriptorRangeFlags::DataVolatile |
+ DescriptorRangeFlags::DataStaticWhileSetAtExecute |
+ DescriptorRangeFlags::DataStatic |
+ DescriptorRangeFlags::DescriptorsStaticKeepingBufferBoundsChecks;
+ Clause.Flags = ValidDescriptorRangeFlags;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -80,7 +87,7 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) {
Clause.NumDescriptors = 2;
Clause.Space = 42;
Clause.Offset = DescriptorTableOffsetAppend;
- Clause.Flags = DescriptorRangeFlags::ValidSamplerFlags;
+ Clause.Flags = llvm::dxbc::DescriptorRangeFlags::DescriptorsVolatile;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -96,7 +103,7 @@ TEST(HLSLRootSignatureTest, DescriptorSamplerClauseDump) {
TEST(HLSLRootSignatureTest, DescriptorTableDump) {
DescriptorTable Table;
Table.NumClauses = 4;
- Table.Visibility = ShaderVisibility::Geometry;
+ Table.Visibility = llvm::dxbc::ShaderVisibility::Geometry;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -130,8 +137,8 @@ TEST(HLSLRootSignatureTest, RootSRVDump) {
Descriptor.Type = DescriptorType::SRV;
Descriptor.Reg = {RegisterType::TReg, 0};
Descriptor.Space = 42;
- Descriptor.Visibility = ShaderVisibility::Geometry;
- Descriptor.Flags = RootDescriptorFlags::None;
+ Descriptor.Visibility = llvm::dxbc::ShaderVisibility::Geometry;
+ Descriptor.Flags = llvm::dxbc::RootDescriptorFlags::None;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -144,12 +151,17 @@ TEST(HLSLRootSignatureTest, RootSRVDump) {
}
TEST(HLSLRootSignatureTest, RootUAVDump) {
+ using llvm::dxbc::RootDescriptorFlags;
RootDescriptor Descriptor;
Descriptor.Type = DescriptorType::UAV;
Descriptor.Reg = {RegisterType::UReg, 92374};
Descriptor.Space = 932847;
- Descriptor.Visibility = ShaderVisibility::Hull;
- Descriptor.Flags = RootDescriptorFlags::ValidFlags;
+ Descriptor.Visibility = llvm::dxbc::ShaderVisibility::Hull;
+ auto ValidRootDescriptorFlags =
+ RootDescriptorFlags::DataVolatile |
+ RootDescriptorFlags::DataStaticWhileSetAtExecute |
+ RootDescriptorFlags::DataStatic;
+ Descriptor.Flags = ValidRootDescriptorFlags;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -194,18 +206,18 @@ TEST(HLSLRootSignatureTest, DefinedStaticSamplerDump) {
StaticSampler Sampler;
Sampler.Reg = {RegisterType::SReg, 0};
- Sampler.Filter = SamplerFilter::ComparisonMinMagLinearMipPoint;
- Sampler.AddressU = TextureAddressMode::Mirror;
- Sampler.AddressV = TextureAddressMode::Border;
- Sampler.AddressW = TextureAddressMode::Clamp;
+ Sampler.Filter = llvm::dxbc::SamplerFilter::ComparisonMinMagLinearMipPoint;
+ Sampler.AddressU = llvm::dxbc::TextureAddressMode::Mirror;
+ Sampler.AddressV = llvm::dxbc::TextureAddressMode::Border;
+ Sampler.AddressW = llvm::dxbc::TextureAddressMode::Clamp;
Sampler.MipLODBias = 4.8f;
Sampler.MaxAnisotropy = 32;
- Sampler.CompFunc = ComparisonFunc::NotEqual;
- Sampler.BorderColor = StaticBorderColor::OpaqueBlack;
+ Sampler.CompFunc = llvm::dxbc::ComparisonFunc::NotEqual;
+ Sampler.BorderColor = llvm::dxbc::StaticBorderColor::OpaqueBlack;
Sampler.MinLOD = 1.0f;
Sampler.MaxLOD = 32.0f;
Sampler.Space = 7;
- Sampler.Visibility = ShaderVisibility::Domain;
+ Sampler.Visibility = llvm::dxbc::ShaderVisibility::Domain;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -249,7 +261,7 @@ TEST(HLSLRootSignatureTest, SetRootConstantsDump) {
Constants.Num32BitConstants = 983;
Constants.Reg = {RegisterType::BReg, 34593};
Constants.Space = 7;
- Constants.Visibility = ShaderVisibility::Pixel;
+ Constants.Visibility = llvm::dxbc::ShaderVisibility::Pixel;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -262,7 +274,7 @@ TEST(HLSLRootSignatureTest, SetRootConstantsDump) {
}
TEST(HLSLRootSignatureTest, NoneRootFlagsDump) {
- RootFlags Flags = RootFlags::None;
+ llvm::dxbc::RootFlags Flags = llvm::dxbc::RootFlags::None;
std::string Out;
llvm::raw_string_ostream OS(Out);
@@ -274,11 +286,23 @@ TEST(HLSLRootSignatureTest, NoneRootFlagsDump) {
}
TEST(HLSLRootSignatureTest, AllRootFlagsDump) {
- RootFlags Flags = RootFlags::ValidFlags;
+ using llvm::dxbc::RootFlags;
+ auto ValidRootFlags = RootFlags::AllowInputAssemblerInputLayout |
+ RootFlags::DenyVertexShaderRootAccess |
+ RootFlags::DenyHullShaderRootAccess |
+ RootFlags::DenyDomainShaderRootAccess |
+ RootFlags::DenyGeometryShaderRootAccess |
+ RootFlags::DenyPixelShaderRootAccess |
+ RootFlags::AllowStreamOutput |
+ RootFlags::LocalRootSignature |
+ RootFlags::DenyAmplificationShaderRootAccess |
+ RootFlags::DenyMeshShaderRootAccess |
+ RootFlags::CBVSRVUAVHeapDirectlyIndexed |
+ RootFlags::SamplerHeapDirectlyIndexed;
std::string Out;
llvm::raw_string_ostream OS(Out);
- OS << Flags;
+ OS << ValidRootFlags;
OS.flush();
std::string Expected = "RootFlags("