<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145438>145438</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[DirectX] RootSignature's `v2::DescriptorRange` is misordered
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:DirectX
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bogner
</td>
</tr>
</table>
<pre>
We currently have the `v2::DescriptorRange` inherit from the `v1::DescriptorRange` and add a `Flags` field, but this is incorrect. In both the 1.0 and 1.1 root signature formats, the `OffsetInDescriptorsFromTableStart` comes last. That is, `v1::DescriptorRange` is laid out as follows:
```c++
struct DescriptorRange {
uint32_t RangeType;
uint32_t NumDescriptors;
uint32_t BaseShaderRegister;
uint32_t RegisterSpace;
uint32_t OffsetInDescriptorsFromTableStart;
};
```
This matches what we have today, but `v2::DescriptorRange` is laid out like so:
```c++
struct DescriptorRange {
uint32_t RangeType;
uint32_t NumDescriptors;
uint32_t BaseShaderRegister;
uint32_t RegisterSpace;
uint32_t Flags;
uint32_t OffsetInDescriptorsFromTableStart;
};
```
This *does not* match what we have today, as we have the `OffsetInDescriptorsFromTableStart` and `Flags` fields reversed. This causes obvious issues when we feed shaders that have root signatures with descriptor ranges into any driver.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VFGL4zYQ_jXyy3BGluM4efBDtkvgXlrYDbRvRZbGtnqyFTTjhPz7Iie5vW64LoWlILDRzHya-Wa-0USunxAbUT2J6jnTMw8hNm3oJ4xZG-yl-R3BzDHixP4Cgz4h8IAg1vKkRLkT5e4ZyUR35BBf9NSjWEtw04DRMXQxjN_di5-668mCthZ08tt73VO67Rx6K9Qv0M4MPDiCdCYTYkTDOXydoA08LPhFfkUp8gJiCAypLM1zROhCHDVTArpl8lvXEfLX6S0T2scwHnTr8ZV15PS6CSMSeE2cw2HQDG6B-PdCXIpwFsLMoAm64H04U3KXO7GW12OEekpH7ojjbBjeAYGokxFgdhOX6k-G5fpwOaIo31l-nccfqngwP2nC10FbjC_YO2KMDy53w-tRm0f8j6laIkT9fPu5F5n-5e6QujZqNgMSnBOLZ7zNULD6cm_uB8P0A6nefUOg8H8z-nmEXqf7HepnsCzUzgYkmAILtbuS_hPKNb3d_QdFJH096JMg4gkjoU0ycQRGz4QEoT25MCfJ0rz0Hqf0aIdogRYCCThlt6TxT8kSnB0PYL8nAzG1K4mfA-jpAja6E8Y8s01pt-VWZ9gUdSVrpUq5zYamQFN3pdyq7UbKDSq52WyLVdVijajaqs5co6Sq5FqVqlxVcpNX7bpdmc50laqw2BRiJXHUzufen8Y8xD5bKmmKVbUqN5nXLXpatqZSrTbfcLJpel1aTX8IpdIyjU0K_tLOPYmV9I6Y3uDYsV_W7j2meoaXEPj1zoJQNX2sjNFRiBYj2myOvhmYj8u-UXuh9r3jYW5zE0ah9unl2-fLMYa_0LBQ-2t_hNrfCjs16u8AAAD__2fB--o">