microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] fatal error: generated SPIR-V is invalid: ID decorated with RelaxedPrecision multiple times is not allowed.
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
Loop unrolling causes duplicate decoration when the phi instruction is decorated. This is due to a bug in spirv-opt: https://github.com/KhronosGroup/SPIRV-Tools/issues/6689
I've already provided a fix for the bug in spirv-tools: https://github.com/KhronosGroup/SPIRV-Tools/pull/6690
But this will need to merged once the issue is fixed.
Steps to Reproduce
This is a simple shader that reproduces the issue:
RWStructuredBuffer<float> outp;
StructuredBuffer<float> inp;
[numthreads(1, 1, 1)]
void main() {
min16float acc = 0;
[unroll] for (uint i = 0; i < 8; i++) {
min16float x = (min16float)inp[i];
acc = min(acc, x * x);
}
outp[0] = acc;
}
You can check it out here: https://godbolt.org/z/eT7dr797f
Actual Behavior
The compiler produces this output:
fatal error: generated SPIR-V is invalid: ID '11' decorated with RelaxedPrecision multiple times is not allowed.
%11 = OpExtInst %float %1 NMin %23 %24
note: please file a bug report on https://github.com/Microsoft/DirectXShaderCompiler/issues with source code if possible
Compiler returned: 5
Environment
The issue occurs in dxc 1.10 and 1.9, but not in 1.8
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 supplied HLSL reproducer and the linked SPIR-V Tools issue and pull request. Confirm the duplicate RelaxedPrecision decoration in dxc 1.9 or 1.10, then track the SPIR-V Tools fix and its integration into DirectXShaderCompiler. Done means the reproducer no longer produces invalid SPIR-V.
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
- Mostly clear
- Newbie friendliness
- 25/100