Skip to content

[upstream #875] Recompiler: tbuffer_load_format_* ignores the V#'s DST_SEL - #200

Closed
ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/875
Closed

ufoptg wants to merge 1 commit into
mainfrom
upstream-pr/875

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

Fixes FormatLoad in crates/xcl/src/gpu/recomp/emit.rs so tbuffer_load_format_* (ENC_MTBUF) uses the identity component select (x, y, z, w) instead of applying the V#s DST_SELfield (dword3[11:0]`):

  • Per the RDNA2 ISA Buffer Data table, buffer_*_format takes both its format and DST_SEL from the V#, whereas tbuffer_*_format takes its format from the instruction and uses the identity select.
  • Previously, tbuffer_load_format_* through a V# with a swizzled DST_SEL returned reordered components, and a SEL_0 V# returned all zeros.
  • buffer_load_format_* continues to apply dst_sel(); stores and (0, 0, 0, 1) missing-component fill are unchanged.
  • Adds translation test tbuffer_load_ignores_vsharp_dst_sel and GPU test gpu_tbuffer_load_identity_dst_sel verifying both swizzled 8_8_8_8_UINT and SEL_0 16_16_FLOAT V#s.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: 54ed7eb4bdbd9e205612e807e9b05f0c450ef2ac
  • cargo build --workspace: clean (no new warnings; only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 715 passed, 0 failed, 41 ignored (tbuffer_load_ignores_vsharp_dst_sel ok, gpu_tbuffer_load_identity_dst_sel ok)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Not tested

  • Retail title regression run (scripts/smoke.ps1) not yet run (no retail title available in this clean-room environment); opened as Draft pending a smoke run.
  • AMD RDNA / wave64 hardware not tested.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).

Mirror of xcl-dev#875 (auto-synced, do not edit).

The typed-buffer load path applied the V#'s DST_SEL (dword3 [11:0]) to
every format load, tbuffer_load_format_* (MTBUF) included. The RDNA2
ISA's "Buffer Data" table gives the DST_SEL source per instruction:
buffer_load_format_* / buffer_store_format_* use the resource's,
tbuffer_*_format_* take FORMAT from the instruction and use the
identity select (X, Y, Z, W), as do the raw and atomic forms. With a
V# whose DST_SEL is not identity (a swizzled or all-SEL_0 word3, as on
a raw buffer descriptor), tbuffer loads came out reordered or zero.

MTBUF format loads (and their d16 forms) now take the converted
components in order; missing components still get the format fill
(0, 0, 0, 1). buffer_load_format_* is unchanged.

Tests: tbuffer_load_ignores_vsharp_dst_sel checks the emitted HLSL
(buffer_load_format keeps dst_sel(), the tbuffer xyzw and d16_xyz
forms read t_c.x.. in order) and compiles it when DXC is present;
gpu_tbuffer_load_identity_dst_sel loads through a V# with DST_SEL
(z, y, x, w) and one with SEL_0 everywhere: buffer_load_format_xyzw
returns (3, 2, 1, 4), tbuffer xyzw (1, 2, 3, 4), tbuffer 16_16_FLOAT
(1.0, -2.0, 0, 1.0) and its d16_xyzw / d16_xy forms packed in order.

Checked off-tree: a Python port of fmt_comp / dst_sel / the d16 packing
(check_formats.py) gives the expected test vectors; the same script
compares fmt_comp with an independent decoder over all 77 formats
(random elements plus 0, 1, max and sign-boundary components) and
round-trips decode/encode for every representable element.

Not built or run on Windows.

Assisted-by: Claude Code (Claude Opus 5.5)
@ufoptg

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

Upstream PR xcl-dev#875 was closed or merged.

@ufoptg ufoptg closed this Nov 25, 2026
@ufoptg
ufoptg deleted the upstream-pr/875 branch November 25, 2026 00:06
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