[llvm] [DirectX] adding support to read/write descriptor table data using obj2yaml/yaml2obj (PR #138315)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 22 10:25:48 PDT 2025
================
@@ -106,13 +125,82 @@ struct RootParameterYamlDesc {
case llvm::to_underlying(dxbc::RootParameterType::UAV):
Descriptor = RootDescriptorYaml();
break;
+ case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
+ Table = DescriptorTableYaml();
+ break;
+ }
+ }
+
+ ~RootParameterYamlDesc() {
+ switch (Type) {
+
+ case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
+ Constants.~RootConstantsYaml();
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::CBV):
+ case llvm::to_underlying(dxbc::RootParameterType::SRV):
+ case llvm::to_underlying(dxbc::RootParameterType::UAV):
+ Descriptor.~RootDescriptorYaml();
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
+ Table.~DescriptorTableYaml();
+ break;
}
}
+ RootParameterYamlDesc(const RootParameterYamlDesc &Other)
+ : Type(Other.Type), Visibility(Other.Visibility), Offset(Other.Offset) {
+ // Initialize the appropriate union member based on Type
+ switch (Type) {
+ case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
+ // Placement new to construct the union member
+ new (&Constants) RootConstantsYaml(Other.Constants);
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::CBV):
+ case llvm::to_underlying(dxbc::RootParameterType::SRV):
+ case llvm::to_underlying(dxbc::RootParameterType::UAV):
+ new (&Descriptor) RootDescriptorYaml(Other.Descriptor);
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
+ new (&Table) DescriptorTableYaml(Other.Table);
+ break;
+ }
+ }
+
+ RootParameterYamlDesc &operator=(const RootParameterYamlDesc &Other) {
+ if (this != &Other) {
+ // First, destroy the current union member
+ this->~RootParameterYamlDesc();
+
+ // Copy the basic members
+ Type = Other.Type;
+ Visibility = Other.Visibility;
+ Offset = Other.Offset;
+
+ // Initialize the new union member based on the Type from 'other'
+ switch (Type) {
+ case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
+ new (&Constants) RootConstantsYaml(Other.Constants);
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::CBV):
+ case llvm::to_underlying(dxbc::RootParameterType::SRV):
+ case llvm::to_underlying(dxbc::RootParameterType::UAV):
+ new (&Descriptor) RootDescriptorYaml(Other.Descriptor);
+ break;
+ case llvm::to_underlying(dxbc::RootParameterType::DescriptorTable):
+ new (&Table) DescriptorTableYaml(Other.Table);
+ break;
+ }
+ }
+ return *this;
+ }
+
+ // ToDo: Fix this (Already have a follow up PR with it)
----------------
joaosaffran wrote:
Will Remove that and swap the PRs order
https://github.com/llvm/llvm-project/pull/138315
More information about the llvm-commits
mailing list