<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/146735>146735</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [DirectX] Incorrect format metadata when using `Buffer<double>` or `Buffer<int64_t>`
        </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>
    HLSL allows `Buffer` and `RWBuffer` of `double`, `int64`, or 2-element vectors of the same, but when lowering these to DXIL they use 32-bit accesses to the buffer itself and convert the value as needed.

However, we emit the format metadata for a buffer based on what's stored there, not how we use it, so for `Buffer<double2> In` we currently see from clang:
```
 ; Name Type  Format         Dim      ID      HLSL Bind Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ---------
; In                                texture f64         buf      T0             t0         1
```

This does not match dxc, which gives:
```
; Name                                 Type Format         Dim      ID      HLSL Bind  Count
; ------------------------------ ---------- ------- ----------- ------- -------------- ------
; In                                texture     u32 buf      T0             t0     1
```

Note the `u32` format here.

We need to make sure that `dxil::ResourceTypeInfo::getTyped()` has the correct `ElementTy` in these cases.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJy8VE1v2zgT_jX0ZWCDor7igw52HKMGgh76BmhvLyhyJHFLkQE_7PjfL0g5Ddp0N7uXHRgQZ4bzwWc8D_dejQaxI_We1IcVj2GyruvtaNCteiuv3afH_z0C19pePJCG7uMwoCMNBW5kMnz5-mayQ7JIG3uNpKGE3SddmdBUN9U6YGvUOKMJcEYRrPMpLEwIns-Y7vQxwGVCA9pe0CkzJq9HCBYO306PSbtC9AglW_cqABcCvUefLqQ8fe4HVPCoh9ymsOaMLmTvmeuIwD0YRIlyQ-iO0N0ne8EzulT-goCzWi4P1s08wIyBSx540oG_Fui5RwnWwGXigbDWgw_WoUyRLr_E2ACTvaSUqV8VktHbnOYNy_J-QYyR8gFOJgF5QRDROTRBX8EjwuDsDEJzM5Iy9ZvgXH50B6Tcw2c-IzxdnxHguDT9Kgc1L4fTYfnmie6VkXBvowkpW7mH9d8KvD_Cb9zwV1G3IicDH0jAlxAdwtBUP2x9HJbDE_357pta_IIJobunSXmQFn0ew8yDmEC-iDziSYkJRnVG_x7OH2h-JBntfw72f4X2v4Y6SSzZRzD_BuLPNmDeE9LQWLL0z71tTNqA22p9xbxqaTtn_h3Bp5ph4iFzxYvSaQTl7gt6G53AhOrJDHaxjhiSQRJ2R9g2FZi4zyWFdQ5FTvKw8MnTNfmVudGF4B79ZiW7Um7LLV9hV7R1UbVF01arqSv4XUtlw1u-bfpWMlnUNQ5ywHZ7J5oCV6pjlNW0payo66qsNgUVtKUoBWVVVWwrUlGcudIbrc_zxrpxpbyP2BVV05b1SvMetc_MyljPxXc0kpS7g0ptfyOMJcJ1XQpe93H0pKJa-eDf0gUVdKbm15j6ACfz-vBfuSlTZvSJL99zCykfMkH_zDuZmf8fFucqOt1NITznnWBHwo6jClPsN8LOhB1TW7fP-tnZP1AEwo75yZ6w4-3V5479GQAA__9c6sdZ">