Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erroneous gradients warning when indexing to an array of textures #6587

Open
godlikepanos opened this issue May 6, 2024 · 2 comments
Open
Labels
bug Bug, regression, crash needs-triage Awaiting triage
Milestone

Comments

@godlikepanos
Copy link
Contributor

Description
Getting the following warning which I think it's incorrect warning: Gradient operations are not affected by wave-sensitive data or control flow. [-Winline-asm]

Steps to Reproduce
Following was built with -T ps_6_6 -E PSMain

struct PSInput
{
    nointerpolation int dynamicallyUniformIndex : IDX; // Same value for the whole drawcall
    float2 uv : UV;
};

Texture2D texes[100];
SamplerState sam;

float4 PSMain(PSInput input) : SV_Target0
{
    int idx = WaveReadLaneFirst(input.dynamicallyUniformIndex); // Scalarize
    float4 val = texes[idx].Sample(sam, input.uv);
    return val;
}

Actual Behavior
The idx is used to select a texture and it shouldn't affect the gradients. I don't think the warning is correct.

Environment

  • DXC version: DXC trunk & 1.8.2403
  • Host Operating System: Any
@godlikepanos godlikepanos added bug Bug, regression, crash needs-triage Awaiting triage labels May 6, 2024
@devshgraphicsprogramming

You are indeed correct that the UV is the same, ergo the derivatives should be too, also that a shading quad needs to have the same subgroup.

However, due to HLSL's syntax, you have a reference to a texture constructed first, and then the Sample is the method. So it might be quite difficult to make the compiler catch up on what you're doing and thats its safe here.

@llvm-beanz
Copy link
Collaborator

Looks like a bug in the diagnostic. Godbolt link.

@llvm-beanz llvm-beanz added this to the Dormant milestone May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash needs-triage Awaiting triage
Projects
Status: Triaged
Development

No branches or pull requests

3 participants