Issue 145439
Summary [DirectX] Root signature's `DescriptorTableView` has undefined behaviour for version 1.0 root signatures.
Labels backend:DirectX
Assignees
Reporter bogner
    We currently have the "DescriptorTableView" load a `DirectX::DescriptorTable` with a type like so:
```c++
struct DescriptorTable {
  uint32_t NumRanges;
  uint32_t RangesOffset;
 ViewArray<dxbc::RTS0::v2::DescriptorRange> Ranges;
};
```

However, we set up the ranges view like so:
```c++
    size_t RangeSize = sizeof(dxbc::RTS0::v1::DescriptorRange);
    if (Version > 1)
 RangeSize = sizeof(dxbc::RTS0::v2::DescriptorRange);

 Table.Ranges.Stride = RangeSize;
    Table.Ranges.Data =
 "" * sizeof(uint32_t), Table.NumRanges * RangeSize);
```

This invokes undefined behaviour. It is not legal to store a `dxbc::RTS0::v1::DescriptorRange` in an object of type `dxbc::RTS0::v2::DescriptorRange` (the inheritance is in the other direction. Furthermore, `dxbc::RTS0::v2::DescriptorRange` will not fit in `sizeof(dxbc::RTS0::v1::DescriptorRange)`, and the last field (currently `Flags`) will overlap with the next object.

Note: this may become moot depending on the fix to #145438, as that issue implies that we won't be able to have an inheritance relationship between the versions of DescriptorRange at all.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to