Skip to content

Recompiler: add an opt-in thread-limit mask for direct compute - #3015

Open
KDenKC wants to merge 2 commits into
xcl-dev:mainfrom
KDenKC:dispatchx-exec-mask
Open

KDenKC wants to merge 2 commits into
xcl-dev:mainfrom
KDenKC:dispatchx-exec-mask

Conversation

@KDenKC

@KDenKC KDenKC commented Nov 27, 2026

Copy link
Copy Markdown

Stacked on #2610 (review only the last commit)

What is in it

Add an opt-in direct-DXIL compute entry that masks lanes outside the requested thread dimensions. It ballots the per-axis bounds after the existing padding mask and intersects the result with EXEC. #2610 supplies the rounded dispatch counts and thread limits. The runtime selection will use this entry for partial groups in a follow-up.

Related: #1751 (BVH rehydration passes issue thread-dimension DispatchX with partial last groups), #1833 (world-load roadmap).

Why

A 200-second diagnostic run counted 2,999 partial-group dispatches in 3,009 thread-dimension DispatchX calls, across four pipelines in the last logged sample. The first appeared at world load. The unguarded-store test shows how extra lanes can write past the requested extent and checks that the mask suppresses them. The ordinary entry emits byte-identical DXIL. This translator source change triggers a one-time rebuild of existing direct-DXIL cache entries.

Tested

All at this head, 1208606b, release.

  • RTX 5090 (621.24), Ryzen 7 9800X3D, Windows 11. Wave32 and split-wave64 GPU readbacks passed. The GPU lacks native wave64, so that case prints SKIPPED here.
  • AMD Radeon Graphics iGPU. All four focused cases passed, including the native-wave64 GPU readback.
  • Compared ordinary translation against bytes captured on the D3D12.X: a DispatchX with thread dimensions launches whole groups #2610 parent, for wave32, split wave64 and native wave64. All three were byte-identical. The cross-run and cross-thread byte test also passed.
  • cargo build --workspace passed. cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_NETWORK=0, RTX 5090): 1,430 passed, 4 failed, 47 ignored, 27 SKIPPED. The 4 failures are the known fuzz_validate_and_gpu_0..3 (DXIL GPU fuzz tests reproducibly fail with E_OUTOFMEMORY on RTX 5060 #1905). The SKIPPED include the native-wave64 case on this GPU.

Regression run

main (08db8020, the base under #2610 and this change; the same block as in #2610's description):

xcl-smoke v1
commit: 08db8020d323bf478964fcc586152cce54959cfc
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2034 (PresentX 2034)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31275 MB

This PR (1208606b):

xcl-smoke v1
commit: 1208606bbe3a896a5677370b96dbec77aabbe333
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 200
exit: 0x0
frames shown: 2054 (PresentX 2054)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31614 MB

Both: the retail title, -Seconds 200, RTX 5090, a copy of the same precompiled cache, the same scripted input to the world load, full-size frame dumps. The main run used a never-used exe name; this head's run reused a warm one. The ordinary compute translation is unchanged (byte-identical DXIL) and the masked entry is not selected yet, so this is a regression check only.

AMD testing requested

On an AMD adapter with native wave64, run this from the branch in PowerShell with DXC available.

$env:XCL_NETWORK = '0'
$env:XCL_ADAPTER = 'amd'
cargo test -p xcl --lib gpu::dxil::dispatchx_tests:: -- --test-threads=1 --nocapture

Please share the adapter, driver and result, including whether dispatchx_native_wave64_masks_excess_lanes ran without a SKIPPED line.

Not tested

In-title behavior and first-use compile timing are for the runtime follow-up.

AI use

Codex (GPT-6.2-Sol) wrote the change, tests and description. Claude Code (Claude Opus 5.5) ran the independent validation on both adapters and the smoke pair.

🤖 Generated with Claude Code

https://claude.ai/code/session_013oPUFCA9W9F8Qb5MPK33bR

KDenKC and others added 2 commits November 25, 2026 18:15
DispatchX(x, y, z, flags) dropped its flags. With USE_THREAD_DIMENSIONS
(0x20; 0x8020 with the wave32 bit) x, y, z are thread counts: the console
launches ceil(count / numthreads) groups and leaves the lanes past the count
out of EXEC. XCL launched the counts as groups: 32-64x the groups for the
retail title's BVH builder (its rehydration and reload passes pass node and
primitive counts), past D3D12's 65,535 groups for a large mesh, and every
extra thread of the unguarded Box32/Box16 rehydration shaders wrote outside
its node array.

The flags now reach the dispatch (also one put off to the submit). With
0x20 the counts become whole groups of the pipeline's console numthreads
(kept with its user SGPRs at creation); a pipeline whose group shape is not
known is not launched, skipped and counted as an untranslated one. The
thread count of an axis that does not end on a whole group goes to io
slots 114..116 (IO_THREAD_LIMIT), where the compute prologue will leave
the lanes past it out of EXEC in a following change: until then the last
group still runs whole. Each kind of flags is logged once.

Part of a stack: EXEC masking of the last group follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Intersect the existing entry EXEC mask with DispatchX thread bounds in a separate compute entry. Keep ordinary compute emission unchanged. Cover excess-lane stores in 1-D, 2-D and 3-D, split and native wave modes, and ordinary translation byte identity. Runtime selection and precompile integration are separate work.

Assisted-by: Codex (GPT-6.1-Sol)
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