[HLSL] Implement prefix stable packing of semantic signatures
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This issue tracks the implementation of the prefix stable signature packing algorithm. This should be made available by a function that will take a mutable arrayref of signature elements and update the start row and start col so the elements to be packed into a grid.
It should be defined so that the optimal algorithm can re-use the co-packing behaviour.
The prefix stable algorithm iterates the elements in declaration order and co-pack elements in registers.
By co-pack it means that a register can contain multiple semantic elements. For example:
```hlsl
struct VSOut {
float fog : FOG;
float alpha : COLOR0;
float2 pos : SV_Position;
};
```
would result in a packed register:
```
reg0: FOG .x | COLOR0 .y | SV_Position .zw
```
There are some more rules regarding when co-packing is feasible, other than that the register has enough space, that need to be adhered to and can be found in the references.
For more comprehensive references:
- [Semantics Overview](https://github.com/llvm/wg-hlsl/blob/main/proposals/0040-semantics-overview.md#signature-packing-constraints)
- [DXIL Spec](https://github.com/microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#signature-packing)
AC:
- [ ] A function for the packing algorithm is defined in `llvm/Frontend/HLSL/SemanticSignatures.h`
- [ ] Unit testing of the packing is defined in `llvm/unittests/Frontend/HLSLSemanticSignaturePackingTest.cpp`
Contributor guide
Assessment
This issue has not been assessed yet.