Skip to content

Shaders: preserve first active lane reads across divergent switches - #2192

Draft
gloger2003 wants to merge 1 commit into
xcl-dev:mainfrom
gloger2003:fix/dxil-first-active-lane
Draft

gloger2003 wants to merge 1 commit into
xcl-dev:mainfrom
gloger2003:fix/dxil-first-active-lane

Conversation

@gloger2003

Copy link
Copy Markdown

Part of #1833. Follow-up to #1679. On a Radeon RX 7800 XT, the direct DXIL read of the first active lane can return a value from a later divergent switch case. That case should see the value captured before the switch.

What is in it

  • For i32, keep the first active lane's bits and broadcast them with a bitwise OR reduction. Other types continue to use the existing intrinsic.
  • Add a standalone GPU regression for seed 722. The existing source hash invalidates cached DXIL.

Tested

  • Windows x64, Ryzen 7 5700X, Radeon RX 7800 XT. Clean main produced one wrong result for seed 722. The standalone test and a direct DXIL GPU divergence test both passed with the patch.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output with XCL_DXIL_CACHE pointing to a writable directory reported 1154 passed, 1 failed, 46 ignored. Runtime skips: 7 (gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu, gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu, heap_window_out_of_memory_falls_back_to_the_switch_form). Seed 783 also produced mismatches on clean main. The HLSL mesh cache-only test passed separately on both revisions with a writable cache, after both had failed using the default directory in this environment.

Regression run

Minecraft Preview, 90 seconds per build, 1x MSAA and XCL_DIRECT_DXIL=all, with separate fresh caches. An earlier 30-second pair reached only 42 frames on main and ended before the candidate entered the title, so the comparison uses a longer matched run.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 7800 XT
title: c22a3829
seconds: 90
exit: 0x0
frames shown: 4847 (PresentX 4847)
presents per 2 s (last 3): 120 120 120
device removals: 0
crashes: 0
peak commit: 3344 MB
xcl-smoke v1
commit: 1d8341aba280c329e184a78869dc8d2327c81504
gpu: AMD Radeon RX 7800 XT
title: c22a3829
seconds: 90
exit: 0x0
frames shown: 5256 (PresentX 5256)
presents per 2 s (last 3): 120 120 120
device removals: 0
crashes: 0
peak commit: 3344 MB

Not tested

Other GPU drivers, retail world entry, and performance of workloads that use this operation more frequently.

AI use

OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode) investigated the mismatch, compared implementations, wrote the patch and regression test, ran validation, and drafted this description.

Broadcast the first active lane i32 value with a masked wave reduction. On the RX 7800 XT the original opcode returns a case-local value in fuzz seed 722. Pin that case in a standalone test.

Assisted-by: OpenAI Codex (GPT-6.2 Sol, high reasoning effort, Fast mode)
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.

2 participants