Skip to content

[upstream #1115] Tests: 16-bit VALU results keep the other half of VDST - #44

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

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

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 24, 2026

Copy link
Copy Markdown
Owner

A 16-bit VALU result goes into D[15:0] and leaves D[31:16] as it was, or with VOP3 op_sel[3] into D[31:16] leaving D[15:0]. op_sel[0..2] read the sources' high halves. valu16 does this ((cur & 0xFFFF0000u) | t, emit.rs ~3051), but only v_add_f16 has a check of it in gpu_valu_16_and_64_bit. The other 16-bit tests, including xcl-dev#638 and xcl-dev#639, compare D[15:0] alone. A change that zeroed or overwrote the other half would pass all of them.

The expected behaviour is measured on RDNA2 silicon, the console's generation, not taken from the ISA text: xcl-dev#638 (comment), plus the op_sel forms below.

What is in it

  • crates/xcl/src/gpu/recomp/tests.rs: gpu_16_bit_results_keep_the_other_half. Every VDST starts at 0xCAFE_BABE. Each source has different values in its two halves. 24 rows:
    • the 16-bit integer ops of valu16 that RDNA2 has, plain VOP3: v_add/sub_nc_u16/i16, v_mul_lo_u16, v_lshlrev/lshrrev_b16, v_ashrrev_i16, v_min/max_u16/i16, v_mad_u16/i16. v_subrev_nc_u16 is left out: the RDNA2 / RDNA4 assembler refuses it.
    • the op_sel forms the RDNA2 assembler takes (v_add/sub_nc_u16/i16, v_mad_u16/i16): writing D[31:16], reading the high halves, both.
    • v_cvt_u16_f16 / v_cvt_i16_f16 (VOP1), f16 source with 0xBEEF in its high half.

Tested

  • Two GPUs in one PC, picked with XCL_ADAPTER: AMD Radeon iGPU of a Ryzen 7 9800X3D (gfx1036, RDNA2, native wave64, driver 32.0.21045.29003) and AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32029.2010). Windows 11 Pro 26200, Rust 1.100.0 MSVC, DXC 1.9.2602.17, debug.
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on a8133ad: 742 passed, 0 failed, 41 ignored on each GPU, no SKIPPED (main 47efa2e: 741 / 0 / 41 on each).
  • The new test with XCL_REQUIRE_GPU=wave64: 3 / 3 passed on each GPU.
  • Negative controls on the RDNA2 iGPU, each a one-line local change to valu16, reverted after:
    • D[31:16] not kept (t written alone): 108 failing rows, e.g. V_ADD_NC_I16 … got 0x00000000, want 0xcafe0000.
    • op_sel[3] ignored: 36 failing rows (got 0xcafef777, want 0xf777babe).
    • op_sel source bits ignored: 35 failing rows.
  • Hardware reference: each instruction and op_sel form above ran as inline assembly in OpenCL (the Recompiler tests: ds_swizzle_b32 lanes match RDNA2 hardware for every offset xcl-dev/xcl#518 / Recompiler: ds_bpermute_b32 in wave64 may stay within each 32-lane half on RDNA2 (needs a hardware run) xcl-dev/xcl#772 method) on both GPUs, VDST preset to 0xCAFEBABE, wave32 and wave64. Every form the assembler accepted matches the rule above on both GPUs.

Regression run

  • Test-only change (tests.rs), no runtime regression run.

Not tested

  • NVIDIA / wave32-only GPUs (the split wave64 form), so the test ran only in native wave64 here.
  • op_sel on the VOP2-origin ops (v_mul_lo_u16, the shifts, min / max): the RDNA2 assembler refuses it, so there is no hardware reference for it.
  • SDWA forms, clamp, the console itself (gfx1036 is a desktop RDNA2 APU of the same generation).

AI use

  • Claude Code (Claude Opus 5.5) wrote the test, the OpenCL probes and this description, and ran the tests and the controls on my PC.

🤖 Generated with Claude Code


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

A 16-bit VALU result goes into D[15:0] and leaves D[31:16] as it was, or
with VOP3 op_sel[3] into D[31:16] leaving D[15:0], and op_sel[0..2] read the
sources' high halves. valu16 does this (`(cur & 0xFFFF0000u) | t`), but only
v_add_f16 had a check of it: the other 16-bit tests compare D[15:0] alone.

gpu_16_bit_results_keep_the_other_half presets every VDST to 0xCAFE_BABE and
runs the 16-bit integer ops of valu16 that RDNA2 has, the op_sel forms the
RDNA2 assembler takes (v_add/sub_nc_u16/i16, v_mad_u16/i16), and
v_cvt_u16_f16 / v_cvt_i16_f16. The expected values follow what RDNA2
(gfx1036) and RDNA4 (gfx1201) silicon gave for the same instructions as
inline assembly through OpenCL.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ufoptg pushed a commit that referenced this pull request Nov 24, 2026
…ites

`pc_resource_desc` takes ALLOW_UNORDERED_ACCESS from a depth buffer the
console also lets shaders write (the PC refuses ALLOW_DEPTH_STENCIL with
ALLOW_UNORDERED_ACCESS). Only CreatePlacedResourceX (#44) moved such a
resource's initial state off UNORDERED_ACCESS as well (to DEPTH_WRITE).
The other paths that create a resource of the converted description
only masked the state with PC_RESOURCE_STATES: the committed fallback of
CreateCommittedResource (#27 / #76 / #127, reached without unified
memory or when its coherent window is full), the PC-way retry and the
committed fallback of CreatePlacedResource (#29), and its memory-of-its-
own path for textures larger on the PC. A console texture with flags
DEPTH_STENCIL | UNORDERED_ACCESS created in UNORDERED_ACCESS was then
asked for in a state D3D12 refuses for a resource without the UAV flag
(E_INVALIDARG; the #29 own-memory path fell back to COMMON).

`device_x::pc_initial_state` does both steps; #44 uses it with no change
in behaviour, and the four other sites use it with the console flags
(or the PC description's, which keep ALLOW_DEPTH_STENCIL).

Tests: a unit test of the helper; a GPU test placing a 256x256 D16
depth+UAV texture in UNORDERED_ACCESS as XCL now does (not run here).

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

ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner Author

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

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