<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121010>121010</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Treat structures in resources as packed
</td>
</tr>
<tr>
<th>Labels</th>
<td>
HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
bogner
</td>
</tr>
</table>
<pre>
Structures in HLSL's StructuredBuffer need to be treated as packed, or otherwise made to skip adding any padding for compatibility with DXC.
Note: `dxc` does this by [hacking padding off](https://github.com/microsoft/DirectXShaderCompiler/blob/v1.8.2407/tools/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp#L277) of *all* structures in CGRecordLowering::lower, like so:
```c++
#if 0 // HLSL Change - No padding for structure. Array offset will be handled when load/store is called
Members.push_back(StorageInfo(Size, getIntNType(8)));
clipTailPadding();
determinePacked(NVBaseType);
insertPadding();
Members.pop_back();
calculateZeroInit();
#endif // HLSL Change End
```
This is obviously not how we should handle this in upstream.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJx8VN1u4zYTfRr6ZhCBoizJvtCFnHzaL0AaLJqgWPSmoMiRxJriCCQV1336graTzRaLAgOIP8MzR2d-ZAhmdIgNKw-sfNjINU7km55Gh37Tkz43L9GvKq4eAxgH_396eWKiDvBxrA_rMKAHh6ghEvQI0aOMqEEGWKQ6ombiHsgDxQn9yQSEWWpMzuFoFpBaGzeCdGdYbuuBPCiaFxlNb6yJZziZOMHDt_uM8Zbx9pkisqIFVnH9l2IVB00YIE4mQH8GVh4mqY4J6h2ShoGVD0zsphiXwIqWiY6JbjRxWvtM0cxENxvlKdAQmegejEcVv71MUqO_p3kxFj0TXW-pZ6J7y7NdJra8ZqKLRDYw0Skr3chEZ03yuCeNX9Cl1ZdfUZHXT_JMazysxmr0mVoWJoonUddM7IEGYKKV1jLRQvhB84_ndEJv3Ji4F61NuySsNUeEQOmUt6ziV1NMHJLxlonCDMDh-r-XDML9JN2IcAfP9IPmH4EzaL2X56RawAgnY23K7CSdtqjhNKEDS1Iz0YVIHsEEUNJa1Iy3AL_g3KMP2bKG6Y9eqiMTu5dIXo746AZKO_M3JvYjxkcXn1_PCzKx2zGxv1lxuCApa5ZXaezXK0smdp8uNUb0s3H49VZmu-ffDjLgFe3dzbiAPv4U4IMnLe80P8eWVq1WRvwdPT06Ez9fM1Gg02b4ma7_c_pzLq4l-5pq0wSg_s3QGuwZHEWY6AQnhDDRavVN32sZGwfrElIvzdlGN4XeF3u5wSavi-1-X3Geb6amUHWZl7wuVVnVg9oXKi-rquaD6oe-V_3GNIKLbS5EIQrBeZ5VqHpelfsaq63IB2RbjrM0NrP2bc7IjxsTwopNLnKe842VPdpwmQ9CXLtfpEnhm-R_169jYFtuTYjhO0I00V5myuVB-QCvaSL8q6w9Blq9wvB9TmxWb5v_6M8U4Pa5Wzz9iSp16oVv6r8b5bdG_BMAAP__ub6NXw">