[llvm-branch-commits] [llvm] [DirectX] Adding support for Root Descriptor in Obj2yaml/Yaml2Obj (PR #136732)

Finn Plummer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Apr 23 10:15:00 PDT 2025


================
@@ -594,6 +599,25 @@ struct RootConstants {
     sys::swapByteOrder(Num32BitValues);
   }
 };
+struct RootDescriptor_V1_0 {
----------------
inbelic wrote:

IIUC, this is how the structs were defined and planned to be extended in DXC. And I believe it was also documented there that each new version of a must guarantee it will only append data members.

What were the reasons for keeping separate structures?

>From glancing, it seems like we would just need to update the `readParameter` function to determine the size of the struct based on the version. Maybe that is more extensible? It seems like the logic elsewhere would be nicer:

Currently it is like:
```
  if (Version == 1) {
    Param1 = Param1;
    Param2 = Param2;
  }
  if (Version == 2) {
    Param1 = Param1;
    Param2 = Param2;
    ExtraParam1 = ExtraParam1;
  }
  if (Version == 3) {
    ...
  }
```
And it could be like
```
Param1 = Param1;
Param2 = Param2;
if (Version >= 2) {
  ExtraParam1 = ExtraParam2;
}
if (Version >= 3) {
  ExtraParam2 = ExtraParam2;
}
```
And similar for the `sys::write` functionality, etc.

Happy to just be told no, but wanted to make sure we haved reconsidered the format.

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


More information about the llvm-branch-commits mailing list