microsoft / microsoft/DirectXShaderCompiler
[DXIL] Broken codegen for loading elements from FP16 matrix types in StructuredBuffer
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
On latest main I get the wrong result when loading elements from fp16 matrix types stored in structured buffers.
struct Data
{
float16_t4x4 a;
};
StructuredBuffer<Data> buf : register(t1);
...
float16_t2 b = buf.a[0].xy;
This loads elements a[0][0] and a[0][2], not a[0][1] as expected.
Looking at the generated code it looks like it thinks there is 4B between each element not 2B.
See attached example HLSL and generated DXIL.
dxc-float16_t4x4-example.zip
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the attached dxc-float16_t4x4-example.zip and inspect the generated DXIL for the StructuredBuffer access in the provided HLSL. Reproduce the load of buf.a[0].xy and trace the element offset calculation; done means the generated code loads adjacent FP16 elements at 2-byte spacing and produces the expected values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100