microsoft / microsoft/DirectXShaderCompiler
lib_ target: SV_PrimitiveID is disallowed during GSVIn
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
SV_PrimitiveID can't be used as input in a geometry shader when compiled with lib_ and then linked to gs_.
Steps to Reproduce
//dxc -T lib_6_3 -> IDxcLinker gs_6_3
// Per-vertex data from the vertex shader.
struct GeometryShaderInput
{
min16float4 pos : SV_POSITION;
min16float3 color : COLOR0;
uint instId : TEXCOORD0;
};
// Per-vertex data passed to the rasterizer.
struct GeometryShaderOutput
{
min16float4 pos : SV_POSITION;
min16float3 color : COLOR0;
uint rtvId : SV_RenderTargetArrayIndex;
};
// This geometry shader is a pass-through that leaves the geometry unmodified
// and sets the render target array index.
[maxvertexcount(3)]
[shader("geometry")]
void GS(triangle GeometryShaderInput input[3], uint j : SV_PrimitiveID, inout TriangleStream<GeometryShaderOutput> outStream)
{
GeometryShaderOutput output;
[unroll(3)]
for (int i = 0; i < 3; ++i)
{
output.pos = input[i].pos;
output.color = input[i].color;
output.rtvId = input[i].instId & j;
outStream.Append(output);
}
}
The error actually comes from the linker itself, not the lib compilation.
Actual Behavior
Same behavior as when compiled with gs_ (no error and similar binary after linking).
Environment
- DXC version: Latest
- Host Operating System: N/A.
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 IDxcLinker path that links a lib_6_3 shader to gs_6_3 and handles SV_PrimitiveID during GSVIn validation. Reproduce the supplied geometry-shader case, then verify that linking reports the disallowed input instead of accepting it; compare the result with direct gs_ compilation.
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
- 45/100