Skip to content

Cover PSO-only RT surface: recursion, RAY_FLAG_SKIP_CLOSEST_HIT_SHADER, callables#1279

Open
MarijnS95 wants to merge 1 commit into
llvm:mainfrom
Traverse-Research:rt-pso-tests-pso-only
Open

Cover PSO-only RT surface: recursion, RAY_FLAG_SKIP_CLOSEST_HIT_SHADER, callables#1279
MarijnS95 wants to merge 1 commit into
llvm:mainfrom
Traverse-Research:rt-pso-tests-pso-only

Conversation

@MarijnS95

@MarijnS95 MarijnS95 commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Depends on #1281

Summary

Three tests stacked on #1275 covering features that inline RT (RayQuery in compute) physically can't express — they're only reachable through a DispatchRays-driven RT pipeline.

  • trace-ray-recursion.test — closest-hit fires a secondary TraceRay from an above-the-triangle origin. First-level CH sees payload=0 → bumps to 0x1 → calls TraceRay. Second-level CH sees payload!=0 → writes 0x10. Unwinds: first-level OR's in 0x100. Final payload 0x110 (272 decimal). RayTracingPipelineConfig.MaxTraceRecursionDepth: 2 so both TraceRay calls are within budget.

  • ray-flag-skip-closest-hit.test — two lanes fire identical rays at the same triangle. Lane 0 uses RAY_FLAG_NONE so CH runs and writes 0xBEEF. Lane 1 uses RAY_FLAG_SKIP_CLOSEST_HIT_SHADER (PSO-only — inline RT has no equivalent) so CH is skipped and payload keeps its initial 0xAAAA. Output [0xBEEF, 0xAAAA].

  • callable-shader.test — two callable shaders writing distinct sentinels (0xAAAA / 0xBBBB). Each lane calls CallShader(Idx, ...) so the SBT callable region's per-record routing is exercised independently of the hit-group / miss routing already covered in Cover DispatchRays index/dimensions + SBT miss/hit-group routing #1277. Callable shaders themselves don't exist in inline RT.

    This test stays # XFAIL: Clang, Vulkan because DXC's -spirv backend lists every callable's IncomingCallableDataKHR variable in every callable entry point's interface, violating VUID-StandaloneSpirv-IncomingCallableDataKHR-04706 and getting rejected by vkCreateShaderModule. The framework's Vulkan SBT / callable path is correct — running spirv-opt --remove-unused-interface-variables on the DXC output cleans the SPIR-V and the test passes natively. Tracking the DXC fix upstream.

All three pass on Metal once the Metal bring-up (#1281) sets setMaxCallStackDepth(MaxTraceRecursionDepth) so nested TraceRay actually unwinds; with the default of 1 the second TraceRay was silently dropped and the recursion test produced 0x1 instead of 0x110. With #1281 rebased underneath, Metal is dropped from the XFAIL list on all three tests.

Test plan

Local on an NVIDIA RTX 3060:

  • Linux Vulkan (native offloader)
  • Linux D3D12 (Wine + vkd3d-proton + cross-compiled offloader.exe)
  • Windows Vulkan (native offloader.exe)
  • Windows D3D12 (native offloader.exe)

CI (RT-capable runners):

  • windows-nvidia D3D12 (RaytracingTier 1.2)
  • windows-intel VK (VK_KHR_ray_tracing_pipeline)
  • macOS Metal (supportsRaytracing)

Three tests stacked on llvm#1275 covering features that inline RT (RayQuery
in compute) physically can't express — they're only reachable through
a DispatchRays-driven RT pipeline.

  - `trace-ray-recursion.test` — closest-hit fires a secondary TraceRay
    from an above-the-triangle origin. First-level CH sees payload=0 →
    bumps to 0x1 → calls TraceRay. Second-level CH sees payload!=0 →
    writes 0x10. Unwinds: first-level OR's in 0x100. Final payload
    0x110 (272 decimal). `RayTracingPipelineConfig.MaxTraceRecursion-
    Depth: 2` so both TraceRay calls are within budget.
  - `ray-flag-skip-closest-hit.test` — two lanes fire identical rays at
    the same triangle. Lane 0 uses RAY_FLAG_NONE so CH runs and writes
    0xBEEF. Lane 1 uses RAY_FLAG_SKIP_CLOSEST_HIT_SHADER (PSO-only —
    inline RT has no equivalent) so CH is skipped and payload keeps its
    initial 0xAAAA. Output [0xBEEF, 0xAAAA].
  - `callable-shader.test` — two callable shaders writing distinct
    sentinels (0xAAAA / 0xBBBB). Each lane calls `CallShader(Idx, ...)`
    so the SBT callable region's per-record routing is exercised
    independently of the hit-group / miss routing already covered in
    llvm#1277. Callable shaders themselves don't exist in inline RT.

    This test stays `# XFAIL: Clang, Vulkan` because DXC's `-spirv`
    backend lists every callable's IncomingCallableDataKHR variable in
    every callable entry point's interface, violating VUID-Standalone-
    Spirv-IncomingCallableDataKHR-04706 and getting rejected by vk-
    CreateShaderModule. The framework's Vulkan SBT / callable path is
    correct — running `spirv-opt --remove-unused-interface-variables`
    on the DXC output cleans the SPIR-V and the test passes natively.
    Track upstream.

All three pass on Metal once the bring-up PR ahead of this commit sets
the raygen pipeline's `setMaxCallStackDepth(MaxTraceRecursionDepth)` so
nested TraceRay actually unwinds (with the default of 1, the second
TraceRay was silently dropped and the recursion test produced 0x1
instead of 0x110).

Locally verified on the user's Linux box:
  - Vulkan via the native offloader: recursion + skip-CH PASS;
    callable PASSes after spirv-opt cleanup (XFAILs from raw DXC SPIR-V
    as documented above).
  - D3D12 via Wine + vkd3d-proton + cross-compiled offloader.exe: all
    three PASS.
And on macOS 15 / metal-irconverter 3.1.1 via the native offloader:
  - All three PASS (recursion + skip-CH + callable).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@EmilioLaiso EmilioLaiso force-pushed the rt-pso-tests-pso-only branch from 866edb0 to 3241fb5 Compare June 26, 2026 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant