Skip to content

[SPIR-V] Generates OpCapability RayQueryKHR when an RTAS is visible (and unused) in miss shaders #6917

Closed

Description

Description
Certain shaders such as miss shaders don't allow further recursion when tracing rays.
A problem happens when miss and other type of shaders are mixed. A closesthit shader might access the resource, but miss shader doesn't.
In that case, emitting OpCapability RayQueryKHR is problematic and excludes the pascal generation since they don't have this capability.

Steps to Reproduce

struct ColorPayload { float a;   };
RaytracingAccelerationStructure test;
[shader("miss")]
void mainMiss(inout ColorPayload payload) { }

Actual Behavior
Only when the miss stage (or callable if shooting rays there isn't allowed?) accesses the RTAS it should turn on this capability.

Environment

  • DXC version: Latest from GH
  • Host Operating System: N/A.

Activity

  1. added
    bug
    needs-triage
    spirv
    on Sep 15, 2024
  2. s-perron commented on Sep 16, 2024

    @s-perron
    Collaborator

    Nielsbishere (@Nielsbishere) We need more detailed information on how to reproduce the problem. When I try to compile your example with the latest DXC, I do not see the RayQuery capability being used: https://godbolt.org/z/Kfvn1c888.

  3. s-perron commented on Sep 16, 2024

    @s-perron
    Collaborator

    I can reproduce the issue if optimizations are turned of (-O0). This is because we see the OpTypeAccelerationStructureKHR is still in the spir-v, and we opt to use it the RayQuery capability to enable it. This is a difficultly in DXC. When a feature can be enabled by multiple capabilities, we cannot know which one to use.

    This can be worked around by specifically adding the allowed extensions on the command line: https://godbolt.org/z/nccj7fWGP.

  4. Nielsbishere commented on Sep 16, 2024

    @Nielsbishere
    ContributorAuthor

    Hmm, that must've been it. I can't seem to reproduce it without -O0 either. Maybe a leftover binary or something that was compiled with debug. I guess I should explicitly disable it like you're showing when RayQuery isn't enabled.

    EDIT: Ah, it seems it has been fixed because I added the explicit -fspv-extension=SPV_KHR_ray_tracing a couple days ago

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

Metadata

Metadata

Labels

bugneeds-triagespirv

Type

No type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions