microsoft / microsoft/DirectXShaderCompiler
[SPIR-V] Output semantic can be written to multiple times
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
struct S1 {
float4 a;
float4 b;
};
struct S2 {
float a;
float b;
};
S2 main(S1 s : SV_Position) : SV_Depth {
S2 o = { s.a.x, s.b.y };
return o;
}
Actual Behavior
Targeting DXIL, this fails because SV_Depth appears twice in the signature.
Targeting SPIR-V, this compiles, and the FragDepth builtin is written to twice.
Building the same shader by moving the semantics into the fields yields an error:
struct S1 {
float4 a;
float4 b;
};
struct S2 {
float a : SV_Depth;
float b : SV_Depth;
};
S2 main(S1 s : SV_Position) {
S2 o = { s.a.x, s.b.y };
return o;
}
error: output semantic 'SV_Depth' used more than once
The spec doesn't seem clear on what's legal and what's not. But the fact that we allow an implicit duplication while disallowing an explicit one seems to be an oversight.
(Filled https://github.com/microsoft/hlsl-specs/issues/515 for the spec part)
Environment
- DXC version: f94396ddffa8562a00d64a1db58d3f73f33b655a
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
Reproduce the two HLSL examples from the issue while targeting DXIL and SPIR-V, and compare the handling of repeated SV_Depth outputs. Trace the semantic validation and SPIR-V emission paths; done means the implicit duplication is handled consistently with the explicit case and regression coverage verifies the behavior.
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
- 35/100