Skip to content

Unflattened RayDesc breaking HL->DXIL lowering #7434

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

Closed
simoll opened this issue May 7, 2025 · 1 comment · Fixed by #7440
Closed

Unflattened RayDesc breaking HL->DXIL lowering #7434

simoll opened this issue May 7, 2025 · 1 comment · Fixed by #7440
Labels
bug Bug, regression, crash needs-triage Awaiting triage

Comments

@simoll
Copy link
Contributor

simoll commented May 7, 2025

ScalarReplHLSL is missing transforms for some RayDesc users, making the RayDesc flattening unreliable. However, the RayDesc has to be flattened in the HL op parameter lists or the DXIL opcode translation will fail.

Steps to Reproduce
HLSL shaders (raygen) with the following snippet will fail. The HitObject::TraceRay prevents the flattening of the RayDesc.

    dx::HitObject hit1 = dx::HitObject::MakeMiss(RAY_FLAG_NONE, 0, ray);
    dx::MaybeReorderThread(hit1);
    dx::HitObject hit2 = dx::HitObject::TraceRay(topObject, RAY_FLAG_SKIP_TRIANGLES, 0xFF, 0, 0, 0, ray, payload);
    dx::MaybeReorderThread(hit2);

Actual Behavior
Assert/crash in TranslateHitObjectMake as the RayDesc isn't flattened in the MakeMiss HL op.

@simoll simoll added bug Bug, regression, crash needs-triage Awaiting triage labels May 7, 2025
simoll added a commit to simoll/DirectXShaderCompiler that referenced this issue May 7, 2025
ScalarReplHLSL will refuse to faltten RayDesc if some users are
incompatible. This is at odds with HLOperationLower, which always
expects a specific flattened form.
This implements explicit RayDesc flattening in ScalarReplHLSL to make this more reliable. One issue with RayDesc-from-cbuffer in RayQuery remains and is documented with a test.

Implement ScalarReplHLSL handling for RayDesc param in HL ops:
- HitObject::MakeMiss [RewriteCallArg]
- HitObject::TraceRay [RewriteCallArg]
- TraceRay            [RewriteCallArg]
- RayQuery::TraceRayInline [unchanged - flatten to RayDesc elements]

In the process:
- Fix copyout code in RewriteCallArg (ScalarReplHLSL)
- Remove obsolete tests that expected a RayDesc alloca (where RayDesc is
  now SROA'd entirely)
- Document RayQuery lowering bug when RayDesc is taken directly from
  cbuffer.

Closes microsoft#7434  Unflattened RayDesc breaking HL->DXIL lowering microsoft#7434
@tex3d tex3d closed this as completed in 053e7ac May 16, 2025
@github-project-automation github-project-automation bot moved this to Triaged in HLSL Triage May 16, 2025
@tex3d
Copy link
Contributor

tex3d commented May 17, 2025

Closed by #7440.

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
2 participants