Skip to content

[SPIR-V] Verify behavior of GetAttributeAtVertex #6383

Closed

Description

Description
Follow-up from #6041 (comment)

Steps to Reproduce

dxc -T ps_6_6 -spirv
float foo(int c, float v) {
  if (c == 0)
    return GetAttributeAtVertex(v, 1);
  else
    return v;
}

float4 main(nointerpolation float a : A) : SV_Target
{
  float tmp1 = GetAttributeAtVertex(a, 2);
  float tmp2 = foo(0, a);
  float tmp3 = foo(1, a);
  return float4(0, 0, 0, tmp1 + tmp2 + tmp3);
}

Actual Behavior
Once #6041 is merged, the above sample will successfully compile for both DXIL and SPIR-V, however, as Nathan Gauër (@Keenuts) mentioned:

DXIL seems to only call the intrinsic for tmp1 and tmp2, but tmp3 gets loaded as usual, but with an undefined vertex index. While for SPIR-V, we default to the index 0.

Expected Behavior
We should determine whether this behavior is well-defined for DXIL then verify that that SPIR-V backend implementation is matches.

Activity

  1. added
    bug
    spirv
    needs-triage
    on Mar 4, 2024
  2. pow2clk commented on Mar 5, 2024

    @pow2clk
    Collaborator

    I'm surprised we don't see errors for this since it's calling GetAttributeAtVertex from a subfunction.

  3. sudonatalie commented on Mar 5, 2024

    @sudonatalie
    CollaboratorAuthor

    Gregory Roth (@pow2clk) If calling GetAttributeAtVertex outside the main entrypoint function is illegal, adding a check and error messaging for that would resolve a lot of our issues, but we didn't find any docs explicitly stating that. It looks like the compiler allows it (with various degrees of functionality) for both DXIL and SPIR-V right now.

  4. sudonatalie commented on Mar 26, 2024

    @sudonatalie
    CollaboratorAuthor
  5. added 3 commits that reference this issue on Mar 27, 2024
    0e5725c
    76ddab0
    27b87b7
  6. Keenuts commented on Apr 3, 2024

    @Keenuts
    Collaborator

    This is now fixed (27b87b7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugspirv

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions