[llvm-branch-commits] [llvm] [NFC] Refactoring DXContainerYaml Root Parameter representation (PR #138318)

Finn Plummer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue May 20 10:48:01 PDT 2025


================
@@ -278,33 +280,40 @@ void DXContainerWriter::writeParts(raw_ostream &OS) {
         auto Header = dxbc::RootParameterHeader{Param.Type, Param.Visibility,
                                                 Param.Offset};
 
-        switch (Param.Type) {
-        case llvm::to_underlying(dxbc::RootParameterType::Constants32Bit):
+        if (std::holds_alternative<DXContainerYAML::RootConstantsYaml>(
+                Param.Data)) {
+          auto ConstantYaml =
+              std::get<DXContainerYAML::RootConstantsYaml>(Param.Data);
+
           dxbc::RootConstants Constants;
-          Constants.Num32BitValues = Param.Constants.Num32BitValues;
-          Constants.RegisterSpace = Param.Constants.RegisterSpace;
-          Constants.ShaderRegister = Param.Constants.ShaderRegister;
+          Constants.Num32BitValues = ConstantYaml.Num32BitValues;
+          Constants.RegisterSpace = ConstantYaml.RegisterSpace;
+          Constants.ShaderRegister = ConstantYaml.ShaderRegister;
           RS.ParametersContainer.addParameter(Header, Constants);
-          break;
-        case llvm::to_underlying(dxbc::RootParameterType::SRV):
-        case llvm::to_underlying(dxbc::RootParameterType::UAV):
-        case llvm::to_underlying(dxbc::RootParameterType::CBV):
+        } else if (std::holds_alternative<DXContainerYAML::RootDescriptorYaml>(
+                       Param.Data)) {
+          auto DescriptorYaml =
+              std::get<DXContainerYAML::RootDescriptorYaml>(Param.Data);
----------------
inbelic wrote:

I think you can use the `std::get_if(&Param.Data)` notations here?

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


More information about the llvm-branch-commits mailing list