-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[DirectX] Removing dxbc RootSignature and RootDescriptor from mcbxdc #154585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DirectX] Removing dxbc RootSignature and RootDescriptor from mcbxdc #154585
Conversation
@llvm/pr-subscribers-mc @llvm/pr-subscribers-hlsl Author: None (joaosaffran) ChangesMC Root Signature Representations currently depend on Object structures. This PR removes that dependency and in order to facilitate removing to_underlying usage in follow up PRs. Full diff: https://github.com/llvm/llvm-project/pull/154585.diff 6 Files Affected:
diff --git a/llvm/include/llvm/MC/DXContainerRootSignature.h b/llvm/include/llvm/MC/DXContainerRootSignature.h
index 4db3f3458c808..85b45323cee08 100644
--- a/llvm/include/llvm/MC/DXContainerRootSignature.h
+++ b/llvm/include/llvm/MC/DXContainerRootSignature.h
@@ -19,6 +19,18 @@ namespace llvm {
class raw_ostream;
namespace mcdxbc {
+struct RootConstants {
+ uint32_t ShaderRegister;
+ uint32_t RegisterSpace;
+ uint32_t Num32BitValues;
+};
+
+struct RootDescriptor {
+ uint32_t ShaderRegister;
+ uint32_t RegisterSpace;
+ uint32_t Flags;
+};
+
struct RootParameterInfo {
dxbc::RootParameterType Type;
dxbc::ShaderVisibility Visibility;
@@ -42,8 +54,8 @@ struct DescriptorTable {
struct RootParametersContainer {
SmallVector<RootParameterInfo> ParametersInfo;
- SmallVector<dxbc::RTS0::v1::RootConstants> Constants;
- SmallVector<dxbc::RTS0::v2::RootDescriptor> Descriptors;
+ SmallVector<RootConstants> Constants;
+ SmallVector<RootDescriptor> Descriptors;
SmallVector<DescriptorTable> Tables;
void addInfo(dxbc::RootParameterType Type, dxbc::ShaderVisibility Visibility,
@@ -52,15 +64,14 @@ struct RootParametersContainer {
}
void addParameter(dxbc::RootParameterType Type,
- dxbc::ShaderVisibility Visibility,
- dxbc::RTS0::v1::RootConstants Constant) {
+ dxbc::ShaderVisibility Visibility, RootConstants Constant) {
addInfo(Type, Visibility, Constants.size());
Constants.push_back(Constant);
}
void addParameter(dxbc::RootParameterType Type,
dxbc::ShaderVisibility Visibility,
- dxbc::RTS0::v2::RootDescriptor Descriptor) {
+ RootDescriptor Descriptor) {
addInfo(Type, Visibility, Descriptors.size());
Descriptors.push_back(Descriptor);
}
@@ -76,11 +87,11 @@ struct RootParametersContainer {
return Info;
}
- const dxbc::RTS0::v1::RootConstants &getConstant(size_t Index) const {
+ const RootConstants &getConstant(size_t Index) const {
return Constants[Index];
}
- const dxbc::RTS0::v2::RootDescriptor &getRootDescriptor(size_t Index) const {
+ const RootDescriptor &getRootDescriptor(size_t Index) const {
return Descriptors[Index];
}
diff --git a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
index 610f889e8d7c6..770a6d1638e3c 100644
--- a/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
+++ b/llvm/lib/Frontend/HLSL/RootSignatureMetadata.cpp
@@ -240,7 +240,7 @@ Error MetadataParser::parseRootConstants(mcdxbc::RootSignatureDesc &RSD,
if (auto E = Visibility.takeError())
return Error(std::move(E));
- dxbc::RTS0::v1::RootConstants Constants;
+ mcdxbc::RootConstants Constants;
if (std::optional<uint32_t> Val = extractMdIntValue(RootConstantNode, 2))
Constants.ShaderRegister = *Val;
else
@@ -294,7 +294,7 @@ Error MetadataParser::parseRootDescriptors(
if (auto E = Visibility.takeError())
return Error(std::move(E));
- dxbc::RTS0::v2::RootDescriptor Descriptor;
+ mcdxbc::RootDescriptor Descriptor;
if (std::optional<uint32_t> Val = extractMdIntValue(RootDescriptorNode, 2))
Descriptor.ShaderRegister = *Val;
else
@@ -544,7 +544,7 @@ Error MetadataParser::validateRootSignature(
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::SRV: {
- const dxbc::RTS0::v2::RootDescriptor &Descriptor =
+ const mcdxbc::RootDescriptor &Descriptor =
RSD.ParametersContainer.getRootDescriptor(Info.Location);
if (!hlsl::rootsig::verifyRegisterValue(Descriptor.ShaderRegister))
DeferredErrs =
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index 14c9c8866bb24..94119d8e89ec9 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -97,7 +97,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
const auto Info = ParametersContainer.getInfo(I);
switch (Info.Type) {
case dxbc::RootParameterType::Constants32Bit: {
- const dxbc::RTS0::v1::RootConstants &Constants =
+ const mcdxbc::RootConstants &Constants =
ParametersContainer.getConstant(Info.Location);
support::endian::write(BOS, Constants.ShaderRegister,
llvm::endianness::little);
@@ -110,7 +110,7 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV: {
- const dxbc::RTS0::v2::RootDescriptor &Descriptor =
+ const mcdxbc::RootDescriptor &Descriptor =
ParametersContainer.getRootDescriptor(Info.Location);
support::endian::write(BOS, Descriptor.ShaderRegister,
diff --git a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
index b112c6f21ee5a..a51821e196cb8 100644
--- a/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
+++ b/llvm/lib/ObjectYAML/DXContainerEmitter.cpp
@@ -288,7 +288,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
case dxbc::RootParameterType::Constants32Bit: {
const DXContainerYAML::RootConstantsYaml &ConstantYaml =
P.RootSignature->Parameters.getOrInsertConstants(L);
- dxbc::RTS0::v1::RootConstants Constants;
+ mcdxbc::RootConstants Constants;
Constants.Num32BitValues = ConstantYaml.Num32BitValues;
Constants.RegisterSpace = ConstantYaml.RegisterSpace;
@@ -302,7 +302,7 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
const DXContainerYAML::RootDescriptorYaml &DescriptorYaml =
P.RootSignature->Parameters.getOrInsertDescriptor(L);
- dxbc::RTS0::v2::RootDescriptor Descriptor;
+ mcdxbc::RootDescriptor Descriptor;
Descriptor.RegisterSpace = DescriptorYaml.RegisterSpace;
Descriptor.ShaderRegister = DescriptorYaml.ShaderRegister;
if (RS.Version > 1)
diff --git a/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp b/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp
index fc0afb9a0efdf..5557443a3db93 100644
--- a/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp
+++ b/llvm/lib/Target/DirectX/DXILPostOptimizationValidation.cpp
@@ -171,7 +171,7 @@ static void validateRootSignature(Module &M,
dxbc::RootParameterType ParamType = dxbc::RootParameterType(ParamInfo.Type);
switch (ParamType) {
case dxbc::RootParameterType::Constants32Bit: {
- dxbc::RTS0::v1::RootConstants Const =
+ mcdxbc::RootConstants Const =
RSD.ParametersContainer.getConstant(ParamInfo.Location);
Builder.trackBinding(dxil::ResourceClass::CBuffer, Const.RegisterSpace,
Const.ShaderRegister, Const.ShaderRegister,
@@ -182,7 +182,7 @@ static void validateRootSignature(Module &M,
case dxbc::RootParameterType::SRV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::CBV: {
- dxbc::RTS0::v2::RootDescriptor Desc =
+ mcdxbc::RootDescriptor Desc =
RSD.ParametersContainer.getRootDescriptor(ParamInfo.Location);
Builder.trackBinding(toResourceClass(ParamInfo.Type), Desc.RegisterSpace,
Desc.ShaderRegister, Desc.ShaderRegister,
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 2ca2ecff5a55f..b05b8ee699ef6 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -182,7 +182,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
const uint32_t &Loc = Info.Location;
switch (Info.Type) {
case dxbc::RootParameterType::Constants32Bit: {
- const dxbc::RTS0::v1::RootConstants &Constants =
+ const mcdxbc::RootConstants &Constants =
RS.ParametersContainer.getConstant(Loc);
OS << " Register Space: " << Constants.RegisterSpace << "\n"
<< " Shader Register: " << Constants.ShaderRegister << "\n"
@@ -192,7 +192,7 @@ PreservedAnalyses RootSignatureAnalysisPrinter::run(Module &M,
case dxbc::RootParameterType::CBV:
case dxbc::RootParameterType::UAV:
case dxbc::RootParameterType::SRV: {
- const dxbc::RTS0::v2::RootDescriptor &Descriptor =
+ const mcdxbc::RootDescriptor &Descriptor =
RS.ParametersContainer.getRootDescriptor(Loc);
OS << " Register Space: " << Descriptor.RegisterSpace << "\n"
<< " Shader Register: " << Descriptor.ShaderRegister << "\n";
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but the same note about a dependency: #154249 (comment)
✅ With the latest revision this PR passed the C/C++ code formatter. |
MC Root Signature Representations currently depend on Object structures. This PR removes that dependency and in order to facilitate removing to_underlying usage in follow up PRs.