Skip to content

Recompiler: emit direct quad ops for quad-local PS swizzles and DPP - #2316

Open
saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:dxil/ps-quad-lane-reads
Open

saintwolf wants to merge 1 commit into
xcl-dev:mainfrom
saintwolf:dxil/ps-quad-lane-reads

Conversation

@saintwolf

@saintwolf saintwolf commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Direct DXIL pixel shaders previously routed every quad-local ds_swizzle_b32, DPP16, and DPP8 read through Lw::rla(), emitting 5 WaveReadLaneAt, 1 WaveActiveBallot, 4 QuadReadLaneAt, and ~40 bit/select ops only to discard the cross-wave path via same_quad. Because wave intrinsics are not ReadNone, opt.rs DCE could not remove the unused cross-wave calls. DPP16 also emitted non-foldable ROW_MASK/BANK_MASK shifts even for 0xF/0x0 and SGe/imax checks for always-valid controls.

This lowers quad-local reads in pixel shaders directly to dx.op.quadOp (ReadAcrossX/Y/Diagonal), single dx.op.quadReadLaneAt broadcasts, identity pass-through, or minimal distinct dx.op.quadReadLaneAt selects (keeping WaveReadLaneAt in non-pixel stages), and folds constant DPP16 mask/validity checks across all stages. Part of #1269.

What is in it

  • crates/xcl/src/gpu/dxil/lanes.rs: add Lw::quad_lane and Lw::read_lane_quad (superseding read_quad_permutation from a50fa7ab with full QuadOp / QuadReadLaneAt lowering).
  • crates/xcl/src/gpu/dxil/lower_mem.rs: add swizzle_quad_map (quad permute 0x8000..=0xBFFF and quad-preserving bit-mode < 0x8000) and route ds_swizzle_b32 through read_lane_quad / quad_lane.
  • crates/xcl/src/gpu/dxil/lower_valu.rs: add dpp16_quad_map (0x000..=0x0FF, 0x160..=0x163) and dpp8_quad_map, route quad-local DPP16/DPP8 through read_lane_quad, and specialize constant ROW_MASK/BANK_MASK, FI=1, and always-valid DPP16 controls.
  • crates/xcl/src/gpu/dxil/core_tests.rs: add ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops (validation + intrinsic counts for PS wave32/wave64 and VS), gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl (fullscreen + diagonal helper-lane GPU parity vs HLSL, gated on wave32_supported() + DXC so WARP/no-GPU CI skips cleanly, with S_WQM_B32 in the diagonal helper-lane pass), and gpu_direct_dpp16_row_bank_masks_and_fi_zero (gated on wave32_supported() + DXC).

Tested

  • Hardware and toolchain: NVIDIA GeForce RTX 4070 SUPER (12 GiB, driver 32.0.16.2140, wave32), AMD Ryzen 7 7800X3D, Windows 11 26300, rustc 1.100.0 (0ef1bc386 2026-11-09), DXC/DXIL 1.8.2502.11 (Windows SDK 10.0.26100.0).
  • Rebased onto main (9dfbe3ea) at a4b2c195:
    • cargo test -p xcl --lib ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops: 1 passed, 0 failed.
    • cargo test -p xcl --lib gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl: 1 passed, 0 failed.
    • cargo test -p xcl --lib gpu_direct_dpp16_row_bank_masks_and_fi_zero: 1 passed, 0 failed.
    • cargo test -p xcl --lib gpu::dxil::lanes::ps_ballot_tests::: 8 passed, 0 failed.
    • cargo build --release -p xcl: clean build.
  • Prior full-workspace run on pre-rebase head (.\scripts\test.ps1, debug): 1,253 passed, 0 failed, 46 ignored across 23 test binaries.
  • Retail shader corpus sweep (xcl shaders <pack> --direct --sample 500 --seed 7 --max-bytes 100000 --validate --threads 8, release, pre-rebase head): 498 / 498 translated and dxil.dll-validated (0 errors; 158 shrunk, 0 grew).
    • All 498 shaders DXIL bytes: 45,499,896 -> 44,775,836 B (-724,060 B, -1.59%).
    • 234 pixel shaders DXIL bytes: 21,949,800 -> 21,230,816 B (-718,984 B, -3.28%, up to -8.2%).
    • Largest affected pixel shaders (bytes / DXIL instructions / WaveReadLaneAt / QuadReadLaneAt / QuadOp):
      • 11441aa968b462c5: 512,956 -> 476,504 B (-7.1%), 71,004 -> 66,688 (-6.1%), wrla 996 -> 191, qrla 481 -> 290, qop 0 -> 28
      • fd955a83b812406b: 596,476 -> 562,964 B (-5.6%), 77,221 -> 72,929 (-5.6%), wrla 1,181 -> 506, qrla 545 -> 414, qop 0 -> 7
      • 774552a952e99a89: 402,548 -> 374,256 B (-7.0%), 57,024 -> 53,737 (-5.8%), wrla 891 -> 231, qrla 473 -> 209, qop 0 -> 112
      • 529d8f27da1a3874: 344,304 -> 316,136 B (-8.2%), 49,239 -> 45,962 (-6.7%), wrla 826 -> 166, qrla 421 -> 157, qop 0 -> 112
      • 237c90ea491571f1: 249,228 -> 232,848 B (-6.6%), 35,525 -> 33,279 (-6.3%), wrla 316 -> 0, qrla 165 -> 58, qop 0 -> 7
  • Cold NVIDIA CreateGraphicsPipelineState on the 6 largest affected pixel shaders (2 alternating cold trials each with fresh exe basename; warm 2nd calls 0.1-0.2 ms): sum 41,387.9 ms -> 41,509.5 ms (+0.3%, neutral within noise on NVIDIA).

Regression run
main:

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1045 (PresentX 1045)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14930 MB

PR head (XCL_DIRECT_DXIL=1, XCL_PREPARE=0, XCL_PSO_PRELOAD=0):

xcl-smoke v1
commit: a4b2c195bf3fd7c5f13baec79c06fa489b8eb342
gpu: NVIDIA GeForce RTX 4070 SUPER
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 1666 (PresentX 1666)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 15213 MB

Not tested

  • Native wave64 GPUs (AMD / Intel) and Linux / Wine / vkd3d-proton.
  • Runtime pixel-shader GPU execution time (FPS delta) benchmarked in isolation.
  • Sample-gated tests (XCL_SAMPLE_* env vars unset).
  • Full cargo test --workspace was not re-run after rebasing onto 9dfbe3ea (targeted unit + GPU tests and release build were run on a4b2c195).

AI use

  • Antigravity (Gemini 4 Neon): analyzed open PRs and retail DXIL output, implemented the quad-local lowering and tests, rebased onto 9dfbe3ea, fixed the CI WARP skip gate, ran tests, corpus sweep, cold PSO measurements, and smoke runs locally, and drafted this description.

@luckyteagirl

Copy link
Copy Markdown
Contributor

Independent RX 6800M (RDNA2 native wave64) verification of exact PR head ea02576f497d5fe9f269ba78a32c9dee725d9501.

Environment: Windows 11 build 26200; Ryzen 9 5980HX; Radeon RX 6800M driver 30.0.13002.13003; Rust 1.99.0 MSVC; DXC/DXIL 1.9.2609.5. XCL_ADAPTER=6800M, XCL_REQUIRE_GPU=wave64, XCL_DIRECT_DXIL=1; debug tests in an isolated Cargo target.

Clean exact-head tests: Each of the three added gpu::dxil::core_tests cases passed 1/0/0 with no SKIPPED line:

  • ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops validated the pixel-shader wave32 and wave64 DXIL/intrinsic shape (and the vertex-shader control).
  • gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl matched direct DXIL, HLSL, and analytical fullscreen results, plus direct/HLSL diagonal-edge helper-lane output. Its checked-in fixture executes wave32.
  • gpu_direct_dpp16_row_bank_masks_and_fi_zero matched direct and HLSL GPU readback under partial EXEC. Its checked-in fixture executes wave32.

Local native-wave64 extension: On the same PR production code, I changed only the pixel-shader parity fixture: asserted runner::wave64_supported() == Ok(true), set its KernelOptions to wave64: true, and set the two HLSL pixel-shader Options to wave64: true. The fullscreen and diagonal-edge direct-vs-HLSL GPU draw test passed 1/0/0, no skips. I restored the clean PR worktree afterward. This is local fixture-only evidence, not a result from the unchanged test source.

Limits: Focused synthetic tests only. I did not run the full workspace suite, an owned-title smoke pair, runtime pixel-shader timing, Intel, or Linux/Wine on this head.

AI use: OpenAI Codex (GPT-6; exact variant not exposed in this session) ran the native Windows tests, made and restored the fixture-only wave64 diagnostic, checked the clean exact head, and drafted this report. No game data was used.

@saintwolf
saintwolf force-pushed the dxil/ps-quad-lane-reads branch from ea02576 to 83fc1bd Compare November 25, 2026 13:58
@saintwolf

Copy link
Copy Markdown
Contributor Author

Force-pushed the same commit as my username and e-mail was not correct for this GH account

@upipibi

upipibi commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

NVIDIA run, to go with luckyteagirl's RDNA2 one. Exact head 83fc1bd (the re-authored commit), as-is on its base 1a0bbe3a: RTX 3070 8 GB, driver 616.56, Windows 11, debug.

run XCL_DIRECT_DXIL=0 XCL_DIRECT_DXIL=1
quad filter (this PR's 12 tests, incl. gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl, gpu_direct_dpp16_row_bank_masks_and_fi_zero) 12 passed, 0 failed 12 passed, 0 failed
gpu_ suite (--skip gpu_sparse_vram, single-threaded) 146 passed, 0 failed, 1 ignored 146 passed, 0 failed, 1 ignored
same suite on main 1a0bbe3a 144 passed, 0 failed, 1 ignored 144 passed, 0 failed, 1 ignored

The two extra passes are this PR's new GPU tests. The only SKIPPED lines are two wave64-only tests that are skipped on main too (gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware: no wave64 on this card).

Not tested: a title, the whole workspace.

AI-assisted (Claude Code). Synthetic tests only.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Independent AMD report for 83fc1bdb1ffd39641a428eab31e6f099d0017168.

Tested

  • AMD Radeon RX 7800 XT (driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 build 26200, rustc 1.100.0, debug profile for tests, release for smoke. Tested at the exact PR head (not a local merge onto main).
  • Focused: ps_quad_local 1 passed, gpu_ps_direct_quad 1 passed, gpu_direct_dpp16 1 passed (the two GPU tests ran, no SKIPPED line).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1252 passed, 1 failed, 46 ignored. The one failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff). It fails identically on main 06c9f550 on this adapter (cargo test -p xcl --lib fuzz_validate_and_gpu_1), so it is not caused by this PR.
  • SKIPPED lines in the log: 7 (6 of them f16_programs_on_the_gpu / f32_programs_on_the_gpu per-lane cases refused for V_MUL_F16, V_PK_MUL_F16 or V_CVT_F16_F32, plus heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • scripts/smoke.ps1 -Seconds 60 on a real title (same title, same time), release build. main 06c9f550: 1531 frames, last presents per 2 s 60 36 38, peak commit 17752 MB, no device removal, no crash. PR head 83fc1bdb: 1586 frames, last presents per 2 s 60 60 60, peak commit 14847 MB, no device removal, no crash. Both exit 0x0.

Not tested

Wave64-only hardware, other adapters, a title whose shaders use these quad swizzles/DPP forms (the smoke run only shows no regression).

AI use

Claude Code (Claude Sonnet 5.5) ran the tests and the smoke runs and wrote this report. No game files, dumps or shader names are included.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

rootw0rm pushed a commit to rootw0rm/xcl that referenced this pull request Nov 26, 2026
…xcl-dev#2316)

Decode half, verbatim: swizzle_quad_map (quad-permute 0x8000..=0xBFFF
or bit mode with upper bits 4:2 preserved), dpp16_quad_map (quad_perm
0x000..=0x0FF, row_xmask 0x160..=0x163) and dpp8_quad_map (lanes 0..4
into 0..4, same relative map on 4..8). The SPIR-V port lowers these
maps to subgroup quad ops instead of cross-wave reads; the DXIL quad-op
emit half stays out.
@Prime1997

Copy link
Copy Markdown
Collaborator

@saintwolf I published the tested main integration branch in xcl-dev/xcl, retaining your authorship. It applies 83fc1bdb to main 8b957bec and resolves this PR's conflict.

Main's #2173 dot-product test and #2368 root-UAV load tests stay in place. The branch also includes all three of your shader quad/DPP tests. The three main checks and three PR checks all passed.

Local result: 6 passed, 0 failed, 0 ignored, 0 explicit skips on the RTX 3060 Ti. Each exact filter ran separately with --test-threads=1 --nocapture after a fresh cargo test --locked -p xcl --lib --no-run build, with 1,347 tests filtered out per invocation. The branch is available for the PR rebase. The focused checks leave full-suite, exact-head title smoke, and the maintainer RDNA4 batch validation pending.

AI use: Codex (GPT-6) resolved the conflict and verified the focused checks. Optional temporary Discord for coordinating contributor work, testing, and comparing results.

@saintwolf
saintwolf force-pushed the dxil/ps-quad-lane-reads branch from 83fc1bd to 2234832 Compare November 26, 2026 17:58
saintwolf added a commit to saintwolf/xcl that referenced this pull request Nov 26, 2026
In Direct DXIL pixel shaders, quad-local ds_swizzle_b32, DPP16, and DPP8 reads previously went through Lw::rla(), emitting 5 WaveReadLaneAt, 1 WaveActiveBallot, 4 QuadReadLaneAt, and ~40 select/bit ops only to discard the cross-wave path via same_quad.

Add Lw::quad_lane and Lw::read_lane_quad to emit single-instruction QuadOp (ReadAcrossX/Y/Diagonal), single QuadReadLaneAt broadcasts, identity pass-through, or minimal distinct QuadReadLaneAt selects in pixel shaders while keeping WaveReadLaneAt in non-pixel stages. Also fold constant DPP16 ROW_MASK/BANK_MASK (0xF/0x0), FI=1, and always-valid controls.

Measured on 498 sampled retail shaders (seed 7, up to 100 KB, all 498 dxil.dll validated): total DXIL -724 KB (-1.59%), 234 PS -719 KB (-3.28%, up to -8.2%), WaveReadLaneAt in quad-heavy PS cut by 57-100%.

Assisted-by: Antigravity (Gemini 4 Neon)

Resolve the merge conflict against current main 8b957be. Preserve the main packed-dot and root-UAV fixtures alongside the exact PR tests.

Original-PR: xcl-dev#2316
Original-commit: 83fc1bd
Assisted-by: OpenAI Codex (GPT-6)
@saintwolf

Copy link
Copy Markdown
Contributor Author

@Prime1997 Thanks for resolving the conflict on review/2316-main-8b957bec! Rebased onto e120925e (merges cleanly onto main 8b957bec with zero conflicts) at 22348324:

  • Also fixed direct_ps_ballot_uses_quad_ops_and_keeps_entry_exec_live_only in lanes.rs, which previously failed CI because helper_lane_masks_ps_code includes two quad-local DPP16 ops (0xB1, 0x4E) that now lower directly to dx.op.quadOp (updated the check to assert exactly those 2 quadOp calls while vopc_only right below still verifies VOPC itself emits 0 quadOp).
  • Full .\scripts\test.ps1 passed with 0 failures and a fresh 60 s scripts/smoke.ps1 run at 22348324 is updated in the PR description.

@SzczepanGrela

Copy link
Copy Markdown

RX 9070 / Linux-Wine verification of current head 223483246da1ba05aecc9af2a5d8d69bbf55f69c against main 8b957bec6f82495aec940944c6bf47faa02db590. The focused rebase checks and GPU comparisons pass on the PR, including an added native-wave64 DPP mask fixture. This adds release/Wine/RDNA4 results to the older Windows reports.

Tested

RX 9070 (RADV GFX1201), Mesa 26.3.1-arch3.5, Ryzen 7 7700, CachyOS kernel 7.3.0-5-cachyos, GE-Proton11-12 / Wine 11.0 Staging, native d3d12/d3d12core/dxgi, vkd3d-proton 8293130ebe370b1+ (local asserts-disabled build), DXC 1.9.2602.17, Rust 1.97.1, release x86_64-pc-windows-gnu.

Separate source copies and targets, built with cargo test --offline --locked --release --target x86_64-pc-windows-gnu -p xcl --lib --no-run. Main received the three upstream tests. Both copies had identical test-only output observations and additional fixtures; original assertions were retained. Source and executable hashes were verified.

The exact head's parent is e120925e3abc9956a8b9bae631969d32e8ccd43c. Main's GPU source directory is byte-identical to that parent. Applying the four-file PR diff to current main also produced byte-identical changed files to the exact head; that integrated tree was checked in source only.

Selection through Wine main PR
Three new tests + seven rebase controls, threads 1 9 passed, 1 failed 10 passed, 0 failed
Same selection, threads 4 9 passed, 1 failed 10 passed, 0 failed
Two added fixtures, three fresh processes per source 2 passed, 0 failed each 2 passed, 0 failed each

All 10 harness invocations had 0 ignored and 0 capability skips. Main's sole failure was the transplanted ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops IR assertion, 0 versus 4 expected QuadOp calls. GPU comparisons passed on both sources. The seven existing controls covered the packed dot-product lowering, root-window load IR and execution, and all four lanes::ps_ballot_tests, including the changed ballot assertion and helper-lane draw.

The original IR test passed on the head for both pixel translation settings: the symmetric quad program emitted 4 QuadOp, 0 QuadReadLaneAt, 0 WaveReadLaneAt, and one entry ballot. The broadcast/asymmetric case had the expected 1 QuadOp and 3 QuadReadLaneAt; the vertex control retained wave reads without quad intrinsics.

The added fixtures were:

  • The original fullscreen and diagonal pixel comparisons with logical wave64: true in both translators. This is a translation setting, not proof of the physical graphics wave size selected by the driver.
  • The original DPP16 row/bank/FI/BOUND control program extended to 64 lanes, setting both EXEC halves to alternating active lanes and restoring both before export. Direct and HLSL shaders have the explicit 64-lane wave property. All 64 lanes matched independently computed register values, including inactive destinations and upper-half lanes.

The captured fixtures produced 40 draws and 20 compute dispatches, including 12 native-wave64 dispatches. A separate verifier checked 5,120 fullscreen RGBA words and 5,120 DPP register words against independent formulas, with zero mismatches on either source. It also checked 5,120 diagonal RGBA words for direct/HLSL and cross-revision parity, plus the triangle's 28-pixel coverage mask. The six HLSL PS/CS control cases stayed byte-identical across revisions and repetitions.

For the diagonal fixture, the covered pixels (0,1), (2,3), (4,5), and (6,7) have all-zero outputs on both sources and both backends, under both logical wave settings. This is a parity observation; the check does not establish an independent console-ISA oracle for helper-lane values.

Environment: XCL_ADAPTER=AMD Radeon RX 9070, XCL_REQUIRE_GPU=wave64, XCL_NETWORK=0, XCL_DIRECT_DXIL=1, XCL_DXC_THREADS=1, native DLL overrides and private enabled caches. Fixtures explicitly call the direct and HLSL translators.

Not tested

Full workspace suite, retail shader corpora, smoke/title runs, merged-tree execution, physical graphics wave size, independent console helper-lane semantics, shader/PSO execution timing, or FPS/performance. Small owned synthetic shaders and inputs only.

AI use

OpenAI Codex (GPT-6; exact serving variant not exposed) reviewed the full diff, prepared the added fixtures and observations, built and ran both sources, independently checked source bytes, IR, GPU outputs and coverage, and wrote this report. Publication authorized by the account owner.

@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2316 rebased head 223483246da1ba05aecc9af2a5d8d69bbf55f69c (exact parent & merge-base e120925e3abc9956a8b9bae631969d32e8ccd43c). Measurements and targeted GPU/unit test results only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, quiet machine (zero concurrent builds/tests during timed runs; note gpu/dxil/* edits give 22348324 a fresh XCL_DIRECT_DXIL_SOURCE_ID namespace)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags, no input)

Targeted RTX 4060 release unit & GPU tests (22348324)

  • cargo test --release -p xcl --lib ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops -- --nocapture: 1 passed, 0 failed, 0 ignored (0.01 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl -- --nocapture: 1 passed, 0 failed, 0 ignored (0.38 s, executed on RTX 4060, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu_direct_dpp16_row_bank_masks_and_fi_zero -- --nocapture: 1 passed, 0 failed, 0 ignored (0.23 s, executed on RTX 4060, 0 SKIPPED).
  • cargo test --release -p xcl --lib direct_ps_ballot_uses_quad_op -- --nocapture: 1 passed, 0 failed, 0 ignored (0.02 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::dxil::core_tests:: (3 consecutive parallel passes): 22 passed, 0 failed, 1 ignored on all 3 passes (0.51 s / 0.49 s / 0.50 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::dxil::: 187 passed, 0 failed, 3 ignored (3.59 s; 1 SKIPPED: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole skipped no wave64 on NVIDIA wave32 RTX 4060).

Paired 60 s RTX 4060 smoke (exact parent e120925e vs 22348324)

Both runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (22348324 vs e120925e xcl.log: 6,116 vs 6,114 MB peak/end local VRAM, 4,683 MB vs 4,651 MB end non-local VRAM, 19,513 vs 19,588 translated draws / 1,024 dispatches with 0 skipped).

Exact parent (e120925e):

xcl-smoke v1
commit: e120925e3abc9956a8b9bae631969d32e8ccd43c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1602 (PresentX 1602)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13979 MB

PR #2316 head (22348324):

xcl-smoke v1
commit: 223483246da1ba05aecc9af2a5d8d69bbf55f69c
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1585 (PresentX 1585)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14008 MB

Limits of coverage

  • Full workspace test suite was not run on 22348324 (only the 4 targeted tests individually, 3 parallel passes of gpu::dxil::core_tests::, all 187 passing tests in gpu::dxil::, release build, and exact-parent paired 60 s smokes); dispatch_chain_native_wave64_builds_whole skipped no wave64 on wave32 NVIDIA hardware.
  • Direct quad-op swizzle/DPP pixel-shader correctness against HLSL was verified on-GPU via gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl and gpu_direct_dpp16_row_bank_masks_and_fi_zero; visual inspection of interactive in-world pixel shaders beyond the 60 s smoke was not performed.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release GPU/unit tests, release build, and exact-parent paired quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

@JJAutoCompare

Copy link
Copy Markdown

Tested

Clean 223483246da1ba05aecc9af2a5d8d69bbf55f69c on Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC, DXC/DXIL 1.9.2609.5, unoptimized test profile. Built with cargo test --locked -j 2 -p xcl --lib --no-run. Ran the resulting executable with --exact <filter> --test-threads=1 --nocapture for each synthetic fixture:

  • CPU: gpu::dxil::core_tests::ps_quad_local_swizzle_and_dpp_emit_direct_quad_ops and gpu::dxil::lanes::ps_ballot_tests::direct_ps_ballot_uses_quad_ops_and_keeps_entry_exec_live_only both passed.
  • Arc: gpu::dxil::core_tests::gpu_ps_direct_quad_swizzle_and_dpp_match_hlsl matched two 8×8 float32 RGBA HLSL-reference draws and the analytical values at all 64 fullscreen pixels. The diagonal draw used HLSL parity. gpu::dxil::core_tests::gpu_direct_dpp16_row_bank_masks_and_fi_zero matched all 160 VGPR values across 32 logical lanes under partial EXEC.

Four passed, zero failed, ignored, or skipped. The two Arc processes used XCL_ADAPTER=A770 and separate shared mutex acquisitions. Executable SHA-256 matched before, under, and after the lock.

Not tested

Actual hardware lane width, native wave64 GPU execution, performance, the full workspace, and retail smoke.

AI use

T3 Code / Codex (gpt-6.2-sol) selected, ran, and independently reran the checked-in tests.

@Prime1997 Prime1997 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving on a merge-check run on an RTX 3060 Ti 8 GB (driver 32.0.16.1714, i5-10400, Windows 11 Pro 26200, Rust 1.100.0).

  • Head 223483246da1ba05aecc9af2a5d8d69bbf55f69c merged cleanly onto main 7db2f391, and the workspace builds.
  • cargo test --workspace --no-fail-fast -- --test-threads=4, with --skip for three uma_driver tests that can end the library harness on this PC on plain main too: 2,594 passed, 0 failed, 49 ignored, 28 SKIPPED (21 of them no wave64). main with the same skips: 2,591 passed, 0 failed. All three new tests pass, including the GPU parity against the HLSL path on wave32.
  • 60 s scripts/smoke.ps1 with XCL_PREPARE=0: 1,405 frames against 1,385 on main, peak commit 15,507 MB against 15,626 MB, no device removal, no crash. The smoke stays in menus and video, so it runs few of the changed pixel shaders.
  • Runtime hunks read in full, no blocking finding. The AMD side (quadOp in pixel shaders, #134) rests on the AMD reports already here; this card cannot add to it.

AI use: Claude Code ran the builds, tests and smoke on Prime's PC and wrote this text. Approving is Prime's decision.

I use a temporary Discord to coordinate my work. Anyone helping test XCL or compare results is welcome. Test coordination on Discord

raylitebull added a commit that referenced this pull request Nov 29, 2026
A pixel shader's lane reads that stay in the reader's quad – DPP16
quad_perm and row_xmask below 4, quad-local DPP8 patterns, ds_swizzle in
quad mode or a bit mode that keeps the quad – went through `rla` in both
translators: four QuadReadLaneAt for the quad, plus a WaveReadLaneAt, a
ballot and four more wave reads that only served lanes of other quads and
were thrown away. Every derivative the console's code takes by DPP
(quad sums, ddx / ddy of shading values) paid for them, in loops too, and
on AMD a wave read inside a loop has left helper lanes' registers
unreliable (RX 6700 XT, `first_lane_live`); the console's quad reads see
helper lanes. VIctory-Neo (KyleS98/VIctory-Neo, docs/findings.md: square
holes and dashed edges in shadows) lowers these reads to quad operations
alone for the same reason; upstream PR #2316 does it for direct DXIL with
quadOp. This uses QuadReadLaneAt with constant lanes only, as `rla`
already does in every pixel shader (quadOp of values derived from wave
reads crashed AMD's compiler, #134), and covers the HLSL path as well.

`emit::quad_map` finds such a read from its source lane per lane (DPP16
by `dpp16_lane`, DPP8, `swizzle_lane`); `Em::quad_read` / `Lw::read_lane_quad`
read each quad position the map names once and select by lane & 3 (a
broadcast is one read, the identity none). The source lane's EXEC bit is
still checked as before. `XCL_PS_QUAD_READS=0` restores the `rla` form in
both translators (default on; in the translated cache's identity).

Tests: quad_local_lane_reads (the maps), ps_quad_local_lane_reads_take_quad_reads_only
(no wave read or quadOp in the PS of either translator, wave32 and wave64;
a compute program keeps rla), gpu_ps_quad_reads_in_a_loop_see_helper_lanes
(quad sums, diagonal, row and column neighbours inside a loop with a
v_readfirstlane, on two triangles: every pixel of both translators, wave32
and wave64, RX 9070 XT; it passes on the earlier form too there).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 1855d0cb1c65c3c6a7f41a2bf4e43aeda17767eb)
raylitebull added a commit that referenced this pull request Nov 29, 2026
A pixel shader's lane reads that stay in the reader's quad – DPP16
quad_perm and row_xmask below 4, quad-local DPP8 patterns, ds_swizzle in
quad mode or a bit mode that keeps the quad – went through `rla` in both
translators: four QuadReadLaneAt for the quad, plus a WaveReadLaneAt, a
ballot and four more wave reads that only served lanes of other quads and
were thrown away. Every derivative the console's code takes by DPP
(quad sums, ddx / ddy of shading values) paid for them, in loops too, and
on AMD a wave read inside a loop has left helper lanes' registers
unreliable (RX 6700 XT, `first_lane_live`); the console's quad reads see
helper lanes. VIctory-Neo (KyleS98/VIctory-Neo, docs/findings.md: square
holes and dashed edges in shadows) lowers these reads to quad operations
alone for the same reason; upstream PR #2316 does it for direct DXIL with
quadOp. This uses QuadReadLaneAt with constant lanes only, as `rla`
already does in every pixel shader (quadOp of values derived from wave
reads crashed AMD's compiler, #134), and covers the HLSL path as well.

`emit::quad_map` finds such a read from its source lane per lane (DPP16
by `dpp16_lane`, DPP8, `swizzle_lane`); `Em::quad_read` / `Lw::read_lane_quad`
read each quad position the map names once and select by lane & 3 (a
broadcast is one read, the identity none). The source lane's EXEC bit is
still checked as before. `XCL_PS_QUAD_READS=0` restores the `rla` form in
both translators (default on; in the translated cache's identity).

Tests: quad_local_lane_reads (the maps), ps_quad_local_lane_reads_take_quad_reads_only
(no wave read or quadOp in the PS of either translator, wave32 and wave64;
a compute program keeps rla), gpu_ps_quad_reads_in_a_loop_see_helper_lanes
(quad sums, diagonal, row and column neighbours inside a loop with a
v_readfirstlane, on two triangles: every pixel of both translators, wave32
and wave64, RX 9070 XT; it passes on the earlier form too there).

(cherry picked from commit 1855d0cb1c65c3c6a7f41a2bf4e43aeda17767eb)
In Direct DXIL pixel shaders, quad-local ds_swizzle_b32, DPP16, and DPP8 reads previously went through Lw::rla(), emitting 5 WaveReadLaneAt, 1 WaveActiveBallot, 4 QuadReadLaneAt, and ~40 select/bit ops only to discard the cross-wave path via same_quad.

Add Lw::quad_lane and Lw::read_lane_quad to emit single-instruction QuadOp (ReadAcrossX/Y/Diagonal), single QuadReadLaneAt broadcasts, identity pass-through, or minimal distinct QuadReadLaneAt selects in pixel shaders while keeping WaveReadLaneAt in non-pixel stages. Also fold constant DPP16 ROW_MASK/BANK_MASK (0xF/0x0), FI=1, and always-valid controls.

Measured on 498 sampled retail shaders (seed 7, up to 100 KB, all 498 dxil.dll validated): total DXIL -724 KB (-1.59%), 234 PS -719 KB (-3.28%, up to -8.2%), WaveReadLaneAt in quad-heavy PS cut by 57-100%.

Assisted-by: Antigravity (Gemini 4 Neon)

Resolve the merge conflict against current main 8b957be. Preserve the main packed-dot and root-UAV fixtures alongside the exact PR tests.

Original-PR: xcl-dev#2316
Original-commit: 83fc1bd
Assisted-by: OpenAI Codex (GPT-6)

# Conflicts:
#	crates/xcl/src/gpu/dxil/core_tests.rs
#	crates/xcl/src/gpu/dxil/lanes.rs
#	crates/xcl/src/gpu/dxil/lower_mem.rs
#	crates/xcl/src/gpu/dxil/lower_valu.rs
@saintwolf
saintwolf force-pushed the dxil/ps-quad-lane-reads branch from 2234832 to a4b2c19 Compare November 30, 2026 13:53
@github-actions github-actions Bot added area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head a4b2c19

No open or merged PR makes the same change; #3455 touches the neighbouring PS ballot path (Lw::ballot_ps) and goes the other way, from quadOp to per-lane QuadReadLaneAt.
Risk in the diff: Lw::read_lane_quad (dxil/lanes.rs) now emits dx.op.quadOp on arbitrary DPP / ds_swizzle_b32 source values in pixel shaders. #134 (comment in lower_valu.rs) and #3455 both report amdxc64 on RDNA2 crashing in the PSO build on quadOp of values that derive from WaveReadLaneAt, which such a source can be (e.g. after v_readfirstlane). The PR was only run on NVIDIA; it needs an AMD run on a title before it goes in, or the QuadReadLaneAt form for the three cross reads.
The quad maps (swizzle_quad_map, dpp16_quad_map, dpp8_quad_map) and the folded ROW_MASK / BANK_MASK / FI handling match the previous lowering.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

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

Labels

area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants