[HLSL] Implement the `SV_ViewID` semantic
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Add `SV_ViewID` to the list of parsed semantics. It is valid as an input to the vertex or pixel shader and requires Shader Model 6.1. Then lower as follows:
DXIL: `ViewID` op (`dx.op.viewID`, opcode 138).
SPIRV: `ViewIndex` built-in load.
Reference [here](https://github.com/llvm/wg-hlsl/blob/main/proposals/0040-semantics-overview.md#system-value-constraints) for its type constraints. Reference the [vertex](https://github.com/llvm/wg-hlsl/blob/main/proposals/0040-semantics-overview.md#vertex-shader)/[pixel](https://github.com/llvm/wg-hlsl/blob/main/proposals/0040-semantics-overview.md#pixel-shader) shader sections for packing info and where valid.
An offload test already exists for this intrinsic.
AC:
- [ ] Add the semantic spelling in `Attr.td`
- [ ] Update `CGHLSLRuntime` to handle the semantic spelling
- [ ] Update `SemaHLSL` to add additional diagnostics
- [ ] Update shader flag analysis to set the `ViewID` flag when this semantic is present
- [ ] Add LIT testing of sema and codegen
Contributor guide
Assessment
This issue has not been assessed yet.