[clang] [llvm] [DirectX][NFC] Refactoring DirectX backend to not use `llvm::to_underlying` in switch cases. (PR #151032)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 12:48:49 PDT 2025
https://github.com/joaosaffran updated https://github.com/llvm/llvm-project/pull/151032
>From ea35c412bbfbefb50078bdd21b44156e1e1efe48 Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Mon, 28 Jul 2025 13:02:34 -0700
Subject: [PATCH 1/9] remove the to_undernlying switch
---
.../Frontend/HLSL/RootSignatureMetadata.cpp | 13 ++++---
.../HLSL/RootSignatureValidations.cpp | 7 ++--
llvm/lib/MC/DXContainerRootSignature.cpp | 36 ++++++++++++-------
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 28 +++++++++------
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 18 ++++++----
llvm/lib/Target/DirectX/DXILRootSignature.cpp | 14 ++++----
6 files changed, 72 insertions(+), 44 deletions(-)
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index 53f59349ae029..ed1e49c10818d 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -559,11 +559,14 @@ bool MetadataParser::validateRootSignature(
assert(dxbc::isValidParameterType(Info.Header.ParameterType) &&
"Invalid value for ParameterType");
- switch (Info.Header.ParameterType) {
+ dxbc::RootParameterType PT =
+ static_cast<dxbc::RootParameterType>(Info.Header.ParameterType);
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV): {
+ switch (PT) {
+
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::UAV:
+ case dxbc::RootParameterType::SRV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
RSD.ParametersContainer.getRootDescriptor(Info.Location);
if (!llvm::hlsl::rootsig::verifyRegisterValue(Descriptor.ShaderRegister))
@@ -580,7 +583,7 @@ bool MetadataParser::validateRootSignature(
}
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
+ case dxbc::RootParameterType::DescriptorTable: {
const mcdxbc::DescriptorTable &Table =
RSD.ParametersContainer.getDescriptorTable(Info.Location);
for (const dxbc::RTS0::v2::DescriptorRange &Range : Table) {
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
index f11c7d2033bfb..e55d3ec15c19d 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
@@ -53,10 +53,9 @@ bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {
bool verifyRangeType(uint32_t Type) {
switch (Type) {
- case llvm::to_underlying(dxbc::DescriptorRangeType::CBV):
- case llvm::to_underlying(dxbc::DescriptorRangeType::SRV):
- case llvm::to_underlying(dxbc::DescriptorRangeType::UAV):
- case llvm::to_underlying(dxbc::DescriptorRangeType::Sampler):
+#define DESCRIPTOR_RANGE(Num, Val) \
+ case llvm::to_underlying(dxbc::DescriptorRangeType::Val):
+#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
};
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index 482280b5ef289..454a0b88178f5 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -8,6 +8,7 @@
#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Support/EndianStream.h"
using namespace llvm;
@@ -35,20 +36,27 @@ size_t RootSignatureDesc::getSize() const {
StaticSamplers.size() * sizeof(dxbc::RTS0::v1::StaticSampler);
for (const RootParameterInfo &I : ParametersContainer) {
- switch (I.Header.ParameterType) {
- case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
+ // Invalid parameters are allowed while writing.
+ if (!dxbc::isValidParameterType(I.Header.ParameterType))
+ continue;
+
+ dxbc::RootParameterType PT =
+ static_cast<dxbc::RootParameterType>(I.Header.ParameterType);
+
+ switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit:
Size += sizeof(dxbc::RTS0::v1::RootConstants);
break;
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV):
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::SRV:
+ case dxbc::RootParameterType::UAV:
if (Version == 1)
Size += sizeof(dxbc::RTS0::v1::RootDescriptor);
else
Size += sizeof(dxbc::RTS0::v2::RootDescriptor);
break;
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
+ case dxbc::RootParameterType::DescriptorTable:
const DescriptorTable &Table =
ParametersContainer.getDescriptorTable(I.Location);
@@ -97,8 +105,12 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
for (size_t I = 0; I < NumParameters; ++I) {
rewriteOffsetToCurrentByte(BOS, ParamsOffsets[I]);
const auto &[Type, Loc] = ParametersContainer.getTypeAndLocForParameter(I);
- switch (Type) {
- case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): {
+ if (!dxbc::isValidParameterType(Type))
+ continue;
+ dxbc::RootParameterType PT = static_cast<dxbc::RootParameterType>(Type);
+
+ switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit: {
const dxbc::RTS0::v1::RootConstants &Constants =
ParametersContainer.getConstant(Loc);
support::endian::write(BOS, Constants.ShaderRegister,
@@ -109,9 +121,9 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
llvm::endianness::little);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV): {
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::SRV:
+ case dxbc::RootParameterType::UAV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
ParametersContainer.getRootDescriptor(Loc);
@@ -123,7 +135,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
support::endian::write(BOS, Descriptor.Flags, llvm::endianness::little);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
+ case dxbc::RootParameterType::DescriptorTable: {
const DescriptorTable &Table =
ParametersContainer.getDescriptorTable(Loc);
support::endian::write(BOS, (uint32_t)Table.Ranges.size(),
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 043b575a43b11..35e1c3e3b5953 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -278,8 +278,19 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
dxbc::RTS0::v1::RootParameterHeader Header{L.Header.Type, L.Header.Visibility,
L.Header.Offset};
- switch (L.Header.Type) {
- case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): {
+ if (!dxbc::isValidParameterType(L.Header.Type)) {
+ // Handling invalid parameter type edge case. We intentionally let
+ // obj2yaml/yaml2obj parse and emit invalid dxcontainer data, in order
+ // for that to be used as a testing tool more effectively.
+ RS.ParametersContainer.addInvalidParameter(Header);
+ continue;
+ }
+
+ dxbc::RootParameterType ParameterType =
+ static_cast<dxbc::RootParameterType>(L.Header.Type);
+
+ switch (ParameterType) {
+ case dxbc::RootParameterType::Constants32Bit: {
const DXContainerYAML::RootConstantsYaml &ConstantYaml =
P.RootSignature->Parameters.getOrInsertConstants(L);
dxbc::RTS0::v1::RootConstants Constants;
@@ -289,9 +300,9 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
RS.ParametersContainer.addParameter(Header, Constants);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV): {
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::SRV:
+ case dxbc::RootParameterType::UAV: {
const DXContainerYAML::RootDescriptorYaml &DescriptorYaml =
P.RootSignature->Parameters.getOrInsertDescriptor(L);
@@ -303,7 +314,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
RS.ParametersContainer.addParameter(Header, Descriptor);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
+ case dxbc::RootParameterType::DescriptorTable: {
const DXContainerYAML::DescriptorTableYaml &TableYaml =
P.RootSignature->Parameters.getOrInsertTable(L);
mcdxbc::DescriptorTable Table;
@@ -323,11 +334,6 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
RS.ParametersContainer.addParameter(Header, Table);
break;
}
- default:
- // Handling invalid parameter type edge case. We intentionally let
- // obj2yaml/yaml2obj parse and emit invalid dxcontainer data, in order
- // for that to be used as a testing tool more effectively.
- RS.ParametersContainer.addInvalidParameter(Header);
}
}
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 263f7bdf37bca..03d5725c21491 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -424,22 +424,28 @@ void MappingContextTraits<DXContainerYAML::RootParameterLocationYaml,
IO.mapRequired("ParameterType", L.Header.Type);
IO.mapRequired("ShaderVisibility", L.Header.Visibility);
- switch (L.Header.Type) {
- case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): {
+ if (!dxbc::isValidParameterType(L.Header.Type))
+ return;
+ dxbc::RootParameterType PT =
+ static_cast<dxbc::RootParameterType>(L.Header.Type);
+
+ // We allow ParameterType to be invalid here.
+ switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit: {
DXContainerYAML::RootConstantsYaml &Constants =
S.Parameters.getOrInsertConstants(L);
IO.mapRequired("Constants", Constants);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV): {
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::SRV:
+ case dxbc::RootParameterType::UAV: {
DXContainerYAML::RootDescriptorYaml &Descriptor =
S.Parameters.getOrInsertDescriptor(L);
IO.mapRequired("Descriptor", Descriptor);
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
+ case dxbc::RootParameterType::DescriptorTable: {
DXContainerYAML::DescriptorTableYaml &Table =
S.Parameters.getOrInsertTable(L);
IO.mapRequired("Table", Table);
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index ebdfcaa566b51..04c7c77953a5b 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -175,8 +175,10 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
OS << "- Parameter Type: " << Type << "\n"
<< " Shader Visibility: " << Header.ShaderVisibility << "\n";
- switch (Type) {
- case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit): {
+ assert(dxbc::isValidParameterType(Type) && "Invalid Parameter Type");
+ dxbc::RootParameterType PT = static_cast<dxbc::RootParameterType>(Type);
+ switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit: {
const dxbc::RTS0::v1::RootConstants &Constants =
RS.ParametersContainer.getConstant(Loc);
OS << " Register Space: " << Constants.RegisterSpace << "\n"
@@ -184,9 +186,9 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
<< " Num 32 Bit Values: " << Constants.Num32BitValues << "\n";
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV): {
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::UAV:
+ case dxbc::RootParameterType::SRV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
RS.ParametersContainer.getRootDescriptor(Loc);
OS << " Register Space: " << Descriptor.RegisterSpace << "\n"
@@ -195,7 +197,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
OS << " Flags: " << Descriptor.Flags << "\n";
break;
}
- case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable): {
+ case dxbc::RootParameterType::DescriptorTable: {
const mcdxbc::DescriptorTable &Table =
RS.ParametersContainer.getDescriptorTable(Loc);
OS << " NumRanges: " << Table.Ranges.size() << "\n";
>From 3c1fc513424cf45e5ab6f3d2fa402036390b5e74 Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Mon, 28 Jul 2025 13:02:55 -0700
Subject: [PATCH 2/9] remove comment
---
llvm/lib/MC/DXContainerRootSignature.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index 454a0b88178f5..c94a39f80eeb2 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -36,7 +36,6 @@ size_t RootSignatureDesc::getSize() const {
StaticSamplers.size() * sizeof(dxbc::RTS0::v1::StaticSampler);
for (const RootParameterInfo &I : ParametersContainer) {
- // Invalid parameters are allowed while writing.
if (!dxbc::isValidParameterType(I.Header.ParameterType))
continue;
>From 591d12a0071e43d0f14381028fa47b1b15f99b85 Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Mon, 28 Jul 2025 13:22:25 -0700
Subject: [PATCH 3/9] remove compiling errors
---
llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index ed1e49c10818d..742b2c55bcce9 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Frontend/HLSL/RootSignatureMetadata.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/IRBuilder.h"
@@ -563,6 +564,9 @@ bool MetadataParser::validateRootSignature(
static_cast<dxbc::RootParameterType>(Info.Header.ParameterType);
switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit:
+ // ToDo: Add proper validation.
+ continue;
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::UAV:
>From 0d55d2898854ea0d3aada59e418ba231961d382f Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Tue, 29 Jul 2025 14:51:15 -0700
Subject: [PATCH 4/9] improve comment, maybe
---
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 03d5725c21491..aca605e099535 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -424,12 +424,13 @@ void MappingContextTraits<DXContainerYAML::RootParameterLocationYaml,
IO.mapRequired("ParameterType", L.Header.Type);
IO.mapRequired("ShaderVisibility", L.Header.Visibility);
+ // If a parameter type is invalid, we don't have a body to parse.
if (!dxbc::isValidParameterType(L.Header.Type))
return;
+
+ // parses the body of a given root parameter type
dxbc::RootParameterType PT =
static_cast<dxbc::RootParameterType>(L.Header.Type);
-
- // We allow ParameterType to be invalid here.
switch (PT) {
case dxbc::RootParameterType::Constants32Bit: {
DXContainerYAML::RootConstantsYaml &Constants =
>From 25ee6d7c5b92c3d61aad261ff68974a244f8687b Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Wed, 6 Aug 2025 11:03:14 -0700
Subject: [PATCH 5/9] fixing merge issues
---
llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index 4ab70aaf20985..2b50493c21c7f 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -555,10 +555,13 @@ Error MetadataParser::validateRootSignature(
dxbc::RootParameterType PT =
static_cast<dxbc::RootParameterType>(Info.Header.ParameterType);
-
- case to_underlying(dxbc::RootParameterType::CBV):
- case to_underlying(dxbc::RootParameterType::UAV):
- case to_underlying(dxbc::RootParameterType::SRV): {
+ switch (PT) {
+ case dxbc::RootParameterType::Constants32Bit:
+ // ToDo: Add proper validation.
+ continue;
+ case dxbc::RootParameterType::CBV:
+ case dxbc::RootParameterType::UAV:
+ case dxbc::RootParameterType::SRV: {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
RSD.ParametersContainer.getRootDescriptor(Info.Location);
if (!hlsl::rootsig::verifyRegisterValue(Descriptor.ShaderRegister))
>From 3924438661ce2f8a7bc9bfc345e8e1cbbf8ee18a Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Fri, 15 Aug 2025 15:10:05 -0700
Subject: [PATCH 6/9] fix
---
llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp | 2 +-
llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp b/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
index 050cc46e8c9b0..91152673df949 100644
--- a/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
+++ b/llvm/lib/Frontend/HLSL/HLSLRootSignature.cpp
@@ -93,7 +93,7 @@ static raw_ostream &operator<<(raw_ostream &OS,
}
static raw_ostream &operator<<(raw_ostream &OS, const ClauseType &Type) {
- OS << enumToStringRef(dxil::ResourceClass(llvm::to_underlying(Type)),
+ OS << enumToStringRef(dxil::ResourceClass(Type),
dxil::getResourceClasses());
return OS;
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index 7ae29c666d54c..c663c1db02a7b 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -121,7 +121,7 @@ MDNode *MetadataBuilder::BuildRootConstants(const RootConstants &Constants) {
MDNode *MetadataBuilder::BuildRootDescriptor(const RootDescriptor &Descriptor) {
IRBuilder<> Builder(Ctx);
StringRef ResName =
- enumToStringRef(dxil::ResourceClass(to_underlying(Descriptor.Type)),
+ enumToStringRef(dxil::ResourceClass(Descriptor.Type),
dxil::getResourceClasses());
assert(!ResName.empty() && "Provided an invalid Resource Class");
SmallString<7> Name({"Root", ResName});
@@ -163,7 +163,7 @@ MDNode *MetadataBuilder::BuildDescriptorTableClause(
const DescriptorTableClause &Clause) {
IRBuilder<> Builder(Ctx);
StringRef ResName =
- enumToStringRef(dxil::ResourceClass(to_underlying(Clause.Type)),
+ enumToStringRef(dxil::ResourceClass(Clause.Type),
dxil::getResourceClasses());
assert(!ResName.empty() && "Provided an invalid Resource Class");
Metadata *Operands[] = {
>From 5f26016c74f2160ba5b236f8a7e945055f04477f Mon Sep 17 00:00:00 2001
From: Joao Saffran <{ID}+{username}@users.noreply.github.com>
Date: Fri, 15 Aug 2025 15:17:28 -0700
Subject: [PATCH 7/9] finish changing
---
clang/lib/Sema/SemaHLSL.cpp | 11 +-
llvm/include/llvm/BinaryFormat/DXContainer.h | 44 +++---
.../Frontend/HLSL/RootSignatureMetadata.h | 2 +-
.../Frontend/HLSL/RootSignatureValidations.h | 19 +--
.../llvm/MC/DXContainerRootSignature.h | 4 +-
llvm/include/llvm/Object/DXContainer.h | 36 +++--
.../include/llvm/ObjectYAML/DXContainerYAML.h | 34 +++--
llvm/lib/BinaryFormat/DXContainer.cpp | 18 +++
.../Frontend/HLSL/RootSignatureMetadata.cpp | 134 +++++++++---------
.../HLSL/RootSignatureValidations.cpp | 46 +++---
llvm/lib/MC/DXContainerRootSignature.cpp | 8 +-
llvm/lib/Object/DXContainer.cpp | 3 +-
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 4 +-
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 56 +++++++-
llvm/lib/Target/DirectX/DXILRootSignature.cpp | 11 +-
llvm/unittests/Object/DXContainerTest.cpp | 49 +++----
16 files changed, 282 insertions(+), 197 deletions(-)
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 47a4874721db8..6263fddd1b0bb 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -39,6 +39,7 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/HLSLBinding.h"
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/Support/Casting.h"
@@ -1218,9 +1219,9 @@ bool SemaHLSL::handleRootSignatureElements(
ReportError(Loc, 0, 0xffffffef);
};
- const uint32_t Version =
- llvm::to_underlying(SemaRef.getLangOpts().HLSLRootSigVer);
- const uint32_t VersionEnum = Version - 1;
+ const llvm::dxbc::RootSignatureVersion Version =
+ SemaRef.getLangOpts().HLSLRootSigVer;
+ const uint32_t VersionEnum = static_cast<uint32_t>(Version) - 1;
auto ReportFlagError = [this, &HadError, VersionEnum](SourceLocation Loc) {
HadError = true;
this->Diag(Loc, diag::err_hlsl_invalid_rootsig_flag)
@@ -1270,7 +1271,9 @@ bool SemaHLSL::handleRootSignatureElements(
}
if (!llvm::hlsl::rootsig::verifyDescriptorRangeFlag(
- Version, llvm::to_underlying(Clause->Type),
+ Version,
+ llvm::dxbc::DescriptorRangeType(
+ llvm::to_underlying(Clause->Type)),
llvm::to_underlying(Clause->Flags)))
ReportFlagError(Loc);
}
diff --git a/llvm/include/llvm/BinaryFormat/DXContainer.h b/llvm/include/llvm/BinaryFormat/DXContainer.h
index f74c9775cb3f3..7010ffba0acd0 100644
--- a/llvm/include/llvm/BinaryFormat/DXContainer.h
+++ b/llvm/include/llvm/BinaryFormat/DXContainer.h
@@ -200,9 +200,9 @@ enum class DescriptorRangeType : uint32_t {
LLVM_ABI ArrayRef<EnumEntry<DescriptorRangeType>> getDescriptorRangeTypes();
#define ROOT_PARAMETER(Val, Enum) \
- case Val: \
+ case dxbc::RootParameterType::Enum: \
return true;
-inline bool isValidParameterType(uint32_t V) {
+inline bool isValidParameterType(dxbc::RootParameterType V) {
switch (V) {
#include "DXContainerConstants.def"
}
@@ -217,9 +217,9 @@ enum class ShaderVisibility : uint32_t {
LLVM_ABI ArrayRef<EnumEntry<ShaderVisibility>> getShaderVisibility();
#define SHADER_VISIBILITY(Val, Enum) \
- case Val: \
+ case dxbc::ShaderVisibility::Enum: \
return true;
-inline bool isValidShaderVisibility(uint32_t V) {
+inline bool isValidShaderVisibility(dxbc::ShaderVisibility V) {
switch (V) {
#include "DXContainerConstants.def"
}
@@ -254,6 +254,14 @@ enum class StaticBorderColor : uint32_t {
LLVM_ABI ArrayRef<EnumEntry<StaticBorderColor>> getStaticBorderColors();
+// D3D_ROOT_SIGNATURE_VERSION
+enum class RootSignatureVersion {
+ V1_0 = 0x1,
+ V1_1 = 0x2,
+};
+
+LLVM_ABI ArrayRef<EnumEntry<RootSignatureVersion>> getRootSignatureVersions();
+
LLVM_ABI PartType parsePartType(StringRef S);
struct VertexPSVInfo {
@@ -646,19 +654,19 @@ static_assert(sizeof(ProgramSignatureElement) == 32,
namespace RTS0 {
namespace v1 {
struct StaticSampler {
- uint32_t Filter;
- uint32_t AddressU;
- uint32_t AddressV;
- uint32_t AddressW;
+ dxbc::SamplerFilter Filter;
+ dxbc::TextureAddressMode AddressU;
+ dxbc::TextureAddressMode AddressV;
+ dxbc::TextureAddressMode AddressW;
float MipLODBias;
uint32_t MaxAnisotropy;
- uint32_t ComparisonFunc;
- uint32_t BorderColor;
+ dxbc::ComparisonFunc ComparisonFunc;
+ dxbc::StaticBorderColor BorderColor;
float MinLOD;
float MaxLOD;
uint32_t ShaderRegister;
uint32_t RegisterSpace;
- uint32_t ShaderVisibility;
+ dxbc::ShaderVisibility ShaderVisibility;
void swapBytes() {
sys::swapByteOrder(Filter);
sys::swapByteOrder(AddressU);
@@ -677,7 +685,7 @@ struct StaticSampler {
};
struct DescriptorRange {
- uint32_t RangeType;
+ dxbc::DescriptorRangeType RangeType;
uint32_t NumDescriptors;
uint32_t BaseShaderRegister;
uint32_t RegisterSpace;
@@ -715,8 +723,8 @@ struct RootConstants {
};
struct RootParameterHeader {
- uint32_t ParameterType;
- uint32_t ShaderVisibility;
+ dxbc::RootParameterType ParameterType;
+ dxbc::ShaderVisibility ShaderVisibility;
uint32_t ParameterOffset;
void swapBytes() {
@@ -760,7 +768,7 @@ struct RootDescriptor : public v1::RootDescriptor {
};
struct DescriptorRange {
- uint32_t RangeType;
+ dxbc::DescriptorRangeType RangeType;
uint32_t NumDescriptors;
uint32_t BaseShaderRegister;
uint32_t RegisterSpace;
@@ -778,12 +786,6 @@ struct DescriptorRange {
} // namespace v2
} // namespace RTS0
-// D3D_ROOT_SIGNATURE_VERSION
-enum class RootSignatureVersion {
- V1_0 = 0x1,
- V1_1 = 0x2,
-};
-
} // namespace dxbc
} // namespace llvm
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
index c6d7c32c4ad95..3ca1ebcc90bde 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
@@ -143,7 +143,7 @@ class MetadataParser {
MetadataParser(MDNode *Root) : Root(Root) {}
LLVM_ABI llvm::Expected<llvm::mcdxbc::RootSignatureDesc>
- ParseRootSignature(uint32_t Version);
+ ParseRootSignature(dxbc::RootSignatureVersion Version);
private:
llvm::Error parseRootFlags(mcdxbc::RootSignatureDesc &RSD,
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
index fde32a1fff591..ac3131fd05eb6 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
@@ -15,6 +15,7 @@
#define LLVM_FRONTEND_HLSL_ROOTSIGNATUREVALIDATIONS_H
#include "llvm/ADT/IntervalMap.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
#include "llvm/Support/Compiler.h"
@@ -25,20 +26,22 @@ namespace rootsig {
// Basic verification of RootElements
LLVM_ABI bool verifyRootFlag(uint32_t Flags);
-LLVM_ABI bool verifyVersion(uint32_t Version);
+LLVM_ABI bool verifyVersion(dxbc::RootSignatureVersion Version);
LLVM_ABI bool verifyRegisterValue(uint32_t RegisterValue);
LLVM_ABI bool verifyRegisterSpace(uint32_t RegisterSpace);
-LLVM_ABI bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal);
-LLVM_ABI bool verifyRangeType(uint32_t Type);
-LLVM_ABI bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type,
+LLVM_ABI bool verifyRootDescriptorFlag(dxbc::RootSignatureVersion Version,
+ uint32_t FlagsVal);
+LLVM_ABI bool verifyRangeType(dxbc::DescriptorRangeType Type);
+LLVM_ABI bool verifyDescriptorRangeFlag(dxbc::RootSignatureVersion Version,
+ dxbc::DescriptorRangeType Type,
uint32_t FlagsVal);
LLVM_ABI bool verifyNumDescriptors(uint32_t NumDescriptors);
-LLVM_ABI bool verifySamplerFilter(uint32_t Value);
-LLVM_ABI bool verifyAddress(uint32_t Address);
+LLVM_ABI bool verifySamplerFilter(dxbc::SamplerFilter Value);
+LLVM_ABI bool verifyAddress(dxbc::TextureAddressMode Address);
LLVM_ABI bool verifyMipLODBias(float MipLODBias);
LLVM_ABI bool verifyMaxAnisotropy(uint32_t MaxAnisotropy);
-LLVM_ABI bool verifyComparisonFunc(uint32_t ComparisonFunc);
-LLVM_ABI bool verifyBorderColor(uint32_t BorderColor);
+LLVM_ABI bool verifyComparisonFunc(dxbc::ComparisonFunc ComparisonFunc);
+LLVM_ABI bool verifyBorderColor(dxbc::StaticBorderColor BorderColor);
LLVM_ABI bool verifyLOD(float LOD);
} // namespace rootsig
diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h b/llvm/include/llvm/MC/DXContainerRootSignature.h
index 3c7c886e79fc3..6c2a4a75b7618 100644
--- a/llvm/include/llvm/MC/DXContainerRootSignature.h
+++ b/llvm/include/llvm/MC/DXContainerRootSignature.h
@@ -72,7 +72,7 @@ struct RootParametersContainer {
Tables.push_back(Table);
}
- std::pair<uint32_t, uint32_t>
+ std::pair<dxbc::RootParameterType, uint32_t>
getTypeAndLocForParameter(uint32_t Location) const {
const RootParameterInfo &Info = ParametersInfo[Location];
return {Info.Header.ParameterType, Info.Location};
@@ -106,7 +106,7 @@ struct RootParametersContainer {
};
struct RootSignatureDesc {
- uint32_t Version = 2U;
+ dxbc::RootSignatureVersion Version = dxbc::RootSignatureVersion::V1_1;
uint32_t Flags = 0U;
uint32_t RootParameterOffset = 0U;
uint32_t StaticSamplersOffset = 0u;
diff --git a/llvm/include/llvm/Object/DXContainer.h b/llvm/include/llvm/Object/DXContainer.h
index ad1b2361ff064..7398facdc42d7 100644
--- a/llvm/include/llvm/Object/DXContainer.h
+++ b/llvm/include/llvm/Object/DXContainer.h
@@ -146,8 +146,7 @@ struct RootParameterView {
struct RootConstantView : RootParameterView {
static bool classof(const RootParameterView *V) {
- return V->Header.ParameterType ==
- (uint32_t)dxbc::RootParameterType::Constants32Bit;
+ return V->Header.ParameterType == dxbc::RootParameterType::Constants32Bit;
}
llvm::Expected<dxbc::RTS0::v1::RootConstants> read() {
@@ -157,25 +156,24 @@ struct RootConstantView : RootParameterView {
struct RootDescriptorView : RootParameterView {
static bool classof(const RootParameterView *V) {
- return (V->Header.ParameterType ==
- llvm::to_underlying(dxbc::RootParameterType::CBV) ||
- V->Header.ParameterType ==
- llvm::to_underlying(dxbc::RootParameterType::SRV) ||
- V->Header.ParameterType ==
- llvm::to_underlying(dxbc::RootParameterType::UAV));
+ return (V->Header.ParameterType == dxbc::RootParameterType::CBV ||
+ V->Header.ParameterType == dxbc::RootParameterType::SRV ||
+ V->Header.ParameterType == dxbc::RootParameterType::UAV);
}
- llvm::Expected<dxbc::RTS0::v2::RootDescriptor> read(uint32_t Version) {
- if (Version == 1) {
+ llvm::Expected<dxbc::RTS0::v2::RootDescriptor>
+ read(dxbc::RootSignatureVersion Version) {
+ if (Version == dxbc::RootSignatureVersion::V1_0) {
auto Descriptor = readParameter<dxbc::RTS0::v1::RootDescriptor>();
if (Error E = Descriptor.takeError())
return E;
return dxbc::RTS0::v2::RootDescriptor(*Descriptor);
}
- if (Version != 2)
- return make_error<GenericBinaryError>("Invalid Root Signature version: " +
- Twine(Version),
- object_error::parse_failed);
+ if (Version != dxbc::RootSignatureVersion::V1_1)
+ return make_error<GenericBinaryError>(
+ "Invalid Root Signature version: " +
+ Twine(static_cast<uint32_t>(Version)),
+ object_error::parse_failed);
return readParameter<dxbc::RTS0::v2::RootDescriptor>();
}
};
@@ -192,7 +190,7 @@ template <typename T> struct DescriptorTable {
struct DescriptorTableView : RootParameterView {
static bool classof(const RootParameterView *V) {
return (V->Header.ParameterType ==
- llvm::to_underlying(dxbc::RootParameterType::DescriptorTable));
+ dxbc::RootParameterType::DescriptorTable);
}
// Define a type alias to access the template parameter from inside classof
@@ -220,7 +218,7 @@ static Error parseFailed(const Twine &Msg) {
class RootSignature {
private:
- uint32_t Version;
+ dxbc::RootSignatureVersion Version;
uint32_t NumParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
@@ -238,7 +236,7 @@ class RootSignature {
RootSignature(StringRef PD) : PartData(PD) {}
LLVM_ABI Error parse();
- uint32_t getVersion() const { return Version; }
+ dxbc::RootSignatureVersion getVersion() const { return Version; }
uint32_t getNumParameters() const { return NumParameters; }
uint32_t getRootParametersOffset() const { return RootParametersOffset; }
uint32_t getNumStaticSamplers() const { return NumStaticSamplers; }
@@ -269,7 +267,7 @@ class RootSignature {
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV:
- if (Version == 1)
+ if (Version == dxbc::RootSignatureVersion::V1_0)
DataSize = sizeof(dxbc::RTS0::v1::RootDescriptor);
else
DataSize = sizeof(dxbc::RTS0::v2::RootDescriptor);
@@ -281,7 +279,7 @@ class RootSignature {
uint32_t NumRanges =
support::endian::read<uint32_t, llvm::endianness::little>(
PartData.begin() + Header.ParameterOffset);
- if (Version == 1)
+ if (Version == dxbc::RootSignatureVersion::V1_0)
DataSize = sizeof(dxbc::RTS0::v1::DescriptorRange) * NumRanges;
else
DataSize = sizeof(dxbc::RTS0::v2::DescriptorRange) * NumRanges;
diff --git a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
index 7e0a4c6b07039..dadc4d2ed6043 100644
--- a/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
+++ b/llvm/include/llvm/ObjectYAML/DXContainerYAML.h
@@ -92,7 +92,7 @@ struct RootDescriptorYaml {
};
struct DescriptorRangeYaml {
- uint32_t RangeType;
+ dxbc::DescriptorRangeType RangeType;
uint32_t NumDescriptors;
uint32_t BaseShaderRegister;
uint32_t RegisterSpace;
@@ -111,12 +111,12 @@ struct DescriptorTableYaml {
};
struct RootParameterHeaderYaml {
- uint32_t Type;
- uint32_t Visibility;
+ dxbc::RootParameterType Type;
+ dxbc::ShaderVisibility Visibility;
uint32_t Offset;
RootParameterHeaderYaml(){};
- RootParameterHeaderYaml(uint32_t T) : Type(T) {}
+ RootParameterHeaderYaml(dxbc::RootParameterType T) : Type(T) {}
};
struct RootParameterLocationYaml {
@@ -165,27 +165,25 @@ struct RootParameterYamlDesc {
};
struct StaticSamplerYamlDesc {
- uint32_t Filter = llvm::to_underlying(dxbc::SamplerFilter::Anisotropic);
- uint32_t AddressU = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
- uint32_t AddressV = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
- uint32_t AddressW = llvm::to_underlying(dxbc::TextureAddressMode::Wrap);
+ dxbc::SamplerFilter Filter = dxbc::SamplerFilter::Anisotropic;
+ dxbc::TextureAddressMode AddressU = dxbc::TextureAddressMode::Wrap;
+ dxbc::TextureAddressMode AddressV = dxbc::TextureAddressMode::Wrap;
+ dxbc::TextureAddressMode AddressW = dxbc::TextureAddressMode::Wrap;
float MipLODBias = 0.f;
uint32_t MaxAnisotropy = 16u;
- uint32_t ComparisonFunc =
- llvm::to_underlying(dxbc::ComparisonFunc::LessEqual);
- uint32_t BorderColor =
- llvm::to_underlying(dxbc::StaticBorderColor::OpaqueWhite);
+ dxbc::ComparisonFunc ComparisonFunc = dxbc::ComparisonFunc::LessEqual;
+ dxbc::StaticBorderColor BorderColor = dxbc::StaticBorderColor::OpaqueWhite;
float MinLOD = 0.f;
float MaxLOD = std::numeric_limits<float>::max();
uint32_t ShaderRegister;
uint32_t RegisterSpace;
- uint32_t ShaderVisibility;
+ dxbc::ShaderVisibility ShaderVisibility;
};
struct RootSignatureYamlDesc {
RootSignatureYamlDesc() = default;
- uint32_t Version;
+ dxbc::RootSignatureVersion Version;
uint32_t NumRootParameters;
uint32_t RootParametersOffset;
uint32_t NumStaticSamplers;
@@ -321,6 +319,14 @@ LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::PSV::ResourceKind)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::D3DSystemValue)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigComponentType)
LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SigMinPrecision)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::ShaderVisibility)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::RootParameterType)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::DescriptorRangeType)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::SamplerFilter)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::TextureAddressMode)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::StaticBorderColor)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::ComparisonFunc)
+LLVM_YAML_DECLARE_ENUM_TRAITS(llvm::dxbc::RootSignatureVersion)
namespace llvm {
diff --git a/llvm/lib/BinaryFormat/DXContainer.cpp b/llvm/lib/BinaryFormat/DXContainer.cpp
index 36d10d0b63078..8d8cfbf163118 100644
--- a/llvm/lib/BinaryFormat/DXContainer.cpp
+++ b/llvm/lib/BinaryFormat/DXContainer.cpp
@@ -139,6 +139,24 @@ ArrayRef<EnumEntry<StaticBorderColor>> dxbc::getStaticBorderColors() {
return ArrayRef(StaticBorderColorValues);
}
+#define DESCRIPTOR_RANGE(Val, Enum) {#Enum, DescriptorRangeType::Enum},
+static const EnumEntry<DescriptorRangeType> DescriptorRangeTypeValues[] = {
+#include "llvm/BinaryFormat/DXContainerConstants.def"
+};
+
+ArrayRef<EnumEntry<DescriptorRangeType>> dxbc::getDescriptorRangeTypes() {
+ return ArrayRef(DescriptorRangeTypeValues);
+}
+
+static const EnumEntry<RootSignatureVersion> RootSignatureVersionsValues[] = {
+ {"V1_0", RootSignatureVersion::V1_0},
+ {"V1_1", RootSignatureVersion::V1_1},
+};
+
+ArrayRef<EnumEntry<RootSignatureVersion>> dxbc::getRootSignatureVersions() {
+ return ArrayRef(RootSignatureVersionsValues);
+}
+
#define ROOT_PARAMETER(Val, Enum) {#Enum, RootParameterType::Enum},
static const EnumEntry<RootParameterType> RootParameterTypes[] = {
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index c663c1db02a7b..5d2d02b344309 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -228,10 +228,10 @@ Error MetadataParser::parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
dxbc::RTS0::v1::RootParameterHeader Header;
// The parameter offset doesn't matter here - we recalculate it during
// serialization Header.ParameterOffset = 0;
- Header.ParameterType = to_underlying(dxbc::RootParameterType::Constants32Bit);
+ Header.ParameterType = dxbc::RootParameterType::Constants32Bit;
if (std::optional<uint32_t> Val = extractMdIntValue(RootConstantNode, 1))
- Header.ShaderVisibility = *Val;
+ Header.ShaderVisibility = static_cast<dxbc::ShaderVisibility>(*Val);
else
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
@@ -270,13 +270,13 @@ Error MetadataParser::parseRootDescriptors(
dxbc::RTS0::v1::RootParameterHeader Header;
switch (ElementKind) {
case RootSignatureElementKind::SRV:
- Header.ParameterType = to_underlying(dxbc::RootParameterType::SRV);
+ Header.ParameterType = dxbc::RootParameterType::SRV;
break;
case RootSignatureElementKind::UAV:
- Header.ParameterType = to_underlying(dxbc::RootParameterType::UAV);
+ Header.ParameterType = dxbc::RootParameterType::UAV;
break;
case RootSignatureElementKind::CBV:
- Header.ParameterType = to_underlying(dxbc::RootParameterType::CBV);
+ Header.ParameterType = dxbc::RootParameterType::CBV;
break;
default:
llvm_unreachable("invalid Root Descriptor kind");
@@ -284,7 +284,7 @@ Error MetadataParser::parseRootDescriptors(
}
if (std::optional<uint32_t> Val = extractMdIntValue(RootDescriptorNode, 1))
- Header.ShaderVisibility = *Val;
+ Header.ShaderVisibility = static_cast<dxbc::ShaderVisibility>(*Val);
else
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
@@ -299,11 +299,11 @@ Error MetadataParser::parseRootDescriptors(
else
return make_error<InvalidRSMetadataValue>("RegisterSpace");
- if (RSD.Version == 1) {
+ if (RSD.Version == dxbc::RootSignatureVersion::V1_0) {
RSD.ParametersContainer.addParameter(Header, Descriptor);
return Error::success();
}
- assert(RSD.Version > 1);
+ assert(RSD.Version > dxbc::RootSignatureVersion::V1_0);
if (std::optional<uint32_t> Val = extractMdIntValue(RootDescriptorNode, 4))
Descriptor.Flags = *Val;
@@ -327,15 +327,13 @@ Error MetadataParser::parseDescriptorRange(mcdxbc::DescriptorTable &Table,
if (!ElementText.has_value())
return make_error<InvalidRSMetadataFormat>("Descriptor Range");
- Range.RangeType =
- StringSwitch<uint32_t>(*ElementText)
- .Case("CBV", to_underlying(dxbc::DescriptorRangeType::CBV))
- .Case("SRV", to_underlying(dxbc::DescriptorRangeType::SRV))
- .Case("UAV", to_underlying(dxbc::DescriptorRangeType::UAV))
- .Case("Sampler", to_underlying(dxbc::DescriptorRangeType::Sampler))
- .Default(~0U);
+ Range.RangeType = StringSwitch<dxbc::DescriptorRangeType>(*ElementText)
+ .Case("CBV", dxbc::DescriptorRangeType::CBV)
+ .Case("SRV", dxbc::DescriptorRangeType::SRV)
+ .Case("UAV", dxbc::DescriptorRangeType::UAV)
+ .Case("Sampler", dxbc::DescriptorRangeType::Sampler);
- if (Range.RangeType == ~0U)
+ if (!verifyRangeType(Range.RangeType))
return make_error<GenericRSMetadataError>("Invalid Descriptor Range type.",
RangeDescriptorNode);
@@ -378,13 +376,12 @@ Error MetadataParser::parseDescriptorTable(mcdxbc::RootSignatureDesc &RSD,
dxbc::RTS0::v1::RootParameterHeader Header;
if (std::optional<uint32_t> Val = extractMdIntValue(DescriptorTableNode, 1))
- Header.ShaderVisibility = *Val;
+ Header.ShaderVisibility = static_cast<dxbc::ShaderVisibility>(*Val);
else
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
mcdxbc::DescriptorTable Table;
- Header.ParameterType =
- to_underlying(dxbc::RootParameterType::DescriptorTable);
+ Header.ParameterType = dxbc::RootParameterType::DescriptorTable;
for (unsigned int I = 2; I < NumOperands; I++) {
MDNode *Element = dyn_cast<MDNode>(DescriptorTableNode->getOperand(I));
@@ -407,22 +404,22 @@ Error MetadataParser::parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
dxbc::RTS0::v1::StaticSampler Sampler;
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 1))
- Sampler.Filter = *Val;
+ Sampler.Filter = static_cast<dxbc::SamplerFilter>(*Val);
else
return make_error<InvalidRSMetadataValue>("Filter");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 2))
- Sampler.AddressU = *Val;
+ Sampler.AddressU = static_cast<dxbc::TextureAddressMode>(*Val);
else
return make_error<InvalidRSMetadataValue>("AddressU");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 3))
- Sampler.AddressV = *Val;
+ Sampler.AddressV = static_cast<dxbc::TextureAddressMode>(*Val);
else
return make_error<InvalidRSMetadataValue>("AddressV");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 4))
- Sampler.AddressW = *Val;
+ Sampler.AddressW = static_cast<dxbc::TextureAddressMode>(*Val);
else
return make_error<InvalidRSMetadataValue>("AddressW");
@@ -437,12 +434,12 @@ Error MetadataParser::parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
return make_error<InvalidRSMetadataValue>("MaxAnisotropy");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 7))
- Sampler.ComparisonFunc = *Val;
+ Sampler.ComparisonFunc = static_cast<dxbc::ComparisonFunc>(*Val);
else
return make_error<InvalidRSMetadataValue>("ComparisonFunc");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 8))
- Sampler.BorderColor = *Val;
+ Sampler.BorderColor = static_cast<dxbc::StaticBorderColor>(*Val);
else
return make_error<InvalidRSMetadataValue>("ComparisonFunc");
@@ -467,7 +464,7 @@ Error MetadataParser::parseStaticSampler(mcdxbc::RootSignatureDesc &RSD,
return make_error<InvalidRSMetadataValue>("RegisterSpace");
if (std::optional<uint32_t> Val = extractMdIntValue(StaticSamplerNode, 13))
- Sampler.ShaderVisibility = *Val;
+ Sampler.ShaderVisibility = static_cast<dxbc::ShaderVisibility>(*Val);
else
return make_error<InvalidRSMetadataValue>("ShaderVisibility");
@@ -518,10 +515,10 @@ Error MetadataParser::validateRootSignature(
const mcdxbc::RootSignatureDesc &RSD) {
Error DeferredErrs = Error::success();
if (!hlsl::rootsig::verifyVersion(RSD.Version)) {
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "Version", RSD.Version));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::RootSignatureVersion>>(
+ "Version", RSD.Version));
}
if (!hlsl::rootsig::verifyRootFlag(RSD.Flags)) {
@@ -533,10 +530,10 @@ Error MetadataParser::validateRootSignature(
for (const mcdxbc::RootParameterInfo &Info : RSD.ParametersContainer) {
if (!dxbc::isValidShaderVisibility(Info.Header.ShaderVisibility))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "ShaderVisibility", Info.Header.ShaderVisibility));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::ShaderVisibility>>(
+ "ShaderVisibility", Info.Header.ShaderVisibility));
assert(dxbc::isValidParameterType(Info.Header.ParameterType) &&
"Invalid value for ParameterType");
@@ -564,7 +561,7 @@ Error MetadataParser::validateRootSignature(
make_error<RootSignatureValidationError<uint32_t>>(
"RegisterSpace", Descriptor.RegisterSpace));
- if (RSD.Version > 1) {
+ if (RSD.Version > dxbc::RootSignatureVersion::V1_0) {
if (!hlsl::rootsig::verifyRootDescriptorFlag(RSD.Version,
Descriptor.Flags))
DeferredErrs =
@@ -579,10 +576,11 @@ Error MetadataParser::validateRootSignature(
RSD.ParametersContainer.getDescriptorTable(Info.Location);
for (const dxbc::RTS0::v2::DescriptorRange &Range : Table) {
if (!hlsl::rootsig::verifyRangeType(Range.RangeType))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "RangeType", Range.RangeType));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<
+ RootSignatureValidationError<dxbc::DescriptorRangeType>>(
+ "RangeType", Range.RangeType));
if (!hlsl::rootsig::verifyRegisterSpace(Range.RegisterSpace))
DeferredErrs =
@@ -610,28 +608,28 @@ Error MetadataParser::validateRootSignature(
for (const dxbc::RTS0::v1::StaticSampler &Sampler : RSD.StaticSamplers) {
if (!hlsl::rootsig::verifySamplerFilter(Sampler.Filter))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "Filter", Sampler.Filter));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::SamplerFilter>>(
+ "Filter", Sampler.Filter));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressU))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "AddressU", Sampler.AddressU));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ "AddressU", Sampler.AddressU));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressV))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "AddressV", Sampler.AddressV));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ "AddressV", Sampler.AddressV));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressW))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "AddressW", Sampler.AddressW));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ "AddressW", Sampler.AddressW));
if (!hlsl::rootsig::verifyMipLODBias(Sampler.MipLODBias))
DeferredErrs = joinErrors(std::move(DeferredErrs),
@@ -645,16 +643,16 @@ Error MetadataParser::validateRootSignature(
"MaxAnisotropy", Sampler.MaxAnisotropy));
if (!hlsl::rootsig::verifyComparisonFunc(Sampler.ComparisonFunc))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "ComparisonFunc", Sampler.ComparisonFunc));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::ComparisonFunc>>(
+ "ComparisonFunc", Sampler.ComparisonFunc));
if (!hlsl::rootsig::verifyBorderColor(Sampler.BorderColor))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "BorderColor", Sampler.BorderColor));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::StaticBorderColor>>(
+ "BorderColor", Sampler.BorderColor));
if (!hlsl::rootsig::verifyLOD(Sampler.MinLOD))
DeferredErrs = joinErrors(std::move(DeferredErrs),
@@ -679,17 +677,17 @@ Error MetadataParser::validateRootSignature(
"RegisterSpace", Sampler.RegisterSpace));
if (!dxbc::isValidShaderVisibility(Sampler.ShaderVisibility))
- DeferredErrs =
- joinErrors(std::move(DeferredErrs),
- make_error<RootSignatureValidationError<uint32_t>>(
- "ShaderVisibility", Sampler.ShaderVisibility));
+ DeferredErrs = joinErrors(
+ std::move(DeferredErrs),
+ make_error<RootSignatureValidationError<dxbc::ShaderVisibility>>(
+ "ShaderVisibility", Sampler.ShaderVisibility));
}
return DeferredErrs;
}
Expected<mcdxbc::RootSignatureDesc>
-MetadataParser::ParseRootSignature(uint32_t Version) {
+MetadataParser::ParseRootSignature(dxbc::RootSignatureVersion Version) {
Error DeferredErrs = Error::success();
mcdxbc::RootSignatureDesc RSD;
RSD.Version = Version;
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
index ebd12169b86ab..9a5b3b8cae4f6 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
@@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include <cmath>
@@ -20,7 +21,10 @@ namespace rootsig {
bool verifyRootFlag(uint32_t Flags) { return (Flags & ~0xfff) == 0; }
-bool verifyVersion(uint32_t Version) { return (Version == 1 || Version == 2); }
+bool verifyVersion(dxbc::RootSignatureVersion Version) {
+ return (Version == dxbc::RootSignatureVersion::V1_0 ||
+ Version == dxbc::RootSignatureVersion::V1_1);
+}
bool verifyRegisterValue(uint32_t RegisterValue) {
return RegisterValue != ~0U;
@@ -32,13 +36,15 @@ bool verifyRegisterSpace(uint32_t RegisterSpace) {
return !(RegisterSpace >= 0xFFFFFFF0);
}
-bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {
+bool verifyRootDescriptorFlag(dxbc::RootSignatureVersion Version,
+ uint32_t FlagsVal) {
using FlagT = dxbc::RootDescriptorFlags;
FlagT Flags = FlagT(FlagsVal);
- if (Version == 1)
+ if (Version == dxbc::RootSignatureVersion::V1_0)
return Flags == FlagT::DataVolatile;
- assert(Version == 2 && "Provided invalid root signature version");
+ assert(Version == dxbc::RootSignatureVersion::V1_1 &&
+ "Provided invalid root signature version");
// The data-specific flags are mutually exclusive.
FlagT DataFlags = FlagT::DataVolatile | FlagT::DataStatic |
@@ -51,10 +57,9 @@ bool verifyRootDescriptorFlag(uint32_t Version, uint32_t FlagsVal) {
return (Flags | DataFlags) == DataFlags;
}
-bool verifyRangeType(uint32_t Type) {
+bool verifyRangeType(dxbc::DescriptorRangeType Type) {
switch (Type) {
-#define DESCRIPTOR_RANGE(Num, Val) \
- case llvm::to_underlying(dxbc::DescriptorRangeType::Val):
+#define DESCRIPTOR_RANGE(Num, Val) case dxbc::DescriptorRangeType::Val:
#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
};
@@ -62,15 +67,15 @@ bool verifyRangeType(uint32_t Type) {
return false;
}
-bool verifyDescriptorRangeFlag(uint32_t Version, uint32_t Type,
+bool verifyDescriptorRangeFlag(llvm::dxbc::RootSignatureVersion Version,
+ llvm::dxbc::DescriptorRangeType Type,
uint32_t FlagsVal) {
using FlagT = dxbc::DescriptorRangeFlags;
FlagT Flags = FlagT(FlagsVal);
- const bool IsSampler =
- (Type == llvm::to_underlying(dxbc::DescriptorRangeType::Sampler));
+ const bool IsSampler = (Type == dxbc::DescriptorRangeType::Sampler);
- if (Version == 1) {
+ if (Version == dxbc::RootSignatureVersion::V1_0) {
// Since the metadata is unversioned, we expect to explicitly see the values
// that map to the version 1 behaviour here.
if (IsSampler)
@@ -128,9 +133,9 @@ bool verifyNumDescriptors(uint32_t NumDescriptors) {
return NumDescriptors > 0;
}
-bool verifySamplerFilter(uint32_t Value) {
+bool verifySamplerFilter(dxbc::SamplerFilter Value) {
switch (Value) {
-#define FILTER(Num, Val) case llvm::to_underlying(dxbc::SamplerFilter::Val):
+#define FILTER(Num, Val) case dxbc::SamplerFilter::Val:
#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
}
@@ -139,10 +144,9 @@ bool verifySamplerFilter(uint32_t Value) {
// Values allowed here:
// https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ne-d3d12-d3d12_texture_address_mode#syntax
-bool verifyAddress(uint32_t Address) {
+bool verifyAddress(dxbc::TextureAddressMode Address) {
switch (Address) {
-#define TEXTURE_ADDRESS_MODE(Num, Val) \
- case llvm::to_underlying(dxbc::TextureAddressMode::Val):
+#define TEXTURE_ADDRESS_MODE(Num, Val) case dxbc::TextureAddressMode::Val:
#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
}
@@ -157,20 +161,18 @@ bool verifyMaxAnisotropy(uint32_t MaxAnisotropy) {
return MaxAnisotropy <= 16u;
}
-bool verifyComparisonFunc(uint32_t ComparisonFunc) {
+bool verifyComparisonFunc(dxbc::ComparisonFunc ComparisonFunc) {
switch (ComparisonFunc) {
-#define COMPARISON_FUNC(Num, Val) \
- case llvm::to_underlying(dxbc::ComparisonFunc::Val):
+#define COMPARISON_FUNC(Num, Val) case dxbc::ComparisonFunc::Val:
#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
}
return false;
}
-bool verifyBorderColor(uint32_t BorderColor) {
+bool verifyBorderColor(dxbc::StaticBorderColor BorderColor) {
switch (BorderColor) {
-#define STATIC_BORDER_COLOR(Num, Val) \
- case llvm::to_underlying(dxbc::StaticBorderColor::Val):
+#define STATIC_BORDER_COLOR(Num, Val) case dxbc::StaticBorderColor::Val:
#include "llvm/BinaryFormat/DXContainerConstants.def"
return true;
}
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index c94a39f80eeb2..ebd1b201d6f00 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -49,7 +49,7 @@ size_t RootSignatureDesc::getSize() const {
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV:
- if (Version == 1)
+ if (Version == dxbc::RootSignatureVersion::V1_0)
Size += sizeof(dxbc::RTS0::v1::RootDescriptor);
else
Size += sizeof(dxbc::RTS0::v2::RootDescriptor);
@@ -62,7 +62,7 @@ size_t RootSignatureDesc::getSize() const {
// 4 bytes for the number of ranges in table and
// 4 bytes for the ranges offset
Size += 2 * sizeof(uint32_t);
- if (Version == 1)
+ if (Version == dxbc::RootSignatureVersion::V1_0)
Size += sizeof(dxbc::RTS0::v1::DescriptorRange) * Table.Ranges.size();
else
Size += sizeof(dxbc::RTS0::v2::DescriptorRange) * Table.Ranges.size();
@@ -130,7 +130,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
llvm::endianness::little);
support::endian::write(BOS, Descriptor.RegisterSpace,
llvm::endianness::little);
- if (Version > 1)
+ if (Version > dxbc::RootSignatureVersion::V1_0)
support::endian::write(BOS, Descriptor.Flags, llvm::endianness::little);
break;
}
@@ -148,7 +148,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
llvm::endianness::little);
support::endian::write(BOS, Range.RegisterSpace,
llvm::endianness::little);
- if (Version > 1)
+ if (Version > dxbc::RootSignatureVersion::V1_0)
support::endian::write(BOS, Range.Flags, llvm::endianness::little);
support::endian::write(BOS, Range.OffsetInDescriptorsFromTableStart,
llvm::endianness::little);
diff --git a/llvm/lib/Object/DXContainer.cpp b/llvm/lib/Object/DXContainer.cpp
index 031b9414f4c1a..431befc24b673 100644
--- a/llvm/lib/Object/DXContainer.cpp
+++ b/llvm/lib/Object/DXContainer.cpp
@@ -250,7 +250,8 @@ Error DirectX::RootSignature::parse() {
return parseFailed(
"Invalid root signature, insufficient space for header.");
- Version = support::endian::read<uint32_t, llvm::endianness::little>(Current);
+ Version = support::endian::read<dxbc::RootSignatureVersion,
+ llvm::endianness::little>(Current);
Current += sizeof(uint32_t);
NumParameters =
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index 35e1c3e3b5953..bf36bfe6647e5 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -309,7 +309,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
dxbc::RTS0::v2::RootDescriptor Descriptor;
Descriptor.RegisterSpace = DescriptorYaml.RegisterSpace;
Descriptor.ShaderRegister = DescriptorYaml.ShaderRegister;
- if (RS.Version > 1)
+ if (RS.Version > dxbc::RootSignatureVersion::V1_0)
Descriptor.Flags = DescriptorYaml.getEncodedFlags();
RS.ParametersContainer.addParameter(Header, Descriptor);
break;
@@ -327,7 +327,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
Range.RegisterSpace = R.RegisterSpace;
Range.OffsetInDescriptorsFromTableStart =
R.OffsetInDescriptorsFromTableStart;
- if (RS.Version > 1)
+ if (RS.Version > dxbc::RootSignatureVersion::V1_0)
Range.Flags = R.getEncodedFlags();
Table.Ranges.push_back(Range);
}
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index aca605e099535..8cc38a3f928ff 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -79,7 +79,7 @@ DXContainerYAML::RootSignatureYamlDesc::create(
const object::DirectX::RootSignature &Data) {
RootSignatureYamlDesc RootSigDesc;
- uint32_t Version = Data.getVersion();
+ dxbc::RootSignatureVersion Version = Data.getVersion();
RootSigDesc.Version = Version;
RootSigDesc.NumStaticSamplers = Data.getNumStaticSamplers();
@@ -139,7 +139,7 @@ DXContainerYAML::RootSignatureYamlDesc::create(
YamlDescriptor.ShaderRegister = Descriptor.ShaderRegister;
YamlDescriptor.RegisterSpace = Descriptor.RegisterSpace;
- if (Version > 1) {
+ if (Version > dxbc::RootSignatureVersion::V1_0) {
#define ROOT_DESCRIPTOR_FLAG(Num, Enum, Flag) \
YamlDescriptor.Enum = \
(Descriptor.Flags & \
@@ -148,11 +148,11 @@ DXContainerYAML::RootSignatureYamlDesc::create(
}
} else if (auto *DTV =
dyn_cast<object::DirectX::DescriptorTableView>(&ParamView)) {
- if (Version == 1) {
+ if (Version == dxbc::RootSignatureVersion::V1_0) {
if (Error E = readDescriptorRanges<dxbc::RTS0::v1::DescriptorRange>(
Header, RootSigDesc, DTV))
return std::move(E);
- } else if (Version == 2) {
+ } else if (Version == dxbc::RootSignatureVersion::V1_1) {
if (Error E = readDescriptorRanges<dxbc::RTS0::v2::DescriptorRange>(
Header, RootSigDesc, DTV))
return std::move(E);
@@ -592,6 +592,54 @@ void ScalarEnumerationTraits<dxbc::SigComponentType>::enumeration(
IO.enumCase(Value, E.Name.str().c_str(), E.Value);
}
+void ScalarEnumerationTraits<dxbc::ShaderVisibility>::enumeration(
+ IO &IO, dxbc::ShaderVisibility &Value) {
+ for (const auto &E : dxbc::getShaderVisibility())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::RootParameterType>::enumeration(
+ IO &IO, dxbc::RootParameterType &Value) {
+ for (const auto &E : dxbc::getRootParameterTypes())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::DescriptorRangeType>::enumeration(
+ IO &IO, dxbc::DescriptorRangeType &Value) {
+ for (const auto &E : dxbc::getDescriptorRangeTypes())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::SamplerFilter>::enumeration(
+ IO &IO, dxbc::SamplerFilter &Value) {
+ for (const auto &E : dxbc::getSamplerFilters())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::TextureAddressMode>::enumeration(
+ IO &IO, dxbc::TextureAddressMode &Value) {
+ for (const auto &E : dxbc::getTextureAddressModes())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::StaticBorderColor>::enumeration(
+ IO &IO, dxbc::StaticBorderColor &Value) {
+ for (const auto &E : dxbc::getStaticBorderColors())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::ComparisonFunc>::enumeration(
+ IO &IO, dxbc::ComparisonFunc &Value) {
+ for (const auto &E : dxbc::getComparisonFuncs())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
+void ScalarEnumerationTraits<dxbc::RootSignatureVersion>::enumeration(
+ IO &IO, dxbc::RootSignatureVersion &Value) {
+ for (const auto &E : dxbc::getRootSignatureVersions())
+ IO.enumCase(Value, E.Name.str().c_str(), E.Value);
+}
+
} // namespace yaml
void DXContainerYAML::PSVInfo::mapInfoForVersion(yaml::IO &IO) {
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 4d46d97d5e1df..ba5d08a76ee2a 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -17,6 +17,7 @@
#include "llvm/Analysis/DXILMetadataAnalysis.h"
#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/RootSignatureMetadata.h"
+#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
@@ -116,9 +117,13 @@ analyzeModule(Module &M) {
continue;
}
+ assert(hlsl::rootsig::verifyVersion(
+ static_cast<dxbc::RootSignatureVersion>(*V)));
+
llvm::hlsl::rootsig::MetadataParser MDParser(RootElementListNode);
llvm::Expected<mcdxbc::RootSignatureDesc> RSDOrErr =
- MDParser.ParseRootSignature(V.value());
+ MDParser.ParseRootSignature(
+ static_cast<dxbc::RootSignatureVersion>(*V));
if (!RSDOrErr) {
handleAllErrors(RSDOrErr.takeError(), [&](ErrorInfoBase &EIB) {
@@ -197,7 +202,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
RS.ParametersContainer.getRootDescriptor(Loc);
OS << " Register Space: " << Descriptor.RegisterSpace << "\n"
<< " Shader Register: " << Descriptor.ShaderRegister << "\n";
- if (RS.Version > 1)
+ if (RS.Version > dxbc::RootSignatureVersion::V1_0)
OS << " Flags: " << Descriptor.Flags << "\n";
break;
}
@@ -213,7 +218,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
<< " Num Descriptors: " << Range.NumDescriptors << "\n"
<< " Offset In Descriptors From Table Start: "
<< Range.OffsetInDescriptorsFromTableStart << "\n";
- if (RS.Version > 1)
+ if (RS.Version > dxbc::RootSignatureVersion::V1_0)
OS << " Flags: " << Range.Flags << "\n";
}
break;
diff --git a/llvm/unittests/Object/DXContainerTest.cpp b/llvm/unittests/Object/DXContainerTest.cpp
index 396d060a75bfd..f9fb464380a01 100644
--- a/llvm/unittests/Object/DXContainerTest.cpp
+++ b/llvm/unittests/Object/DXContainerTest.cpp
@@ -8,6 +8,7 @@
#include "llvm/Object/DXContainer.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
#include "llvm/ObjectYAML/yaml2obj.h"
@@ -848,7 +849,7 @@ TEST(RootSignature, RootParameters) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 2u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 36u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -856,8 +857,8 @@ TEST(RootSignature, RootParameters) {
ASSERT_EQ(RS.getFlags(), 17u);
auto RootParam = *RS.param_headers().begin();
- ASSERT_EQ((unsigned)RootParam.ParameterType, 1u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 2u);
+ ASSERT_EQ(RootParam.ParameterType, dxbc::RootParameterType::Constants32Bit);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Hull);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -889,7 +890,7 @@ TEST(RootSignature, ParseRootFlags) {
const auto &RS = C.getRootSignature();
ASSERT_TRUE(RS.has_value());
- ASSERT_EQ(RS->getVersion(), 2u);
+ ASSERT_EQ(RS->getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS->getNumParameters(), 0u);
ASSERT_EQ(RS->getRootParametersOffset(), 24u);
ASSERT_EQ(RS->getNumStaticSamplers(), 0u);
@@ -934,7 +935,7 @@ TEST(RootSignature, ParseRootConstant) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 2u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 24u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -943,7 +944,7 @@ TEST(RootSignature, ParseRootConstant) {
auto RootParam = *RS.param_headers().begin();
ASSERT_EQ((unsigned)RootParam.ParameterType, 1u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 2u);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Hull);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -981,7 +982,7 @@ TEST(RootSignature, ParseRootDescriptor) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 1u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_0);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 24u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -990,7 +991,7 @@ TEST(RootSignature, ParseRootDescriptor) {
auto RootParam = *RS.param_headers().begin();
ASSERT_EQ((unsigned)RootParam.ParameterType, 2u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 3u);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Domain);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -1025,7 +1026,7 @@ TEST(RootSignature, ParseRootDescriptor) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 2u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 24u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -1034,7 +1035,7 @@ TEST(RootSignature, ParseRootDescriptor) {
auto RootParam = *RS.param_headers().begin();
ASSERT_EQ((unsigned)RootParam.ParameterType, 2u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 3u);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Domain);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -1072,7 +1073,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 2u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 24u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -1081,7 +1082,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto RootParam = *RS.param_headers().begin();
ASSERT_EQ((unsigned)RootParam.ParameterType, 0u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 3u);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Domain);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -1096,7 +1097,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto Range = *Table->begin();
- ASSERT_EQ(Range.RangeType, 0u);
+ ASSERT_EQ(Range.RangeType, dxbc::DescriptorRangeType::SRV);
ASSERT_EQ(Range.NumDescriptors, -1u);
ASSERT_EQ(Range.BaseShaderRegister, 42u);
ASSERT_EQ(Range.RegisterSpace, 43u);
@@ -1124,7 +1125,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 1u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_0);
ASSERT_EQ(RS.getNumParameters(), 1u);
ASSERT_EQ(RS.getRootParametersOffset(), 24u);
ASSERT_EQ(RS.getNumStaticSamplers(), 0u);
@@ -1133,7 +1134,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto RootParam = *RS.param_headers().begin();
ASSERT_EQ((unsigned)RootParam.ParameterType, 0u);
- ASSERT_EQ((unsigned)RootParam.ShaderVisibility, 3u);
+ ASSERT_EQ(RootParam.ShaderVisibility, dxbc::ShaderVisibility::Domain);
auto ParamView = RS.getParameter(RootParam);
ASSERT_THAT_ERROR(ParamView.takeError(), Succeeded());
@@ -1148,7 +1149,7 @@ TEST(RootSignature, ParseDescriptorTable) {
auto Range = *Table->begin();
- ASSERT_EQ(Range.RangeType, 0u);
+ ASSERT_EQ(Range.RangeType, dxbc::DescriptorRangeType::SRV);
ASSERT_EQ(Range.NumDescriptors, -1u);
ASSERT_EQ(Range.BaseShaderRegister, 42u);
ASSERT_EQ(Range.RegisterSpace, 43u);
@@ -1177,7 +1178,7 @@ TEST(RootSignature, ParseStaticSamplers) {
auto MaybeRS = C.getRootSignature();
ASSERT_TRUE(MaybeRS.has_value());
const auto &RS = MaybeRS.value();
- ASSERT_EQ(RS.getVersion(), 2u);
+ ASSERT_EQ(RS.getVersion(), dxbc::RootSignatureVersion::V1_1);
ASSERT_EQ(RS.getNumParameters(), 0u);
ASSERT_EQ(RS.getRootParametersOffset(), 0u);
ASSERT_EQ(RS.getNumStaticSamplers(), 1u);
@@ -1186,18 +1187,18 @@ TEST(RootSignature, ParseStaticSamplers) {
auto Sampler = *RS.samplers().begin();
- ASSERT_EQ(Sampler.Filter, 10u);
- ASSERT_EQ(Sampler.AddressU, 1u);
- ASSERT_EQ(Sampler.AddressV, 2u);
- ASSERT_EQ(Sampler.AddressW, 5u);
+ ASSERT_EQ(Sampler.Filter, dxbc::SamplerFilter::MinLinearMagMipPoint);
+ ASSERT_EQ(Sampler.AddressU, dxbc::TextureAddressMode::Wrap);
+ ASSERT_EQ(Sampler.AddressV, dxbc::TextureAddressMode::Mirror);
+ ASSERT_EQ(Sampler.AddressW, dxbc::TextureAddressMode::MirrorOnce);
ASSERT_FLOAT_EQ(Sampler.MipLODBias, 1.23f);
ASSERT_EQ(Sampler.MaxAnisotropy, 20u);
- ASSERT_EQ(Sampler.ComparisonFunc, 4u);
- ASSERT_EQ(Sampler.BorderColor, 0u);
+ ASSERT_EQ(Sampler.ComparisonFunc, dxbc::ComparisonFunc::LessEqual);
+ ASSERT_EQ(Sampler.BorderColor, dxbc::StaticBorderColor::TransparentBlack);
ASSERT_FLOAT_EQ(Sampler.MinLOD, 4.56f);
ASSERT_FLOAT_EQ(Sampler.MaxLOD, 8.9f);
ASSERT_EQ(Sampler.ShaderRegister, 31u);
ASSERT_EQ(Sampler.RegisterSpace, 32u);
- ASSERT_EQ(Sampler.ShaderVisibility, 7u);
+ ASSERT_EQ(Sampler.ShaderVisibility, dxbc::ShaderVisibility::Mesh);
}
}
>From c975cc2c0ab9db6c1added27b9479e470d17c5db Mon Sep 17 00:00:00 2001
From: Joao Saffran <joaosaffranllvm at gmail.com>
Date: Mon, 18 Aug 2025 11:36:05 -0700
Subject: [PATCH 8/9] fix tests
---
.../Frontend/HLSL/RootSignatureMetadata.h | 7 +-
.../Frontend/HLSL/RootSignatureMetadata.cpp | 30 ++++--
...escriptorTable-AllValidFlagCombinations.ll | 34 +++---
...criptorTable-AllValidFlagCombinationsV1.ll | 10 +-
.../RootSignature-DescriptorTable.ll | 54 +++++-----
.../ContainerData/RootSignature-Flags.ll | 20 ++--
.../RootSignature-MultipleEntryFunctions.ll | 4 +-
.../ContainerData/RootSignature-Parameters.ll | 18 ++--
.../RootSignature-RootConstants.ll | 30 +++---
.../RootSignature-RootDescriptor.ll | 30 +++---
.../RootSignature-RootDescriptor_V1.ll | 29 +++--
.../RootSignature-StaticSamplers.ll | 46 ++++----
.../RootSignature-Descriptor1.0.yaml | 38 +++----
.../RootSignature-Descriptor1.1.yaml | 40 +++----
.../RootSignature-DescriptorTable1.0.yaml | 52 ++++-----
.../RootSignature-DescriptorTable1.1.yaml | 54 +++++-----
.../DXContainer/RootSignature-Flags.yaml | 4 +-
.../RootSignature-InvalidType.yaml | 29 -----
.../RootSignature-InvalidVisibility.yaml | 33 ------
.../RootSignature-MultipleParameters.yaml | 102 +++++++++---------
...RootSignature-StaticSamplers-Defaults.yaml | 34 +++---
.../RootSignature-StaticSamplers.yaml | 34 +++---
llvm/unittests/Object/DXContainerTest.cpp | 2 +-
.../ObjectYAML/DXContainerYAMLTest.cpp | 60 +++++------
24 files changed, 371 insertions(+), 423 deletions(-)
delete mode 100644 llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidType.yaml
delete mode 100644 llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidVisibility.yaml
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
index 3ca1ebcc90bde..0a5b6b600688e 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
@@ -19,6 +19,7 @@
#include "llvm/IR/Constants.h"
#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Support/Compiler.h"
+#include <cstdint>
namespace llvm {
class LLVMContext;
@@ -28,9 +29,9 @@ class Metadata;
namespace hlsl {
namespace rootsig {
-template <typename T>
+template <typename T, typename ET = T>
class RootSignatureValidationError
- : public ErrorInfo<RootSignatureValidationError<T>> {
+ : public ErrorInfo<RootSignatureValidationError<T, ET>> {
public:
static char ID;
StringRef ParamName;
@@ -40,7 +41,7 @@ class RootSignatureValidationError
: ParamName(ParamName), Value(Value) {}
void log(raw_ostream &OS) const override {
- OS << "Invalid value for " << ParamName << ": " << Value;
+ OS << "Invalid value for " << ParamName << ": " << static_cast<ET>(Value);
}
std::error_code convertToErrorCode() const override {
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index 5d2d02b344309..349303148f19b 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -17,6 +17,7 @@
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/ScopedPrinter.h"
+#include <cstdint>
using namespace llvm;
@@ -27,7 +28,7 @@ namespace rootsig {
char GenericRSMetadataError::ID;
char InvalidRSMetadataFormat::ID;
char InvalidRSMetadataValue::ID;
-template <typename T> char RootSignatureValidationError<T>::ID;
+template <typename T, typename ET> char RootSignatureValidationError<T, ET>::ID;
static std::optional<uint32_t> extractMdIntValue(MDNode *Node,
unsigned int OpId) {
@@ -331,7 +332,8 @@ Error MetadataParser::parseDescriptorRange(mcdxbc::DescriptorTable &Table,
.Case("CBV", dxbc::DescriptorRangeType::CBV)
.Case("SRV", dxbc::DescriptorRangeType::SRV)
.Case("UAV", dxbc::DescriptorRangeType::UAV)
- .Case("Sampler", dxbc::DescriptorRangeType::Sampler);
+ .Case("Sampler", dxbc::DescriptorRangeType::Sampler)
+ .Default(static_cast<dxbc::DescriptorRangeType>(-1));
if (!verifyRangeType(Range.RangeType))
return make_error<GenericRSMetadataError>("Invalid Descriptor Range type.",
@@ -532,7 +534,8 @@ Error MetadataParser::validateRootSignature(
if (!dxbc::isValidShaderVisibility(Info.Header.ShaderVisibility))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::ShaderVisibility>>(
+ make_error<
+ RootSignatureValidationError<dxbc::ShaderVisibility, uint32_t>>(
"ShaderVisibility", Info.Header.ShaderVisibility));
assert(dxbc::isValidParameterType(Info.Header.ParameterType) &&
@@ -610,25 +613,29 @@ Error MetadataParser::validateRootSignature(
if (!hlsl::rootsig::verifySamplerFilter(Sampler.Filter))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::SamplerFilter>>(
+ make_error<
+ RootSignatureValidationError<dxbc::SamplerFilter, uint32_t>>(
"Filter", Sampler.Filter));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressU))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ make_error<
+ RootSignatureValidationError<dxbc::TextureAddressMode, uint32_t>>(
"AddressU", Sampler.AddressU));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressV))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ make_error<
+ RootSignatureValidationError<dxbc::TextureAddressMode, uint32_t>>(
"AddressV", Sampler.AddressV));
if (!hlsl::rootsig::verifyAddress(Sampler.AddressW))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::TextureAddressMode>>(
+ make_error<
+ RootSignatureValidationError<dxbc::TextureAddressMode, uint32_t>>(
"AddressW", Sampler.AddressW));
if (!hlsl::rootsig::verifyMipLODBias(Sampler.MipLODBias))
@@ -645,13 +652,15 @@ Error MetadataParser::validateRootSignature(
if (!hlsl::rootsig::verifyComparisonFunc(Sampler.ComparisonFunc))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::ComparisonFunc>>(
+ make_error<
+ RootSignatureValidationError<dxbc::ComparisonFunc, uint32_t>>(
"ComparisonFunc", Sampler.ComparisonFunc));
if (!hlsl::rootsig::verifyBorderColor(Sampler.BorderColor))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::StaticBorderColor>>(
+ make_error<
+ RootSignatureValidationError<dxbc::StaticBorderColor, uint32_t>>(
"BorderColor", Sampler.BorderColor));
if (!hlsl::rootsig::verifyLOD(Sampler.MinLOD))
@@ -679,7 +688,8 @@ Error MetadataParser::validateRootSignature(
if (!dxbc::isValidShaderVisibility(Sampler.ShaderVisibility))
DeferredErrs = joinErrors(
std::move(DeferredErrs),
- make_error<RootSignatureValidationError<dxbc::ShaderVisibility>>(
+ make_error<
+ RootSignatureValidationError<dxbc::ShaderVisibility, uint32_t>>(
"ShaderVisibility", Sampler.ShaderVisibility));
}
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinations.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinations.ll
index 8eb7f90c6b757..e8aa5cfc80bb8 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinations.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinations.ll
@@ -55,100 +55,100 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;DXC:- Name: RTS0
;DXC-NEXT: Size: 380
;DXC-NEXT: RootSignature:
-;DXC-NEXT: Version: 2
+;DXC-NEXT: Version: V1_1
;DXC-NEXT: NumRootParameters: 1
;DXC-NEXT: RootParametersOffset: 24
;DXC-NEXT: NumStaticSamplers: 0
;DXC-NEXT: StaticSamplersOffset: 0
;DXC-NEXT: Parameters:
-;DXC-NEXT: - ParameterType: 0
-;DXC-NEXT: ShaderVisibility: 0
+;DXC-NEXT: - ParameterType: DescriptorTable
+;DXC-NEXT: ShaderVisibility: All
;DXC-NEXT: Table:
;DXC-NEXT: NumRanges: 14
;DXC-NEXT: RangesOffset: 44
;DXC-NEXT: Ranges:
-;DXC-NEXT: - RangeType: 3
+;DXC-NEXT: - RangeType: Sampler
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 1
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
-;DXC-NEXT: - RangeType: 3
+;DXC-NEXT: - RangeType: Sampler
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 3
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
-;DXC-NEXT: - RangeType: 3
+;DXC-NEXT: - RangeType: Sampler
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 4
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
-;DXC-NEXT: - RangeType: 0
+;DXC-NEXT: - RangeType: SRV
;DXC-NEXT: NumDescriptors: 1
;DXC-NEXT: BaseShaderRegister: 0
;DXC-NEXT: RegisterSpace: 5
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
-;DXC-NEXT: - RangeType: 1
+;DXC-NEXT: - RangeType: UAV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 6
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
-;DXC-NEXT: - RangeType: 2
+;DXC-NEXT: - RangeType: CBV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 7
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_VOLATILE: true
-;DXC-NEXT: - RangeType: 0
+;DXC-NEXT: - RangeType: SRV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 8
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_STATIC: true
-;DXC-NEXT: - RangeType: 1
+;DXC-NEXT: - RangeType: UAV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 9
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-;DXC-NEXT: - RangeType: 2
+;DXC-NEXT: - RangeType: CBV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 10
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
;DXC-NEXT: DATA_VOLATILE: true
-;DXC-NEXT: - RangeType: 0
+;DXC-NEXT: - RangeType: SRV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 11
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DESCRIPTORS_VOLATILE: true
;DXC-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-;DXC-NEXT: - RangeType: 1
+;DXC-NEXT: - RangeType: UAV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 12
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
-;DXC-NEXT: - RangeType: 2
+;DXC-NEXT: - RangeType: CBV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 13
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_VOLATILE: true
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
-;DXC-NEXT: - RangeType: 0
+;DXC-NEXT: - RangeType: SRV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 14
;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
;DXC-NEXT: DATA_STATIC: true
;DXC-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
-;DXC-NEXT: - RangeType: 1
+;DXC-NEXT: - RangeType: UAV
;DXC-NEXT: NumDescriptors: 5
;DXC-NEXT: BaseShaderRegister: 1
;DXC-NEXT: RegisterSpace: 15
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinationsV1.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinationsV1.ll
index 053721de1eb1f..042a557584c1a 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinationsV1.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable-AllValidFlagCombinationsV1.ll
@@ -20,24 +20,24 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; DXC: - Name: RTS0
; DXC-NEXT: Size: 84
; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 1
+; DXC-NEXT: Version: V1_0
; DXC-NEXT: NumRootParameters: 1
; DXC-NEXT: RootParametersOffset: 24
; DXC-NEXT: NumStaticSamplers: 0
; DXC-NEXT: StaticSamplersOffset: 0
; DXC-NEXT: Parameters:
-; DXC-NEXT: - ParameterType: 0
-; DXC-NEXT: ShaderVisibility: 0
+; DXC-NEXT: - ParameterType: DescriptorTable
+; DXC-NEXT: ShaderVisibility: All
; DXC-NEXT: Table:
; DXC-NEXT: NumRanges: 2
; DXC-NEXT: RangesOffset: 44
; DXC-NEXT: Ranges:
-; DXC-NEXT: - RangeType: 3
+; DXC-NEXT: - RangeType: Sampler
; DXC-NEXT: NumDescriptors: 1
; DXC-NEXT: BaseShaderRegister: 1
; DXC-NEXT: RegisterSpace: 0
; DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
-; DXC-NEXT: - RangeType: 1
+; DXC-NEXT: - RangeType: UAV
; DXC-NEXT: NumDescriptors: 5
; DXC-NEXT: BaseShaderRegister: 1
; DXC-NEXT: RegisterSpace: 10
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable.ll
index 8e9b4b43b11a6..ea499df28db80 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-DescriptorTable.ll
@@ -19,30 +19,30 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!6 = !{ !"SRV", i32 1, i32 1, i32 0, i32 -1, i32 4 }
!7 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 92
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 2
-; DXC-NEXT: NumRootParameters: 1
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 0
-; DXC-NEXT: StaticSamplersOffset: 0
-; DXC-NEXT: Parameters:
-; DXC-NEXT: - ParameterType: 0
-; DXC-NEXT: ShaderVisibility: 0
-; DXC-NEXT: Table:
-; DXC-NEXT: NumRanges: 2
-; DXC-NEXT: RangesOffset: 44
-; DXC-NEXT: Ranges:
-; DXC-NEXT: - RangeType: 0
-; DXC-NEXT: NumDescriptors: 1
-; DXC-NEXT: BaseShaderRegister: 1
-; DXC-NEXT: RegisterSpace: 0
-; DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
-; DXC-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-; DXC-NEXT: - RangeType: 1
-; DXC-NEXT: NumDescriptors: 5
-; DXC-NEXT: BaseShaderRegister: 1
-; DXC-NEXT: RegisterSpace: 10
-; DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
-; DXC-NEXT: DATA_VOLATILE: true
+;DXC: - Name: RTS0
+;DXC-NEXT: Size: 92
+;DXC-NEXT: RootSignature:
+;DXC-NEXT: Version: V1_1
+;DXC-NEXT: NumRootParameters: 1
+;DXC-NEXT: RootParametersOffset: 24
+;DXC-NEXT: NumStaticSamplers: 0
+;DXC-NEXT: StaticSamplersOffset: 0
+;DXC-NEXT: Parameters:
+;DXC-NEXT: - ParameterType: DescriptorTable
+;DXC-NEXT: ShaderVisibility: All
+;DXC-NEXT: Table:
+;DXC-NEXT: NumRanges: 2
+;DXC-NEXT: RangesOffset: 44
+;DXC-NEXT: Ranges:
+;DXC-NEXT: - RangeType: SRV
+;DXC-NEXT: NumDescriptors: 1
+;DXC-NEXT: BaseShaderRegister: 1
+;DXC-NEXT: RegisterSpace: 0
+;DXC-NEXT: OffsetInDescriptorsFromTableStart: 4294967295
+;DXC-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
+;DXC-NEXT: - RangeType: UAV
+;DXC-NEXT: NumDescriptors: 5
+;DXC-NEXT: BaseShaderRegister: 1
+;DXC-NEXT: RegisterSpace: 10
+;DXC-NEXT: OffsetInDescriptorsFromTableStart: 5
+;DXC-NEXT: DATA_VOLATILE: true
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
index 10235b7d17960..de7cf95e94b68 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Flags.ll
@@ -18,13 +18,13 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!4 = !{ !"RootFlags", i32 1 } ; 1 = allow_input_assembler_input_layout
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 24
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 2
-; DXC-NEXT: NumRootParameters: 0
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 0
-; DXC-NEXT: StaticSamplersOffset: 0
-; DXC-NEXT: Parameters: []
-; DXC-NEXT: AllowInputAssemblerInputLayout: true
+;DXC: - Name: RTS0
+;DXC-NEXT: Size: 24
+;DXC-NEXT: RootSignature:
+;DXC-NEXT: Version: V1_1
+;DXC-NEXT: NumRootParameters: 0
+;DXC-NEXT: RootParametersOffset: 24
+;DXC-NEXT: NumStaticSamplers: 0
+;DXC-NEXT: StaticSamplersOffset: 0
+;DXC-NEXT: Parameters: []
+;DXC-NEXT: AllowInputAssemblerInputLayout: true
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
index fec9c226d8bc5..f3e374e4b0a44 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
@@ -25,7 +25,7 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; CHECK-LABEL: Definition for 'main':
; CHECK-NEXT: Flags: 0x000001
-; CHECK-NEXT: Version: 2
+; CHECK-NEXT: Version: 0x2
; CHECK-NEXT: RootParametersOffset: 24
; CHECK-NEXT: NumParameters: 0
; CHECK-NEXT: NumStaticSamplers: 0
@@ -33,7 +33,7 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; CHECK-LABEL: Definition for 'anotherMain':
; CHECK-NEXT: Flags: 0x000002
-; CHECK-NEXT: Version: 2
+; CHECK-NEXT: Version: 0x2
; CHECK-NEXT: RootParametersOffset: 24
; CHECK-NEXT: NumParameters: 0
; CHECK-NEXT: NumStaticSamplers: 0
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
index 6477ad397c32d..a0171d0160ed5 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
@@ -22,29 +22,29 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
;CHECK-LABEL: Definition for 'main':
;CHECK-NEXT: Flags: 0x000001
-;CHECK-NEXT: Version: 2
+;CHECK-NEXT: Version: 0x2
;CHECK-NEXT: RootParametersOffset: 24
;CHECK-NEXT: NumParameters: 3
-;CHECK-NEXT: - Parameter Type: 1
-;CHECK-NEXT: Shader Visibility: 0
+;CHECK-NEXT: - Parameter Type: 0x1
+;CHECK-NEXT: Shader Visibility: 0x0
;CHECK-NEXT: Register Space: 2
;CHECK-NEXT: Shader Register: 1
;CHECK-NEXT: Num 32 Bit Values: 3
-;CHECK-NEXT: - Parameter Type: 3
-;CHECK-NEXT: Shader Visibility: 1
+;CHECK-NEXT: - Parameter Type: 0x3
+;CHECK-NEXT: Shader Visibility: 0x1
;CHECK-NEXT: Register Space: 5
;CHECK-NEXT: Shader Register: 4
;CHECK-NEXT: Flags: 4
-;CHECK-NEXT: - Parameter Type: 0
-;CHECK-NEXT: Shader Visibility: 0
+;CHECK-NEXT: - Parameter Type: 0x0
+;CHECK-NEXT: Shader Visibility: 0x0
;CHECK-NEXT: NumRanges: 2
-;CHECK-NEXT: - Range Type: 0
+;CHECK-NEXT: - Range Type: 0x0
;CHECK-NEXT: Register Space: 0
;CHECK-NEXT: Base Shader Register: 1
;CHECK-NEXT: Num Descriptors: 1
;CHECK-NEXT: Offset In Descriptors From Table Start: 4294967295
;CHECK-NEXT: Flags: 4
-;CHECK-NEXT: - Range Type: 1
+;CHECK-NEXT: - Range Type: 0x1
;CHECK-NEXT: Register Space: 10
;CHECK-NEXT: Base Shader Register: 1
;CHECK-NEXT: Num Descriptors: 5
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootConstants.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootConstants.ll
index 964554fe143ef..71b76eaa50469 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootConstants.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootConstants.ll
@@ -17,18 +17,18 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"RootConstants", i32 0, i32 1, i32 2, i32 3 }
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 48
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 2
-; DXC-NEXT: NumRootParameters: 1
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 0
-; DXC-NEXT: StaticSamplersOffset: 0
-; DXC-NEXT: Parameters:
-; DXC-NEXT: - ParameterType: 1
-; DXC-NEXT: ShaderVisibility: 0
-; DXC-NEXT: Constants:
-; DXC-NEXT: Num32BitValues: 3
-; DXC-NEXT: RegisterSpace: 2
-; DXC-NEXT: ShaderRegister: 1
+; DXC: - Name: RTS0
+; DXC-NEXT: Size: 48
+; DXC-NEXT: RootSignature:
+; DXC-NEXT: Version: V1_1
+; DXC-NEXT: NumRootParameters: 1
+; DXC-NEXT: RootParametersOffset: 24
+; DXC-NEXT: NumStaticSamplers: 0
+; DXC-NEXT: StaticSamplersOffset: 0
+; DXC-NEXT: Parameters:
+; DXC-NEXT: - ParameterType: Constants32Bit
+; DXC-NEXT: ShaderVisibility: All
+; DXC-NEXT: Constants:
+; DXC-NEXT: Num32BitValues: 3
+; DXC-NEXT: RegisterSpace: 2
+; DXC-NEXT: ShaderRegister: 1
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor.ll
index f77bb96840bea..3eee26bc7ac5d 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor.ll
@@ -17,18 +17,18 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"RootCBV", i32 0, i32 1, i32 2, i32 8 }
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 48
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 2
-; DXC-NEXT: NumRootParameters: 1
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 0
-; DXC-NEXT: StaticSamplersOffset: 0
-; DXC-NEXT: Parameters:
-; DXC-NEXT: - ParameterType: 2
-; DXC-NEXT: ShaderVisibility: 0
-; DXC-NEXT: Descriptor:
-; DXC-NEXT: RegisterSpace: 2
-; DXC-NEXT: ShaderRegister: 1
-; DXC-NEXT: DATA_STATIC: true
+;DXC: - Name: RTS0
+;DXC-NEXT: Size: 48
+;DXC-NEXT: RootSignature:
+;DXC-NEXT: Version: V1_1
+;DXC-NEXT: NumRootParameters: 1
+;DXC-NEXT: RootParametersOffset: 24
+;DXC-NEXT: NumStaticSamplers: 0
+;DXC-NEXT: StaticSamplersOffset: 0
+;DXC-NEXT: Parameters:
+;DXC-NEXT: - ParameterType: CBV
+;DXC-NEXT: ShaderVisibility: All
+;DXC-NEXT: Descriptor:
+;DXC-NEXT: RegisterSpace: 2
+;DXC-NEXT: ShaderRegister: 1
+;DXC-NEXT: DATA_STATIC: true
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor_V1.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor_V1.ll
index ddf556e7fe20a..20377ca921127 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor_V1.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-RootDescriptor_V1.ll
@@ -17,18 +17,17 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"RootCBV", i32 0, i32 1, i32 2, i32 2 }
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 44
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 1
-; DXC-NEXT: NumRootParameters: 1
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 0
-; DXC-NEXT: StaticSamplersOffset: 0
-; DXC-NEXT: Parameters:
-; DXC-NEXT: - ParameterType: 2
-; DXC-NEXT: ShaderVisibility: 0
-; DXC-NEXT: Descriptor:
-; DXC-NEXT: RegisterSpace: 2
-; DXC-NEXT: ShaderRegister: 1
-; DXC-NOT: DATA_VOLATILE: true
+;DXC: - Name: RTS0
+;DXC-NEXT: Size: 44
+;DXC-NEXT: RootSignature:
+;DXC-NEXT: Version: V1_0
+;DXC-NEXT: NumRootParameters: 1
+;DXC-NEXT: RootParametersOffset: 24
+;DXC-NEXT: NumStaticSamplers: 0
+;DXC-NEXT: StaticSamplersOffset: 0
+;DXC-NEXT: Parameters:
+;DXC-NEXT: - ParameterType: CBV
+;DXC-NEXT: ShaderVisibility: All
+;DXC-NEXT: Descriptor:
+;DXC-NEXT: RegisterSpace: 2
+;DXC-NEXT: ShaderRegister: 1
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll
index d9ee39dbb7287..37e533785af5b 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-StaticSamplers.ll
@@ -17,26 +17,26 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!3 = !{ !5 } ; list of root signature elements
!5 = !{ !"StaticSampler", i32 4, i32 2, i32 3, i32 5, float 0x3FF6CCCCC0000000, i32 9, i32 3, i32 2, float -1.280000e+02, float 1.280000e+02, i32 42, i32 0, i32 0 }
-; DXC: - Name: RTS0
-; DXC-NEXT: Size: 76
-; DXC-NEXT: RootSignature:
-; DXC-NEXT: Version: 2
-; DXC-NEXT: NumRootParameters: 0
-; DXC-NEXT: RootParametersOffset: 24
-; DXC-NEXT: NumStaticSamplers: 1
-; DXC-NEXT: StaticSamplersOffset: 24
-; DXC-NEXT: Parameters: []
-; DXC-NEXT: Samplers:
-; DXC-NEXT: - Filter: 4
-; DXC-NEXT: AddressU: 2
-; DXC-NEXT: AddressV: 3
-; DXC-NEXT: AddressW: 5
-; DXC-NEXT: MipLODBias: 1.425
-; DXC-NEXT: MaxAnisotropy: 9
-; DXC-NEXT: ComparisonFunc: 3
-; DXC-NEXT: BorderColor: 2
-; DXC-NEXT: MinLOD: -128
-; DXC-NEXT: MaxLOD: 128
-; DXC-NEXT: ShaderRegister: 42
-; DXC-NEXT: RegisterSpace: 0
-; DXC-NEXT: ShaderVisibility: 0
+;DXC: - Name: RTS0
+;DXC-NEXT: Size: 76
+;DXC-NEXT: RootSignature:
+;DXC-NEXT: Version: V1_1
+;DXC-NEXT: NumRootParameters: 0
+;DXC-NEXT: RootParametersOffset: 24
+;DXC-NEXT: NumStaticSamplers: 1
+;DXC-NEXT: StaticSamplersOffset: 24
+;DXC-NEXT: Parameters: []
+;DXC-NEXT: Samplers:
+;DXC-NEXT: - Filter: MinPointMagLinearMipPoint
+;DXC-NEXT: AddressU: Mirror
+;DXC-NEXT: AddressV: Clamp
+;DXC-NEXT: AddressW: MirrorOnce
+;DXC-NEXT: MipLODBias: 1.425
+;DXC-NEXT: MaxAnisotropy: 9
+;DXC-NEXT: ComparisonFunc: Equal
+;DXC-NEXT: BorderColor: OpaqueWhite
+;DXC-NEXT: MinLOD: -128
+;DXC-NEXT: MaxLOD: 128
+;DXC-NEXT: ShaderRegister: 42
+;DXC-NEXT: RegisterSpace: 0
+;DXC-NEXT: ShaderVisibility: All
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.0.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.0.yaml
index 889eccf74001f..fafaa63a95bd9 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.0.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.0.yaml
@@ -13,33 +13,33 @@ Parts:
- Name: RTS0
Size: 96
RootSignature:
- Version: 1
+ Version: V1_0
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 2 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: CBV
+ ShaderVisibility: Domain
Descriptor:
ShaderRegister: 31
RegisterSpace: 32
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 96
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 1
-# CHECK-NEXT: NumRootParameters: 1
-# CHECK-NEXT: RootParametersOffset: 24
-# CHECK-NEXT: NumStaticSamplers: 0
-# CHECK-NEXT: StaticSamplersOffset: 60
-# CHECK-NEXT: Parameters:
-# CHECK-NEXT: - ParameterType: 2
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Descriptor:
-# CHECK-NEXT: RegisterSpace: 32
-# CHECK-NEXT: ShaderRegister: 31
-# CHECK-NEXT: AllowInputAssemblerInputLayout: true
-# CHECK-NEXT: DenyGeometryShaderRootAccess: true
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 96
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: V1_0
+#CHECK-NEXT: NumRootParameters: 1
+#CHECK-NEXT: RootParametersOffset: 24
+#CHECK-NEXT: NumStaticSamplers: 0
+#CHECK-NEXT: StaticSamplersOffset: 60
+#CHECK-NEXT: Parameters:
+#CHECK-NEXT: - ParameterType: CBV
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Descriptor:
+#CHECK-NEXT: RegisterSpace: 32
+#CHECK-NEXT: ShaderRegister: 31
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.1.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.1.yaml
index 64e01c6836e32..ad95347b9f337 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.1.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-Descriptor1.1.yaml
@@ -13,14 +13,14 @@ Parts:
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 2 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: CBV
+ ShaderVisibility: Domain
Descriptor:
ShaderRegister: 31
RegisterSpace: 32
@@ -28,20 +28,20 @@ Parts:
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 89
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 2
-# CHECK-NEXT: NumRootParameters: 1
-# CHECK-NEXT: RootParametersOffset: 24
-# CHECK-NEXT: NumStaticSamplers: 0
-# CHECK-NEXT: StaticSamplersOffset: 60
-# CHECK-NEXT: Parameters:
-# CHECK-NEXT: - ParameterType: 2
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Descriptor:
-# CHECK-NEXT: RegisterSpace: 32
-# CHECK-NEXT: ShaderRegister: 31
-# CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-# CHECK-NEXT: AllowInputAssemblerInputLayout: true
-# CHECK-NEXT: DenyGeometryShaderRootAccess: true
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 89
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: V1_1
+#CHECK-NEXT: NumRootParameters: 1
+#CHECK-NEXT: RootParametersOffset: 24
+#CHECK-NEXT: NumStaticSamplers: 0
+#CHECK-NEXT: StaticSamplersOffset: 60
+#CHECK-NEXT: Parameters:
+#CHECK-NEXT: - ParameterType: CBV
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Descriptor:
+#CHECK-NEXT: RegisterSpace: 32
+#CHECK-NEXT: ShaderRegister: 31
+#CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.0.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.0.yaml
index 0441bb7a256b1..f318ed6e8f89d 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.0.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.0.yaml
@@ -14,18 +14,18 @@ Parts:
- Name: RTS0
Size: 89
RootSignature:
- Version: 1
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 0 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: DescriptorTable
+ ShaderVisibility: Domain
Table:
NumRanges: 1
Ranges:
- - RangeType: 0
+ - RangeType: SRV
NumDescriptors: -1
BaseShaderRegister: 42
RegisterSpace: 43
@@ -33,25 +33,25 @@ Parts:
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 89
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 1
-# CHECK-NEXT: NumRootParameters: 1
-# CHECK-NEXT: RootParametersOffset: 24
-# CHECK-NEXT: NumStaticSamplers: 0
-# CHECK-NEXT: StaticSamplersOffset: 60
-# CHECK-NEXT: Parameters:
-# CHECK-NEXT: - ParameterType: 0
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Table:
-# CHECK-NEXT: NumRanges: 1
-# CHECK-NEXT: RangesOffset: 44
-# CHECK-NEXT: Ranges:
-# CHECK-NEXT: - RangeType: 0
-# CHECK-NEXT: NumDescriptors: -1
-# CHECK-NEXT: BaseShaderRegister: 42
-# CHECK-NEXT: RegisterSpace: 43
-# CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
-# CHECK-NEXT: AllowInputAssemblerInputLayout: true
-# CHECK-NEXT: DenyGeometryShaderRootAccess: true
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 89
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: V1_1
+#CHECK-NEXT: NumRootParameters: 1
+#CHECK-NEXT: RootParametersOffset: 24
+#CHECK-NEXT: NumStaticSamplers: 0
+#CHECK-NEXT: StaticSamplersOffset: 60
+#CHECK-NEXT: Parameters:
+#CHECK-NEXT: - ParameterType: DescriptorTable
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Table:
+#CHECK-NEXT: NumRanges: 1
+#CHECK-NEXT: RangesOffset: 44
+#CHECK-NEXT: Ranges:
+#CHECK-NEXT: - RangeType: SRV
+#CHECK-NEXT: NumDescriptors: -1
+#CHECK-NEXT: BaseShaderRegister: 42
+#CHECK-NEXT: RegisterSpace: 43
+#CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.1.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.1.yaml
index d06be5e181418..e1442790dab2b 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.1.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-DescriptorTable1.1.yaml
@@ -14,18 +14,18 @@ Parts:
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 0 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: DescriptorTable
+ ShaderVisibility: Domain
Table:
NumRanges: 1
Ranges:
- - RangeType: 0
+ - RangeType: SRV
NumDescriptors: -1
BaseShaderRegister: 42
RegisterSpace: 43
@@ -34,26 +34,26 @@ Parts:
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 89
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 2
-# CHECK-NEXT: NumRootParameters: 1
-# CHECK-NEXT: RootParametersOffset: 24
-# CHECK-NEXT: NumStaticSamplers: 0
-# CHECK-NEXT: StaticSamplersOffset: 60
-# CHECK-NEXT: Parameters:
-# CHECK-NEXT: - ParameterType: 0
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Table:
-# CHECK-NEXT: NumRanges: 1
-# CHECK-NEXT: RangesOffset: 44
-# CHECK-NEXT: Ranges:
-# CHECK-NEXT: - RangeType: 0
-# CHECK-NEXT: NumDescriptors: -1
-# CHECK-NEXT: BaseShaderRegister: 42
-# CHECK-NEXT: RegisterSpace: 43
-# CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
-# CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-# CHECK-NEXT: AllowInputAssemblerInputLayout: true
-# CHECK-NEXT: DenyGeometryShaderRootAccess: true
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 89
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: V1_1
+#CHECK-NEXT: NumRootParameters: 1
+#CHECK-NEXT: RootParametersOffset: 24
+#CHECK-NEXT: NumStaticSamplers: 0
+#CHECK-NEXT: StaticSamplersOffset: 60
+#CHECK-NEXT: Parameters:
+#CHECK-NEXT: - ParameterType: DescriptorTable
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Table:
+#CHECK-NEXT: NumRanges: 1
+#CHECK-NEXT: RangesOffset: 44
+#CHECK-NEXT: Ranges:
+#CHECK-NEXT: - RangeType: SRV
+#CHECK-NEXT: NumDescriptors: -1
+#CHECK-NEXT: BaseShaderRegister: 42
+#CHECK-NEXT: RegisterSpace: 43
+#CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
+#CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml
index 74816d403183a..ea210e82325c7 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-Flags.yaml
@@ -13,7 +13,7 @@ Parts:
- Name: RTS0
Size: 24
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 0
RootParametersOffset: 24
NumStaticSamplers: 0
@@ -25,7 +25,7 @@ Parts:
# CHECK: - Name: RTS0
# CHECK-NEXT: Size: 24
# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 2
+# CHECK-NEXT: Version: V1_1
# CHECK-NEXT: NumRootParameters: 0
# CHECK-NEXT: RootParametersOffset: 24
# CHECK-NEXT: NumStaticSamplers: 0
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidType.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidType.yaml
deleted file mode 100644
index 091e70789d956..0000000000000
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidType.yaml
+++ /dev/null
@@ -1,29 +0,0 @@
-# RUN: yaml2obj %s -o %t
-# RUN: not obj2yaml 2>&1 %t | FileCheck %s -DFILE=%t
-
-# CHECK: Error reading file: [[FILE]]: Invalid value for parameter type
-
-
---- !dxcontainer
-Header:
- Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
- Version:
- Major: 1
- Minor: 0
- PartCount: 1
- PartOffsets: [ 60 ]
-Parts:
- - Name: RTS0
- Size: 80
- RootSignature:
- Version: 2
- NumRootParameters: 2
- RootParametersOffset: 24
- NumStaticSamplers: 0
- StaticSamplersOffset: 64
- Parameters:
- - ParameterType: 255 # INVALID
- ShaderVisibility: 2 # Hull
- AllowInputAssemblerInputLayout: true
- DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidVisibility.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidVisibility.yaml
deleted file mode 100644
index 1acaf6e4e08a4..0000000000000
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-InvalidVisibility.yaml
+++ /dev/null
@@ -1,33 +0,0 @@
-# RUN: yaml2obj %s -o %t
-# RUN: not obj2yaml 2>&1 %t | FileCheck %s -DFILE=%t
-
-# CHECK: Error reading file: [[FILE]]: Invalid value for shader visibility
-
-
---- !dxcontainer
-Header:
- Hash: [ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
- 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 ]
- Version:
- Major: 1
- Minor: 0
- PartCount: 1
- PartOffsets: [ 60 ]
-Parts:
- - Name: RTS0
- Size: 80
- RootSignature:
- Version: 2
- NumRootParameters: 2
- RootParametersOffset: 24
- NumStaticSamplers: 0
- StaticSamplersOffset: 64
- Parameters:
- - ParameterType: 1 # Constants32Bit
- ShaderVisibility: 255 # INVALID
- Constants:
- Num32BitValues: 21
- ShaderRegister: 22
- RegisterSpace: 23
- AllowInputAssemblerInputLayout: true
- DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-MultipleParameters.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-MultipleParameters.yaml
index 947fc096a9207..c299e249f5c6f 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-MultipleParameters.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-MultipleParameters.yaml
@@ -13,36 +13,36 @@ Parts:
- Name: RTS0
Size: 200
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 3
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 1 # Constants32Bit
- ShaderVisibility: 2 # Hull
+ - ParameterType: Constants32Bit
+ ShaderVisibility: Hull
Constants:
Num32BitValues: 16
ShaderRegister: 15
RegisterSpace: 14
- - ParameterType: 1 # Constants32Bit
- ShaderVisibility: 4 # Geometry
+ - ParameterType: Constants32Bit
+ ShaderVisibility: Geometry
Constants:
Num32BitValues: 21
ShaderRegister: 22
RegisterSpace: 23
- - ParameterType: 2 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: SRV
+ ShaderVisibility: Domain
Descriptor:
ShaderRegister: 31
RegisterSpace: 32
DATA_STATIC_WHILE_SET_AT_EXECUTE: true
- - ParameterType: 0 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: DescriptorTable
+ ShaderVisibility: Domain
Table:
NumRanges: 1
Ranges:
- - RangeType: 0
+ - RangeType: SRV
NumDescriptors: -1
BaseShaderRegister: 42
RegisterSpace: 43
@@ -51,44 +51,44 @@ Parts:
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-# CHECK: - Name: RTS0
-# CHECK-NEXT: Size: 200
-# CHECK-NEXT: RootSignature:
-# CHECK-NEXT: Version: 2
-# CHECK-NEXT: NumRootParameters: 4
-# CHECK-NEXT: RootParametersOffset: 24
-# CHECK-NEXT: NumStaticSamplers: 0
-# CHECK-NEXT: StaticSamplersOffset: 60
-# CHECK-NEXT: Parameters:
-# CHECK-NEXT: - ParameterType: 1
-# CHECK-NEXT: ShaderVisibility: 2
-# CHECK-NEXT: Constants:
-# CHECK-NEXT: Num32BitValues: 16
-# CHECK-NEXT: RegisterSpace: 14
-# CHECK-NEXT: ShaderRegister: 15
-# CHECK-NEXT: - ParameterType: 1
-# CHECK-NEXT: ShaderVisibility: 4
-# CHECK-NEXT: Constants:
-# CHECK-NEXT: Num32BitValues: 21
-# CHECK-NEXT: RegisterSpace: 23
-# CHECK-NEXT: ShaderRegister: 22
-# CHECK-NEXT: - ParameterType: 2
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Descriptor:
-# CHECK-NEXT: RegisterSpace: 32
-# CHECK-NEXT: ShaderRegister: 31
-# CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
-# CHECK-NEXT: - ParameterType: 0
-# CHECK-NEXT: ShaderVisibility: 3
-# CHECK-NEXT: Table:
-# CHECK-NEXT: NumRanges: 1
-# CHECK-NEXT: RangesOffset: 116
-# CHECK-NEXT: Ranges:
-# CHECK-NEXT: - RangeType: 0
-# CHECK-NEXT: NumDescriptors: -1
-# CHECK-NEXT: BaseShaderRegister: 42
-# CHECK-NEXT: RegisterSpace: 43
-# CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
-# CHECK-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
-# CHECK-NEXT: AllowInputAssemblerInputLayout: true
-# CHECK-NEXT: DenyGeometryShaderRootAccess: true
+#CHECK: - Name: RTS0
+#CHECK-NEXT: Size: 200
+#CHECK-NEXT: RootSignature:
+#CHECK-NEXT: Version: V1_1
+#CHECK-NEXT: NumRootParameters: 4
+#CHECK-NEXT: RootParametersOffset: 24
+#CHECK-NEXT: NumStaticSamplers: 0
+#CHECK-NEXT: StaticSamplersOffset: 60
+#CHECK-NEXT: Parameters:
+#CHECK-NEXT: - ParameterType: Constants32Bit
+#CHECK-NEXT: ShaderVisibility: Hull
+#CHECK-NEXT: Constants:
+#CHECK-NEXT: Num32BitValues: 16
+#CHECK-NEXT: RegisterSpace: 14
+#CHECK-NEXT: ShaderRegister: 15
+#CHECK-NEXT: - ParameterType: Constants32Bit
+#CHECK-NEXT: ShaderVisibility: Geometry
+#CHECK-NEXT: Constants:
+#CHECK-NEXT: Num32BitValues: 21
+#CHECK-NEXT: RegisterSpace: 23
+#CHECK-NEXT: ShaderRegister: 22
+#CHECK-NEXT: - ParameterType: SRV
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Descriptor:
+#CHECK-NEXT: RegisterSpace: 32
+#CHECK-NEXT: ShaderRegister: 31
+#CHECK-NEXT: DATA_STATIC_WHILE_SET_AT_EXECUTE: true
+#CHECK-NEXT: - ParameterType: DescriptorTable
+#CHECK-NEXT: ShaderVisibility: Domain
+#CHECK-NEXT: Table:
+#CHECK-NEXT: NumRanges: 1
+#CHECK-NEXT: RangesOffset: 116
+#CHECK-NEXT: Ranges:
+#CHECK-NEXT: - RangeType: SRV
+#CHECK-NEXT: NumDescriptors: -1
+#CHECK-NEXT: BaseShaderRegister: 42
+#CHECK-NEXT: RegisterSpace: 43
+#CHECK-NEXT: OffsetInDescriptorsFromTableStart: 41
+#CHECK-NEXT: DESCRIPTORS_STATIC_KEEPING_BUFFER_BOUNDS_CHECKS: true
+#CHECK-NEXT: AllowInputAssemblerInputLayout: true
+#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml
index 2189753be0b74..4e6bb477af3f4 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers-Defaults.yaml
@@ -13,7 +13,7 @@ Parts:
- Name: RTS0
Size: 76
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 0
RootParametersOffset: 0
NumStaticSamplers: 1
@@ -22,32 +22,32 @@ Parts:
Samplers:
- ShaderRegister: 31
RegisterSpace: 32
- ShaderVisibility: 7
+ ShaderVisibility: Mesh
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-#CHECK: - Name: RTS0
+#CHECK: - Name: RTS0
#CHECK-NEXT: Size: 76
#CHECK-NEXT: RootSignature:
-#CHECK-NEXT: Version: 2
+#CHECK-NEXT: Version: V1_1
#CHECK-NEXT: NumRootParameters: 0
#CHECK-NEXT: RootParametersOffset: 0
#CHECK-NEXT: NumStaticSamplers: 1
#CHECK-NEXT: StaticSamplersOffset: 24
#CHECK-NEXT: Parameters: []
#CHECK-NEXT: Samplers:
-#CHECK-NEXT: - Filter: 85
-#CHECK-NEXT: AddressU: 1
-#CHECK-NEXT: AddressV: 1
-#CHECK-NEXT: AddressW: 1
-#CHECK-NEXT: MipLODBias: 0
-#CHECK-NEXT: MaxAnisotropy: 16
-#CHECK-NEXT: ComparisonFunc: 4
-#CHECK-NEXT: BorderColor: 2
-#CHECK-NEXT: MinLOD: 0
-#CHECK-NEXT: MaxLOD: 3.40282e+38
-#CHECK-NEXT: ShaderRegister: 31
-#CHECK-NEXT: RegisterSpace: 32
-#CHECK-NEXT: ShaderVisibility: 7
+#CHECK-NEXT: - Filter: Anisotropic
+#CHECK-NEXT: AddressU: Wrap
+#CHECK-NEXT: AddressV: Wrap
+#CHECK-NEXT: AddressW: Wrap
+#CHECK-NEXT: MipLODBias: 0
+#CHECK-NEXT: MaxAnisotropy: 16
+#CHECK-NEXT: ComparisonFunc: LessEqual
+#CHECK-NEXT: BorderColor: OpaqueWhite
+#CHECK-NEXT: MinLOD: 0
+#CHECK-NEXT: MaxLOD: 3.40282e+38
+#CHECK-NEXT: ShaderRegister: 31
+#CHECK-NEXT: RegisterSpace: 32
+#CHECK-NEXT: ShaderVisibility: Mesh
#CHECK-NEXT: AllowInputAssemblerInputLayout: true
#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
index 8f8083e091253..554e83c92f4fa 100644
--- a/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
+++ b/llvm/test/ObjectYAML/DXContainer/RootSignature-StaticSamplers.yaml
@@ -13,51 +13,51 @@ Parts:
- Name: RTS0
Size: 76
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 0
RootParametersOffset: 0
NumStaticSamplers: 1
StaticSamplersOffset: 24
Parameters: []
Samplers:
- - Filter: 10
- AddressU: 1
- AddressV: 2
- AddressW: 5
+ - Filter: MinLinearMagMipPoint
+ AddressU: Wrap
+ AddressV: Mirror
+ AddressW: MirrorOnce
MipLODBias: 1.23
MaxAnisotropy: 20
- ComparisonFunc: 4
- BorderColor: 0
+ ComparisonFunc: LessEqual
+ BorderColor: TransparentBlack
MinLOD: 4.56
MaxLOD: 8.90
ShaderRegister: 31
RegisterSpace: 32
- ShaderVisibility: 7
+ ShaderVisibility: Mesh
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
-#CHECK: - Name: RTS0
+#CHECK: - Name: RTS0
#CHECK-NEXT: Size: 76
#CHECK-NEXT: RootSignature:
-#CHECK-NEXT: Version: 2
+#CHECK-NEXT: Version: V1_1
#CHECK-NEXT: NumRootParameters: 0
#CHECK-NEXT: RootParametersOffset: 0
#CHECK-NEXT: NumStaticSamplers: 1
#CHECK-NEXT: StaticSamplersOffset: 24
#CHECK-NEXT: Parameters: []
#CHECK-NEXT: Samplers:
-#CHECK-NEXT: - Filter: 10
-#CHECK-NEXT: AddressU: 1
-#CHECK-NEXT: AddressV: 2
-#CHECK-NEXT: AddressW: 5
+#CHECK-NEXT: - Filter: MinLinearMagMipPoint
+#CHECK-NEXT: AddressU: Wrap
+#CHECK-NEXT: AddressV: Mirror
+#CHECK-NEXT: AddressW: MirrorOnce
#CHECK-NEXT: MipLODBias: 1.23
#CHECK-NEXT: MaxAnisotropy: 20
-#CHECK-NEXT: ComparisonFunc: 4
-#CHECK-NEXT: BorderColor: 0
+#CHECK-NEXT: ComparisonFunc: LessEqual
+#CHECK-NEXT: BorderColor: TransparentBlack
#CHECK-NEXT: MinLOD: 4.56
#CHECK-NEXT: MaxLOD: 8.9
#CHECK-NEXT: ShaderRegister: 31
#CHECK-NEXT: RegisterSpace: 32
-#CHECK-NEXT: ShaderVisibility: 7
+#CHECK-NEXT: ShaderVisibility: Mesh
#CHECK-NEXT: AllowInputAssemblerInputLayout: true
#CHECK-NEXT: DenyGeometryShaderRootAccess: true
diff --git a/llvm/unittests/Object/DXContainerTest.cpp b/llvm/unittests/Object/DXContainerTest.cpp
index f9fb464380a01..56cf14b908cce 100644
--- a/llvm/unittests/Object/DXContainerTest.cpp
+++ b/llvm/unittests/Object/DXContainerTest.cpp
@@ -1167,7 +1167,7 @@ TEST(RootSignature, ParseStaticSamplers) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
diff --git a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
index 9e6f7cc4f7dbd..4c842abf59ecc 100644
--- a/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
+++ b/llvm/unittests/ObjectYAML/DXContainerYAMLTest.cpp
@@ -126,7 +126,7 @@ TEST(RootSignature, ParseRootFlags) {
- Name: RTS0
Size: 24
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 0
RootParametersOffset: 24
NumStaticSamplers: 0
@@ -166,14 +166,14 @@ TEST(RootSignature, HeaderData) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 255
NumStaticSamplers: 0
StaticSamplersOffset: 0
Parameters:
- - ParameterType: 1
- ShaderVisibility: 2
+ - ParameterType: Constants32Bit
+ ShaderVisibility: Hull
Constants:
Num32BitValues: 16
ShaderRegister: 15
@@ -218,14 +218,14 @@ TEST(RootSignature, ParseRootConstants) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 36
NumStaticSamplers: 0
StaticSamplersOffset: 0
Parameters:
- - ParameterType: 1
- ShaderVisibility: 2
+ - ParameterType: Constants32Bit
+ ShaderVisibility: Hull
Constants:
Num32BitValues: 16
ShaderRegister: 15
@@ -270,14 +270,14 @@ TEST(RootSignature, ParseRootDescriptorsV10) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 1
+ Version: V1_0
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 2 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: CBV
+ ShaderVisibility: Domain
Descriptor:
ShaderRegister: 31
RegisterSpace: 32
@@ -321,14 +321,14 @@ TEST(RootSignature, ParseRootDescriptorsV11) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 2 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: CBV
+ ShaderVisibility: Domain
Descriptor:
ShaderRegister: 31
RegisterSpace: 32
@@ -373,18 +373,18 @@ TEST(RootSignature, ParseDescriptorTableV10) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 1
+ Version: V1_0
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 0 # SRV
- ShaderVisibility: 3 # Domain
+ - ParameterType: DescriptorTable
+ ShaderVisibility: Domain
Table:
NumRanges: 1
Ranges:
- - RangeType: 0
+ - RangeType: SRV
NumDescriptors: 41
BaseShaderRegister: 42
RegisterSpace: 43
@@ -429,18 +429,18 @@ TEST(RootSignature, ParseDescriptorTableV11) {
- Name: RTS0
Size: 89
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 1
RootParametersOffset: 24
NumStaticSamplers: 0
StaticSamplersOffset: 60
Parameters:
- - ParameterType: 0 # Descriptor Table
- ShaderVisibility: 3 # Domain
+ - ParameterType: DescriptorTable
+ ShaderVisibility: Domain
Table:
NumRanges: 1
Ranges:
- - RangeType: 0
+ - RangeType: SRV
NumDescriptors: -1
BaseShaderRegister: 42
RegisterSpace: 43
@@ -485,26 +485,26 @@ TEST(RootSignature, ParseStaticSamplers) {
- Name: RTS0
Size: 76
RootSignature:
- Version: 2
+ Version: V1_1
NumRootParameters: 0
RootParametersOffset: 0
NumStaticSamplers: 1
StaticSamplersOffset: 24
Parameters: []
Samplers:
- - Filter: 10
- AddressU: 1
- AddressV: 2
- AddressW: 5
+ - Filter: MinLinearMagMipPoint
+ AddressU: Wrap
+ AddressV: Mirror
+ AddressW: MirrorOnce
MipLODBias: 1.23
MaxAnisotropy: 20
- ComparisonFunc: 4
- BorderColor: 0
+ ComparisonFunc: LessEqual
+ BorderColor: TransparentBlack
MinLOD: 4.56
MaxLOD: 8.90
ShaderRegister: 31
RegisterSpace: 32
- ShaderVisibility: 7
+ ShaderVisibility: Mesh
AllowInputAssemblerInputLayout: true
DenyGeometryShaderRootAccess: true
)"));
@@ -517,7 +517,7 @@ TEST(RootSignature, ParseStaticSamplers) {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x52, 0x54, 0x53, 0x30, 0x4c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00,
+ 0x18, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
0xa4, 0x70, 0x9d, 0x3f, 0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x85, 0xeb, 0x91, 0x40, 0x66, 0x66, 0x0e, 0x41,
>From 3b5f49786540fde3476c82293900607ff73c4e5e Mon Sep 17 00:00:00 2001
From: Joao Saffran <joaosaffranllvm at gmail.com>
Date: Mon, 18 Aug 2025 12:48:34 -0700
Subject: [PATCH 9/9] clean up
---
clang/lib/Sema/SemaHLSL.cpp | 1 -
.../Frontend/HLSL/RootSignatureMetadata.h | 1 -
.../Frontend/HLSL/RootSignatureValidations.h | 1 -
.../Frontend/HLSL/RootSignatureMetadata.cpp | 2 -
.../HLSL/RootSignatureValidations.cpp | 1 -
llvm/lib/MC/DXContainerRootSignature.cpp | 1 -
llvm/lib/ObjectYAML/DXContainerEmitter.cpp | 13 +---
llvm/lib/ObjectYAML/DXContainerYAML.cpp | 9 +--
llvm/lib/Target/DirectX/DXILRootSignature.cpp | 22 ++++---
.../RootSignature-MultipleEntryFunctions.ll | 4 +-
.../ContainerData/RootSignature-Parameters.ll | 62 +++++++++----------
llvm/unittests/Object/DXContainerTest.cpp | 1 -
12 files changed, 49 insertions(+), 69 deletions(-)
diff --git a/clang/lib/Sema/SemaHLSL.cpp b/clang/lib/Sema/SemaHLSL.cpp
index 6263fddd1b0bb..4080f6dd8d554 100644
--- a/clang/lib/Sema/SemaHLSL.cpp
+++ b/clang/lib/Sema/SemaHLSL.cpp
@@ -39,7 +39,6 @@
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/HLSLBinding.h"
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/Support/Casting.h"
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
index 0a5b6b600688e..fb256cd7c4dba 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureMetadata.h
@@ -19,7 +19,6 @@
#include "llvm/IR/Constants.h"
#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/Support/Compiler.h"
-#include <cstdint>
namespace llvm {
class LLVMContext;
diff --git a/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h b/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
index ac3131fd05eb6..949bc3eb7444e 100644
--- a/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
+++ b/llvm/include/llvm/Frontend/HLSL/RootSignatureValidations.h
@@ -15,7 +15,6 @@
#define LLVM_FRONTEND_HLSL_ROOTSIGNATUREVALIDATIONS_H
#include "llvm/ADT/IntervalMap.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/HLSLRootSignature.h"
#include "llvm/Support/Compiler.h"
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index c1503a6acd36e..8a6e83d6ed4ee 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -12,13 +12,11 @@
//===----------------------------------------------------------------------===//
#include "llvm/Frontend/HLSL/RootSignatureMetadata.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/ScopedPrinter.h"
-#include <cstdint>
using namespace llvm;
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
index 9a5b3b8cae4f6..2f70185eed06e 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureValidations.cpp
@@ -11,7 +11,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/Frontend/HLSL/RootSignatureValidations.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include <cmath>
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index ebd1b201d6f00..e3e2d3c853bb8 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -8,7 +8,6 @@
#include "llvm/MC/DXContainerRootSignature.h"
#include "llvm/ADT/SmallString.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/Support/EndianStream.h"
using namespace llvm;
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index bf36bfe6647e5..a8b4e7f2d52e7 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -278,18 +278,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
dxbc::RTS0::v1::RootParameterHeader Header{L.Header.Type, L.Header.Visibility,
L.Header.Offset};
- if (!dxbc::isValidParameterType(L.Header.Type)) {
- // Handling invalid parameter type edge case. We intentionally let
- // obj2yaml/yaml2obj parse and emit invalid dxcontainer data, in order
- // for that to be used as a testing tool more effectively.
- RS.ParametersContainer.addInvalidParameter(Header);
- continue;
- }
-
- dxbc::RootParameterType ParameterType =
- static_cast<dxbc::RootParameterType>(L.Header.Type);
-
- switch (ParameterType) {
+ switch (L.Header.Type) {
case dxbc::RootParameterType::Constants32Bit: {
const DXContainerYAML::RootConstantsYaml &ConstantYaml =
P.RootSignature->Parameters.getOrInsertConstants(L);
diff --git a/llvm/lib/ObjectYAML/DXContainerYAML.cpp b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
index 8cc38a3f928ff..47a5c84bb122d 100644
--- a/llvm/lib/ObjectYAML/DXContainerYAML.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerYAML.cpp
@@ -424,14 +424,7 @@ void MappingContextTraits<DXContainerYAML::RootParameterLocationYaml,
IO.mapRequired("ParameterType", L.Header.Type);
IO.mapRequired("ShaderVisibility", L.Header.Visibility);
- // If a parameter type is invalid, we don't have a body to parse.
- if (!dxbc::isValidParameterType(L.Header.Type))
- return;
-
- // parses the body of a given root parameter type
- dxbc::RootParameterType PT =
- static_cast<dxbc::RootParameterType>(L.Header.Type);
- switch (PT) {
+ switch (L.Header.Type) {
case dxbc::RootParameterType::Constants32Bit: {
DXContainerYAML::RootConstantsYaml &Constants =
S.Parameters.getOrInsertConstants(L);
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index ba5d08a76ee2a..a179d13b9053e 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -28,6 +28,7 @@
#include "llvm/Pass.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/ScopedPrinter.h"
#include "llvm/Support/raw_ostream.h"
#include <cstdint>
@@ -172,7 +173,8 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
OS << "Definition for '" << F.getName() << "':\n";
// start root signature header
OS << "Flags: " << format_hex(RS.Flags, 8) << "\n"
- << "Version: " << RS.Version << "\n"
+ << "Version: "
+ << enumToStringRef(RS.Version, dxbc::getRootSignatureVersions()) << "\n"
<< "RootParametersOffset: " << RS.RootParameterOffset << "\n"
<< "NumParameters: " << RS.ParametersContainer.size() << "\n";
for (size_t I = 0; I < RS.ParametersContainer.size(); I++) {
@@ -181,12 +183,13 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
const dxbc::RTS0::v1::RootParameterHeader Header =
RS.ParametersContainer.getHeader(I);
- OS << "- Parameter Type: " << Type << "\n"
- << " Shader Visibility: " << Header.ShaderVisibility << "\n";
-
- assert(dxbc::isValidParameterType(Type) && "Invalid Parameter Type");
- dxbc::RootParameterType PT = static_cast<dxbc::RootParameterType>(Type);
- switch (PT) {
+ OS << "- Parameter Type: "
+ << enumToStringRef(Type, dxbc::getRootParameterTypes()) << "\n"
+ << " Shader Visibility: "
+ << enumToStringRef(Header.ShaderVisibility,
+ dxbc::getShaderVisibility())
+ << "\n";
+ switch (Type) {
case dxbc::RootParameterType::Constants32Bit: {
const dxbc::RTS0::v1::RootConstants &Constants =
RS.ParametersContainer.getConstant(Loc);
@@ -212,7 +215,10 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
OS << " NumRanges: " << Table.Ranges.size() << "\n";
for (const dxbc::RTS0::v2::DescriptorRange Range : Table) {
- OS << " - Range Type: " << Range.RangeType << "\n"
+ OS << " - Range Type: "
+ << enumToStringRef(Range.RangeType,
+ dxbc::getDescriptorRangeTypes())
+ << "\n"
<< " Register Space: " << Range.RegisterSpace << "\n"
<< " Base Shader Register: " << Range.BaseShaderRegister << "\n"
<< " Num Descriptors: " << Range.NumDescriptors << "\n"
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
index f3e374e4b0a44..e950d38fedeaf 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-MultipleEntryFunctions.ll
@@ -25,7 +25,7 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; CHECK-LABEL: Definition for 'main':
; CHECK-NEXT: Flags: 0x000001
-; CHECK-NEXT: Version: 0x2
+; CHECK-NEXT: Version: V1_1
; CHECK-NEXT: RootParametersOffset: 24
; CHECK-NEXT: NumParameters: 0
; CHECK-NEXT: NumStaticSamplers: 0
@@ -33,7 +33,7 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
; CHECK-LABEL: Definition for 'anotherMain':
; CHECK-NEXT: Flags: 0x000002
-; CHECK-NEXT: Version: 0x2
+; CHECK-NEXT: Version: V1_1
; CHECK-NEXT: RootParametersOffset: 24
; CHECK-NEXT: NumParameters: 0
; CHECK-NEXT: NumStaticSamplers: 0
diff --git a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
index a0171d0160ed5..e3500e3b2df41 100644
--- a/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
+++ b/llvm/test/CodeGen/DirectX/ContainerData/RootSignature-Parameters.ll
@@ -20,35 +20,35 @@ attributes #0 = { "hlsl.numthreads"="1,1,1" "hlsl.shader"="compute" }
!8 = !{ !"SRV", i32 1, i32 1, i32 0, i32 -1, i32 4 }
!9 = !{ !"UAV", i32 5, i32 1, i32 10, i32 5, i32 2 }
-;CHECK-LABEL: Definition for 'main':
-;CHECK-NEXT: Flags: 0x000001
-;CHECK-NEXT: Version: 0x2
-;CHECK-NEXT: RootParametersOffset: 24
-;CHECK-NEXT: NumParameters: 3
-;CHECK-NEXT: - Parameter Type: 0x1
-;CHECK-NEXT: Shader Visibility: 0x0
-;CHECK-NEXT: Register Space: 2
-;CHECK-NEXT: Shader Register: 1
-;CHECK-NEXT: Num 32 Bit Values: 3
-;CHECK-NEXT: - Parameter Type: 0x3
-;CHECK-NEXT: Shader Visibility: 0x1
-;CHECK-NEXT: Register Space: 5
-;CHECK-NEXT: Shader Register: 4
+;CHECK: Definition for 'main':
+;CHECK-NEXT: Flags: 0x000001
+;CHECK-NEXT: Version: V1_1
+;CHECK-NEXT: RootParametersOffset: 24
+;CHECK-NEXT: NumParameters: 3
+;CHECK-NEXT: - Parameter Type: Constants32Bit
+;CHECK-NEXT: Shader Visibility: All
+;CHECK-NEXT: Register Space: 2
+;CHECK-NEXT: Shader Register: 1
+;CHECK-NEXT: Num 32 Bit Values: 3
+;CHECK-NEXT: - Parameter Type: SRV
+;CHECK-NEXT: Shader Visibility: Vertex
+;CHECK-NEXT: Register Space: 5
+;CHECK-NEXT: Shader Register: 4
+;CHECK-NEXT: Flags: 4
+;CHECK-NEXT: - Parameter Type: DescriptorTable
+;CHECK-NEXT: Shader Visibility: All
+;CHECK-NEXT: NumRanges: 2
+;CHECK-NEXT: - Range Type: SRV
+;CHECK-NEXT: Register Space: 0
+;CHECK-NEXT: Base Shader Register: 1
+;CHECK-NEXT: Num Descriptors: 1
+;CHECK-NEXT: Offset In Descriptors From Table Start: 4294967295
;CHECK-NEXT: Flags: 4
-;CHECK-NEXT: - Parameter Type: 0x0
-;CHECK-NEXT: Shader Visibility: 0x0
-;CHECK-NEXT: NumRanges: 2
-;CHECK-NEXT: - Range Type: 0x0
-;CHECK-NEXT: Register Space: 0
-;CHECK-NEXT: Base Shader Register: 1
-;CHECK-NEXT: Num Descriptors: 1
-;CHECK-NEXT: Offset In Descriptors From Table Start: 4294967295
-;CHECK-NEXT: Flags: 4
-;CHECK-NEXT: - Range Type: 0x1
-;CHECK-NEXT: Register Space: 10
-;CHECK-NEXT: Base Shader Register: 1
-;CHECK-NEXT: Num Descriptors: 5
-;CHECK-NEXT: Offset In Descriptors From Table Start: 5
-;CHECK-NEXT: Flags: 2
-;CHECK-NEXT: NumStaticSamplers: 0
-;CHECK-NEXT: StaticSamplersOffset: 0
+;CHECK-NEXT: - Range Type: UAV
+;CHECK-NEXT: Register Space: 10
+;CHECK-NEXT: Base Shader Register: 1
+;CHECK-NEXT: Num Descriptors: 5
+;CHECK-NEXT: Offset In Descriptors From Table Start: 5
+;CHECK-NEXT: Flags: 2
+;CHECK-NEXT: NumStaticSamplers: 0
+;CHECK-NEXT: StaticSamplersOffset: 0
diff --git a/llvm/unittests/Object/DXContainerTest.cpp b/llvm/unittests/Object/DXContainerTest.cpp
index 56cf14b908cce..f83a3145d3aa2 100644
--- a/llvm/unittests/Object/DXContainerTest.cpp
+++ b/llvm/unittests/Object/DXContainerTest.cpp
@@ -8,7 +8,6 @@
#include "llvm/Object/DXContainer.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/BinaryFormat/DXContainer.h"
#include "llvm/BinaryFormat/Magic.h"
#include "llvm/ObjectYAML/DXContainerYAML.h"
#include "llvm/ObjectYAML/yaml2obj.h"
More information about the llvm-commits
mailing list