microsoft / microsoft/DirectXShaderCompiler
GetAttributeAtVertex() doesn't work on function parameters
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
When using an array member of a VS interpolant structure, GetAttributeAtVertex fails to compile.
Steps to Reproduce
// dxc.exe repro.hlsl /Tps_6_1 /EMainPS
cbuffer Globals : register (b0)
{
int GIndex;
};
struct Interpolants
{
float3 BaryWeights : SV_Barycentrics;
nointerpolation float4 PackedTexCoords[1] : COLOR0;
nointerpolation uint PrimitiveId : PRIMITIVE_ID;
};
float4 GetUV(Interpolants vs, int index)
{
float4 a1 = GetAttributeAtVertex(vs.PackedTexCoords[index], 0);
float4 a2 = GetAttributeAtVertex(vs.PackedTexCoords[index], 1);
float4 a3 = GetAttributeAtVertex(vs.PackedTexCoords[index], 2);
return a1 * vs.BaryWeights.x + a2 * vs.BaryWeights.y + a3 * vs.BaryWeights.z;
}
[RootSignature("CBV(b0)")]
float4 MainPS(Interpolants vs) : SV_Target0
{
float4 x = GetUV(vs, 0); // FAIL
return x;
}
Actual Behavior
gaav-repro.hlsl:19:14: error: attribute evaluation can only be done on values taken directly from inputs.
float4 a3 = GetAttributeAtVertex(vs.PackedTexCoords[index], 2);
^
gaav-repro.hlsl:18:14: error: attribute evaluation can only be done on values taken directly from inputs.
float4 a2 = GetAttributeAtVertex(vs.PackedTexCoords[index], 1);
^
gaav-repro.hlsl:17:14: error: attribute evaluation can only be done on values taken directly from inputs.
float4 a1 = GetAttributeAtVertex(vs.PackedTexCoords[index], 0);
^
Note that moving the GetAttributeAtVertex calls to be inside MainPS can compile successfully.
Environment
- DXC version dxcompiler.dll: 1.7 - 1.7.2308.7 (69e54e290); dxil.dll: 1.7(101.7.2308.12)
- Host Operating System Windows 11
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 by compiling the provided repro.hlsl with dxc.exe using /Tps_6_1 and /EMainPS, comparing GetUV(Interpolants vs, int index) with the working calls inside MainPS. Trace the compiler handling of GetAttributeAtVertex when its input is a function parameter and verify that the repro compiles successfully without the attribute-evaluation errors.
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
- Clearly specified
- Newbie friendliness
- 45/100