[llvm-branch-commits] [llvm] [DirectX] Adding missing descriptor table validations (PR #153276)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Aug 29 19:55:02 PDT 2025


================
@@ -214,6 +214,39 @@ enum class ShaderVisibility : uint32_t {
 #include "DXContainerConstants.def"
 };
 
+inline dxil::ResourceClass
+toResourceClass(dxbc::DescriptorRangeType RangeType) {
+  using namespace dxbc;
+  switch (RangeType) {
+  case DescriptorRangeType::SRV:
+    return dxil::ResourceClass::SRV;
+  case DescriptorRangeType::UAV:
+    return dxil::ResourceClass::UAV;
+  case DescriptorRangeType::CBV:
+    return dxil::ResourceClass::CBuffer;
+  case DescriptorRangeType::Sampler:
+    return dxil::ResourceClass::Sampler;
+  }
+  llvm_unreachable("Unknown DescriptorRangeType");
+}
+
+inline dxil::ResourceClass toResourceClass(dxbc::RootParameterType Type) {
+  using namespace dxbc;
+  switch (Type) {
+  case RootParameterType::Constants32Bit:
+    return dxil::ResourceClass::CBuffer;
+  case RootParameterType::SRV:
+    return dxil::ResourceClass::SRV;
+  case RootParameterType::UAV:
+    return dxil::ResourceClass::UAV;
+  case RootParameterType::CBV:
+    return dxil::ResourceClass::CBuffer;
+  case dxbc::RootParameterType::DescriptorTable:
+    llvm_unreachable("DescriptorTable is not convertible to ResourceClass");
+  }
+  llvm_unreachable("Unknown RootParameterType");
+}
----------------
joaosaffran wrote:

Those are being moved to here, to be used in `Frontend/HLSL/RootSignatureMetadata.cpp` and `DirectX/DxilPostOptimizationValidation.cpp`

https://github.com/llvm/llvm-project/pull/153276


More information about the llvm-branch-commits mailing list