[llvm] [HLSL] Adding support for root descriptors in root signature metadata representation (PR #139781)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 2 11:09:48 PDT 2025
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff HEAD~1 HEAD --extensions h,cpp -- llvm/include/llvm/MC/DXContainerRootSignature.h llvm/lib/MC/DXContainerRootSignature.cpp llvm/lib/Target/DirectX/DXILRootSignature.cpp llvm/lib/Target/DirectX/DXILRootSignature.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/MC/DXContainerRootSignature.cpp b/llvm/lib/MC/DXContainerRootSignature.cpp
index ebbb9cbda..59d301e45 100644
--- a/llvm/lib/MC/DXContainerRootSignature.cpp
+++ b/llvm/lib/MC/DXContainerRootSignature.cpp
@@ -104,12 +104,12 @@ void RootSignatureDesc::write(raw_ostream &OS) const {
llvm::endianness::little);
support::endian::write(BOS, Constants.Num32BitValues,
llvm::endianness::little);
- } break;
+ } break;
case llvm::to_underlying(dxbc::RootParameterType::CBV):
case llvm::to_underlying(dxbc::RootParameterType::SRV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV):{
+ case llvm::to_underlying(dxbc::RootParameterType::UAV): {
const dxbc::RTS0::v2::RootDescriptor &Descriptor =
- ParametersContainer.getRootDescriptor(Loc);
+ ParametersContainer.getRootDescriptor(Loc);
support::endian::write(BOS, Descriptor.ShaderRegister,
llvm::endianness::little);
diff --git a/llvm/lib/Target/DirectX/DXILRootSignature.cpp b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
index 1064a5367..0888aa5fc 100644
--- a/llvm/lib/Target/DirectX/DXILRootSignature.cpp
+++ b/llvm/lib/Target/DirectX/DXILRootSignature.cpp
@@ -249,26 +249,26 @@ static bool validate(LLVMContext *Ctx, const mcdxbc::RootSignatureDesc &RSD) {
assert(dxbc::isValidParameterType(Info.Header.ParameterType) &&
"Invalid value for ParameterType");
- switch(Info.Header.ParameterType) {
-
- case llvm::to_underlying(dxbc::RootParameterType::CBV):
- case llvm::to_underlying(dxbc::RootParameterType::UAV):
- case llvm::to_underlying(dxbc::RootParameterType::SRV): {
- const dxbc::RTS0::v2::RootDescriptor &Descriptor = RSD.ParametersContainer.getRootDescriptor(Info.Location);
- if (!verifyRegisterValue(Descriptor.ShaderRegister))
- return reportValueError(Ctx, "ShaderRegister",
- Descriptor.ShaderRegister);
-
- if (!verifyRegisterSpace(Descriptor.RegisterSpace))
- return reportValueError(Ctx, "RegisterSpace",
- Descriptor.RegisterSpace);
-
- if(RSD.Version > 1) {
- if (!verifyDescriptorFlag(Descriptor.Flags))
- return reportValueError(Ctx, "DescriptorFlag", Descriptor.Flags);
- }
- break;
+ switch (Info.Header.ParameterType) {
+
+ case llvm::to_underlying(dxbc::RootParameterType::CBV):
+ case llvm::to_underlying(dxbc::RootParameterType::UAV):
+ case llvm::to_underlying(dxbc::RootParameterType::SRV): {
+ const dxbc::RTS0::v2::RootDescriptor &Descriptor =
+ RSD.ParametersContainer.getRootDescriptor(Info.Location);
+ if (!verifyRegisterValue(Descriptor.ShaderRegister))
+ return reportValueError(Ctx, "ShaderRegister",
+ Descriptor.ShaderRegister);
+
+ if (!verifyRegisterSpace(Descriptor.RegisterSpace))
+ return reportValueError(Ctx, "RegisterSpace", Descriptor.RegisterSpace);
+
+ if (RSD.Version > 1) {
+ if (!verifyDescriptorFlag(Descriptor.Flags))
+ return reportValueError(Ctx, "DescriptorFlag", Descriptor.Flags);
}
+ break;
+ }
}
}
@@ -411,17 +411,17 @@ 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::CBV):
case llvm::to_underlying(dxbc::RootParameterType::UAV):
case llvm::to_underlying(dxbc::RootParameterType::SRV): {
- const dxbc::RTS0::v2::RootDescriptor &Descriptor =
+ const dxbc::RTS0::v2::RootDescriptor &Descriptor =
RS.ParametersContainer.getRootDescriptor(Loc);
OS << indent(Space + 2)
<< "Register Space: " << Descriptor.RegisterSpace << "\n";
OS << indent(Space + 2)
<< "Shader Register: " << Descriptor.ShaderRegister << "\n";
- if(RS.Version > 1)
- OS << indent(Space + 2) << "Flags: " << Descriptor.Flags << "\n";
+ if (RS.Version > 1)
+ OS << indent(Space + 2) << "Flags: " << Descriptor.Flags << "\n";
break;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139781
More information about the llvm-commits
mailing list