Skip to content

Recompiler: a V# with ADD_TID_ENABLE indexes buffers by lane - #2066

Open
upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/buffer-add-tid
Open

upipibi wants to merge 1 commit into
xcl-dev:mainfrom
upipibi:fix/buffer-add-tid

Conversation

@upipibi

@upipibi upipibi commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Both paths ignored ADD_TID_ENABLE (V# word 3 bit 23). Every lane of a buffer access without IDXEN used index 0, so a 64-lane buffer_load_dword through such a V# read element 0 in every lane. RDNA2 takes the lane as the index when IDXEN is clear, and ignores ADD_TID when IDXEN is set.

Source for the rule: boykopovar/AnyPS5#21970 measured it on gfx1036 with their hardware oracle (compute), and boykopovar/AnyPS5#24781 applies the same rule to graphics stages.

What is in it

  • recomp/emit.rs and dxil/lower_mem.rs: when IDXEN is clear, the MUBUF index is select(V# word 3 bit 23, lane, 0) instead of 0. This applies at all five sites: loads and stores, sub-dword D16, and atomics. The atomic sites now read V# word 3.
  • recomp/tests.rs: gpu_buffer_add_tid_indexes_by_lane uses a stride-4 V# with ADD_TID, and each lane should read its own dword. The test sits next to the other buffer tests rather than at the end of the file.

Tested

Regression run
Run by Toons29 on an AMD Radeon RX 9070 (comment), main and this head, pasted unedited:

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: b81d47c33ef0529b6707496ce44de3b43a1d1850
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1567)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14627 MB

Not tested

  • Titles. On AMD, only oni-swr's run above.
  • Not covered: swizzled buffers. With the V#'s swizzle bit set (word 1 bit 31, stride not 0), this PR still computes a linear stride * lane address after the new index (recomp/emit.rs:2089, :2099, :4117, :4124, :4174, :4184; dxil/lower_mem.rs:1179-1181, :1840-1842). fix(shader): address swizzled buffers like RDNA2 boykopovar/AnyPS5#21970 measured on gfx1036 (compute, through HIP; the PR is open) that the swizzle does apply with ADD_TID: step = 8 << INDEX_STRIDE, addr = ((idx/step)*stride + (off&~3))*step + (idx%step)*4 + (off&3). This doesn't make anything worse, because main has no buffer swizzle on either path (with IDXEN either). The test here uses stride 4 with the bit clear, where both rules give 4l, so it can't tell them apart. Swizzle is a separate change: Recompiler: swizzled buffer V#s address records in dword-interleaved groups #2325, stacked on this one.

AI use

  • AI-assisted (Claude Code, Claude Opus 5.5): wrote the change, the tests and this description, and ran the tests above. Synthetic tests only; no game files.

🤖 Generated with Claude Code

Both paths ignored ADD_TID_ENABLE (V# word 3 bit 23): every lane of a
buffer load without IDXEN read element 0. RDNA2 takes the lane as the
index when IDXEN is clear and ignores ADD_TID with IDXEN (AnyPS5#21970,
measured on gfx1036; #24781 applies it to graphics stages). Loads,
stores and atomics, both paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@JJAutoCompare

Copy link
Copy Markdown

Tested

I ran the checked-in stride-4 gpu_buffer_add_tid_indexes_by_lane fixture on an Intel Arc A770 at clean PR head b81d47c33ef0529b6707496ce44de3b43a1d1850. GitHub showed this exact open head before and after execution. The post-run conversation showed no separate verification report. PR #2066

  • Intel Arc A770, driver 32.0.101.9175, AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation 26200.9974.
  • Rust and Cargo 1.100.0, toolchain stable-x86_64-pc-windows-msvc. Unoptimized Cargo test profile with debug info and incremental compilation disabled. DXC/DXIL 1.9.2609.5.
  • Built the XCL library test executable outside the Arc lock. Used the same executable for both runs.
$env:CARGO_TARGET_DIR = 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target'
$env:CARGO_INCREMENTAL = '0'
$env:CARGO_PROFILE_DEV_DEBUG = '0'
$env:CARGO_PROFILE_TEST_DEBUG = '0'
$env:TEMP = 'L:\XclTooling\pr2066\run-b81d47c-20261125T025448907Z\temp'
$env:TMP = $env:TEMP
& 'C:/Users/ljensen/.cargo/bin/cargo.exe' +stable-x86_64-pc-windows-msvc test --locked -p xcl --lib -j 2 --no-run --message-format=json

The following ran once with XCL_DIRECT_DXIL=0 for HLSL/DXC and once with XCL_DIRECT_DXIL=1 for direct DXIL. The test runner uses direct DXIL without a fallback in the second mode.

$env:XCL_ADAPTER = 'A770'
$env:XCL_DXC_DIR = 'C:/Users/ljensen/AppData/Local/XclTooling/dxc-1.9.2609/bin/x64'
$env:XCL_REQUIRE_GPU = 'wave64'
$child = @"
& 'L:/XclTooling/Invoke-ArcTest.ps1' -WaitMinutes 30 -Test { & 'L:/XclTooling/pr1947-1831ec4-t3-97236edf/target\debug\build\xcl/97fdf2b9ff8e1482\out\xcl-97fdf2b9ff8e1482.exe' gpu::recomp::tests::gpu_buffer_add_tid_indexes_by_lane --exact --nocapture --test-threads=1 }; exit `$LASTEXITCODE
"@
& 'C:/Windows/System32/WindowsPowerShell/v1.0/powershell.exe' -NoProfile -ExecutionPolicy RemoteSigned -Command $child
Backend Passed Failed Ignored Skipped Filtered out Lanes matching expected
HLSL/DXC 1 0 0 0 1119 64/64
Direct DXIL 1 0 0 0 1119 64/64

The fixture's exact vector assertion passed on both backends. For each lane from 0 through 63, the readback equaled 0xA000 + lane, so the two backend outputs matched on all 64 lanes. Both runs exited 0 and released the Arc lock. The initial shell attempts were blocked before test execution by Windows PowerShell's default policy. The successful commands used process-scoped RemoteSigned.

Not tested

Other descriptor or address combinations, writes, atomics, other GPU adapters, the full workspace suite, and retail-title smoke runs.

AI use

T3 Code / Codex (gpt-6.2-sol) ran the checked-in fixture, verified the logs, and wrote this report.

@JoaoPauluu

Copy link
Copy Markdown

A run with vkd3d-proton as the host D3D12. The DXIL goes through dxil-spirv and then the NVIDIA Vulkan driver, a different compiler from a native-Windows run: this PR's new test passes.

Tested

Not tested

  • the whole suite on this head, a retail title, native Windows, AMD.

AI use

  • Claude Code (Claude Opus 5.5) built the commit, ran the tests and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

IvyNotFound added a commit to IvyNotFound/xcl that referenced this pull request Nov 25, 2026
@Toons29

Toons29 commented Nov 25, 2026

Copy link
Copy Markdown

Regression run of b81d47c3 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 568e7db7, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 568e7db7729c8fa6c8f0f4b32d798faaf11462bb
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1566 (PresentX 1566)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14592 MB
xcl-smoke v1
commit: b81d47c33ef0529b6707496ce44de3b43a1d1850
gpu: AMD Radeon RX 9070
title: 34df7c50
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1567)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14627 MB

Against the limits in CONTRIBUTING.md: 100 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; a script posted this right after the run, with both blocks exactly as printed.

@raylitebull

Copy link
Copy Markdown
Member

Code review on b81d47c looks solid, CI is green, and it has Arc A770, vkd3d-proton, RTX 3060 Ti, and RX 9070 smoke coverage.

Only missing piece before merge is an AMD synthetic GPU test run (gpu_buffer_add_tid_indexes_by_lane) on b81d47c.

@oni-swr

oni-swr commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

AMD synthetic GPU run of b81d47c33ef0529b6707496ce44de3b43a1d1850 (exact PR head, tested as-is, not merged onto main; the diff touches the recompiler and its test only). Synthetic Cargo tests only: no retail title, no smoke.ps1.

Tested

  • AMD Radeon RX 7800 XT (RDNA3, driver 32.0.31035.1003), Ryzen 7 5700X3D, Windows 11 Pro 26200, rustc 1.100.0 (2026-11-09), debug build, DXC 1.9.0.5512. Clean target dir; Compiling xcl v0.1.0 came from the PR checkout.
  • cargo test -p xcl --lib gpu_buffer_add_tid -- --nocapture: gpu::recomp::tests::gpu_buffer_add_tid_indexes_by_lane ... ok (1 passed, 0 failed, 0 ignored).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1146 passed, 1 failed, 46 ignored, 7 distinct SKIPPED lines. These are not coverage: f16/f32 per-lane form refused (6, wave32 and wave64) and heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The 1 failure is gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 (seed 722: res[30] = 0x1, CPU 0x7fffffff). It fails the same way on main 1a0bbe3 on this machine (cargo test -p xcl --lib fuzz_validate_and_gpu_1: 0 passed, 1 failed), so the PR did not cause it. I did not look into it further.
  • With --workspace and no prior cargo build --workspace, e2e failed 2 of 3 because xcl_testtitle.exe was not built yet. After cargo build --workspace, e2e gave 3 passed, 0 failed.

Not tested

  • Retail title / scripts/smoke.ps1 regression run, NVIDIA, Intel, Wine/vkd3d.
  • Whether the PR merged with newer main still passes.

AI use
Claude Code, Claude Sonnet 5.5 ran the tests, checked the diff, and wrote this report.

upipibi added a commit to upipibi/xcl that referenced this pull request Nov 25, 2026
…he swizzled offset

gpu_buffer_swizzle_window_from_swizzled_offset: three swizzled loads with two
memory windows - an offset carry from below window 0 into window 1, an
index * stride product that carries into window 1, and a product past 2^32
that must read 0. Fails on main + xcl-dev#2066 on both paths, passes with the swizzle.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

7 participants