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

DXIL Modifying recursive payload does not work #3414

Open
DBouma opened this issue Feb 1, 2021 · 3 comments
Open

DXIL Modifying recursive payload does not work #3414

DBouma opened this issue Feb 1, 2021 · 3 comments
Assignees
Labels
bug Bug, regression, crash
Milestone

Comments

@DBouma
Copy link

DBouma commented Feb 1, 2021

When doing recursions in a closest hit shader, modifying the inout payload does not seem to update the payload. However creating a new payload and assigning it with the incoming payload for recursions does work.

Note that this behavior only happens on dxil, on spirv this seems to work fine.

#define RECURSION_DEPTH 30
#define BUGGED 1

struct Payload {
    uint4 data0;
};

RaytracingAccelerationStructure tlas : register(t0, space0);

[shader("closesthit")] void
main(inout Payload payload, in BuiltInTriangleIntersectionAttributes attribs) {
    float3 dir = WorldRayDirection();

    RayDesc ray;
    ray.Origin = WorldRayOrigin() + dir * RayTCurrent();
    ray.TMin = 0.1;
    ray.Direction = float3(dir.x, dir.y, -dir.z);
    ray.TMax = 1000.0;

#if BUGGED
    payload.data0 += uint4(1,1,1,1);

    if (payload.data0.x < RECURSION_DEPTH) {
        TraceRay(tlas,
                RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
                    0, // flags
                0xff,  // instance inclusion mask
                0,     // RayContributionToHitGroupIndex
                1,     // MultiplierForGeometryContributionToHitGroupIndex
                0,     // MissShaderIndex
                ray, payload);
    }
#else
    Payload new_payload;
    new_payload = payload;
    new_payload.data0 += uint4(1,1,1,1);

    if (new_payload.data0.x < RECURSION_DEPTH) {
        TraceRay(tlas,
                 RAY_FLAG_FORCE_OPAQUE | RAY_FLAG_CULL_BACK_FACING_TRIANGLES |
                     0, // flags
                 0xff,  // instance inclusion mask
                 0,     // RayContributionToHitGroupIndex
                 1,     // MultiplierForGeometryContributionToHitGroupIndex
                 0,     // MissShaderIndex
                 ray, new_payload);

        payload = new_payload;
    }
#endif
}
@Dredhog
Copy link

Dredhog commented Oct 1, 2021

@pow2clk hope you can help, would it be possible to evaluate and bump the priority on this case?

At Unity we're getting reports from our users about this after updating DXC to the latest release, this is a regression that can cause visual differences and even freezes.

@llvm-beanz llvm-beanz added the needs-triage Awaiting triage label Jun 29, 2023
@llvm-beanz
Copy link
Collaborator

The DXIL generation looks correct to me. We are generating a store to the payload so I'm unsure why this would fail.

@tex3d, @pow2clk, any thoughts here?

godbolt link

@damyanp damyanp added bug Bug, regression, crash and removed needs-triage Awaiting triage labels Apr 16, 2024
@damyanp damyanp added this to the Dormant milestone Apr 16, 2024
@damyanp
Copy link
Member

damyanp commented Apr 16, 2024

Moving to Dormant. @tex3d / @pow2clk, next step would be to look into llvm-beanz's question above. @DBouma - if this is no longer an issue for you then please feel free to close this one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug, regression, crash
Projects
Status: Triaged
Development

No branches or pull requests

6 participants