Skip to content

D3D12.X: GFX10 image format 134 (1_5_5_5) is B5G5R5A1, not 135 (#946) - #990

Merged
ivall merged 1 commit into
xcl-dev:mainfrom
emirduran707:gfx10-1555
Nov 24, 2026
Merged

ivall merged 1 commit into
xcl-dev:mainfrom
emirduran707:gfx10-1555

Conversation

@emirduran707

Copy link
Copy Markdown
Contributor

gpu::desc::dxgi_format mapped GFX10 image format 135 to DXGI B5G5R5A1. In the GFX10 format enum (Mesa's src/amd/registers/gfx10-rsrc.json, GFX10_FORMAT), 134 is 1_5_5_5_UNORM and 135 is 5_5_5_1_UNORM. The names list the fields from the top bit down (gfx10_format_table.py reverses them into little-endian order), so 1_5_5_5 has x in bits 0–4 and w in bit 15, which is B5G5R5A1. 5_5_5_1 keeps its one-bit field in bit 0, which no DXGI format has. Fixes #946.

As it was:

  • a B5G5R5A1 T# (134) had no DXGI format, so image_d3d12 refused its view;
  • a 5_5_5_1 T# was read with B5G5R5A1's layout;
  • gfx10_format(DXGI_FORMAT_B5G5R5A1_UNORM) gave 135, the format XCL writes into the T#s of its own B5G5R5A1 views.

The tiling size class (133..=136, two bytes) is the same for both codes.

What is in it

  • crates/xcl/src/gpu/desc.rs: 134, not 135, maps to B5G5R5A1.
  • Test packed_formats_reorder_channels, extended: dxgi_format(134) is B5G5R5A1 with the BGRA order, dxgi_format(135) is None, and gfx10_format gives 134. It fails without the change (left: None).

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.31044.16; Ryzen 5 5600, 32 GB; Windows 11 Pro 26300; rustc 1.100.0 x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.
  • cargo test --workspace -- --test-threads=4 at 87fae1f: 724 passed, 0 failed, 41 ignored; no SKIPPED lines.
  • The enum values were checked against Mesa's register database (GFX10_FORMAT: 133 5_6_5_UNORM, 134 1_5_5_5_UNORM, 135 5_5_5_1_UNORM, 136 4_4_4_4_UNORM).

Regression run

The gpu: line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log names backend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).

main:

xcl-smoke v1
commit: 9aec53df7004bd9018ef3df67532f85d66ee261c
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1570 (PresentX 1570)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16708 MB

PR:

xcl-smoke v1
commit: 87fae1fa9e1ff5da09445fb8de33d8cbf42033bb
gpu: AMD Radeon RX 9060 XT
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1589 (PresentX 1589)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17541 MB

Not tested

  • A title that samples a 1_5_5_5 texture: the retail title above does not show whether it uses this format. The run checks only that nothing else changed.
  • NVIDIA.

AI use

  • Claude Code with Claude Opus 5.5: checked the issue against Mesa's sources, and wrote the change, the test and this description. The runs above were made on my machine.

🤖 Generated with Claude Code

…ev#946)

dxgi_format mapped IMG_FORMAT 135 to DXGI B5G5R5A1. In the GFX10 format
enum (Mesa's register database) 134 is 1_5_5_5_UNORM and 135 is
5_5_5_1_UNORM; the names list the fields from the top bit down, so 1_5_5_5
has x in bits 0-4 and w in bit 15, which is B5G5R5A1. 5_5_5_1 keeps its
one-bit field in bit 0, which no DXGI format has.

So a B5G5R5A1 T# (134) had no DXGI format and its view was refused, a
5_5_5_1 T# was read with B5G5R5A1's layout, and gfx10_format gave 135 for
the T#s XCL writes for its own B5G5R5A1 views. The tiling size class
(133..=136, two bytes) is the same for both codes.

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

Copy link
Copy Markdown

NVIDIA run, since Not tested lists NVIDIA.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (32-lane waves), driver 32.0.16.1088; AMD Ryzen 7 5700X; native Windows 11 Pro 26H2 (build 26300.9974), Graphics Tools (D3D12 debug layer) installed; rustc 1.100.0 stable-x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug
  • Exact head 87fae1fa9e1ff5da09445fb8de33d8cbf42033bb (on its base 9aec53d), clean worktree: cargo build --workspace, then cargo test --workspace --no-fail-fast -- --test-threads=4: 724 passed, 0 failed, 41 ignored, the same total as yours. gpu::desc::tests::packed_formats_reorder_channels passed.
  • Fails without the change: with 134 => turned back into 135 => and the test kept, --exact gpu::desc::tests::packed_formats_reorder_channels fails at desc.rs:419 with left: None, right: Some((DXGI_FORMAT(86), [2, 1, 0, 3])).
  • gfx10_format is derived from dxgi_format ((0..=182).find(...)), and nothing else under gpu/ or hle/d3d12x/ hard-codes 135 for this format. So the one line also fixes the T#s XCL writes for its own B5G5R5A1 views.
  • Merged onto current main 6efdabc (no conflict): cargo test --workspace --no-fail-fast -- --test-threads=4: 727 passed, 0 failed, 41 ignored
  • cargo test -p xcl --lib gpu::desc on the merged tree, 10 runs: 10 of 10 passed (11 tests each)
  • D3D12 debug layer: the e2e test title's XCL_D3D12_DEBUG=1 run (test_title_draws_with_a_root_signature_under_the_debug_layer) logs the same set of debug-layer errors and warnings on the merged tree as on main. Nothing new.
  • SKIPPED (no wave64 on this adapter): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware
  • XCL_SAMPLE_* not set

Not tested

  • A B5G5R5A1 texture sampled on this GPU through a translated shader: no test here creates one, and there's no retail title here.
  • Release build.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests on the machine above, including the check without the change, and wrote this report from the logs.

@dcastell1

Copy link
Copy Markdown

Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on main@02bfd1d (baseline 727 passed, 0 failed, 41 ignored on this box; the head of this PR is based on 9aec53d, which is why the base is stated):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
727 passed; 0 failed; 41 ignored   (exit 0)

Same count as the baseline — the format-134 (1_5_5_5) change is exercised by existing coverage and nothing regresses.

Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

@raylitebull

Copy link
Copy Markdown
Member

Code/CI review only (not independently runtime-tested by me): clean merge with both checks green (Build and test + PR description). Minimal +7/-1 fix mapping GFX10 image format 134 (1_5_5_5) to B5G5R5A1 instead of 135 (#946). Recommend merging, @ivall.

@ivall
ivall merged commit a610eb5 into xcl-dev:main Nov 24, 2026
2 checks passed
@ivall

ivall commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Merged in a610eb5 – thanks, and thanks to @fromthemoonx and @dcastell1 for the checks (the test fails with 135 again). Tested on the merged batch (#990, #1037, #951, #1016): cargo test --workspace --no-fail-fast -- --test-threads=4: 741 passed, 0 failed, 41 ignored, no SKIPPED. Retail title, 90 s with scripted presses, against main before the batch the same way: exit 0, no crash, no device removal, 1500 frames, peak process commit 27.7 GB against 29.2 GB.

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.

desc: GFX10 format 135 is mapped to DXGI B5G5R5A1, which is 134 (1_5_5_5_UNORM)

5 participants