Skip to content

compute: decode the 10-bit-x buffer format as 2_10_10_10, not 10_10_10_2 - #2192

Merged
R0Y00 merged 1 commit into
R0Y00:mainfrom
archielcqp-a11y:compute/descriptor-format-2-10-10-10
Nov 25, 2026
Merged

R0Y00 merged 1 commit into
R0Y00:mainfrom
archielcqp-a11y:compute/descriptor-format-2-10-10-10

Conversation

@archielcqp-a11y

Copy link
Copy Markdown
Contributor

Refs #2022. This fixes the format table shared by the descriptor-format stores (#1542) and loads (#2150).

Problem

The 10-bit-x packer (x in bits 9:0, y and z in the next 10-bit fields, w in bits 31:30) was registered for BUF_FMT_10_10_10_2_UNORM, which is gfx10 code 44 and legacy DFMT 8. That format has a different layout: x is the 2-bit field in bits 1:0, followed by 10-bit y, z and w. So a store or load with code 44 would have written or read the wrong fields, with no refusal.

Sources:

  • AMD format names list the fields from the most significant bit. Mesa's src/amd/common/gfx10_format_table.py reverses each name into channel sizes ("Keep the bit sizes in little-endian order"), so 2_10_10_10 is [10, 10, 10, 2] from bit 0 and 10_10_10_2 is [2, 10, 10, 10].
  • radeonsi (si_translate_buffer_dataformat) and radv (radv_translate_buffer_dataformat) map formats whose first channel is 10 bits and whose fourth is 2 bits (R10G10B10A2) to BUF_DATA_FORMAT_2_10_10_10.
  • LLVM's gfx10 unified format table numbers BUF_FMT_10_10_10_2_UNORM 44 and BUF_FMT_2_10_10_10_UNORM 50, as tools/disasm_rdna2.py already does.

Change

  • Remap: the packer now serves BUF_FMT_2_10_10_10_UNORM (code 50, legacy DFMT 9).
  • Refusal: code 44 and legacy DFMT 8 are not handled. A store with that format is skipped, and a load is invalid, so the dispatch publishes nothing.

Implementing the real 10_10_10_2 layout is left out, so the change stays a pure correction.

Tests

  • Store fixture (draw-descriptor-store-format): the xyzw store uses code 50, with unchanged pinned words. A new GPU run gives that store code 44 and must leave its element at the sentinel.
  • Load fixture (compute_load_format_check.py draw): the xyzw load uses code 50. A fifth invalid-format run gives it code 44 and must leave all 320 words at the sentinel; a zero-filled reference must fail.
  • Controls: they reject the code-44 word and the legacy DFMT 8 word (0x00040FAC). The pinned legacy word for code 50 is 0x00048FAC. With the old mapping restored, the store controls and the load model fail.

Results

Run at 282f630 on 8bfbabf (main), Windows 10 build 19045, debug layer enabled, 0 debug errors and 0 debug warnings on every dispatch.

Command WARP 1.0.22 (app-local) NVIDIA GeForce RTX 3080, driver 32.0.15.9174
tests/compute_store_check.py draw-descriptor-store-format pass, including the 10_10_10_2 refusal pass, including the 10_10_10_2 refusal
tests/compute_load_format_check.py draw pass (7 dispatches, 14 wrong references, 11 mutated sources) pass (same counts)

Other checks:

  • tests/compute_store_check.py binary with LLVM 15: pass.
  • tests/compute_load_format_check.py binary with LLVM 15: pass.
  • form_coverage_check, docs_links_check and bidi_controls_check: pass.

No capability skips.

The open d16 PR #2165 uses code 44 in its fixture. Once one of the two merges, I'll update the other.

cmake --build --preset dev --target offscreen_check
ctest --preset dev --no-tests=error -R '^compute_(store_aot_descriptor_(store|load)_format_|load_format_controls$)' -V

🤖 Generated with Claude Code

AMD format names list the fields from the most significant bit. Mesa's
gfx10_format_table.py reverses each name into little-endian channel
sizes, and radeonsi and radv map R10G10B10A2 (x in bits 9:0, w in bits
31:30) to 2_10_10_10. The descriptor-format store and load decoders used
the 10-bit-x packer for BUF_FMT_10_10_10_2_UNORM (44, legacy DFMT 8),
whose x is the 2-bit field in bits 1:0, so they would have read and
written the wrong fields. The packer now serves BUF_FMT_2_10_10_10_UNORM
(50, legacy DFMT 9). Code 44 and legacy DFMT 8 are refused: the store is
skipped and the load is invalid, so nothing is published.

The store and load fixtures use code 50, and each adds a GPU run with
code 44 that must leave its output at the sentinel. The controls reject
the code-44 and legacy DFMT 8 words, and fail with the old mapping.

Refs R0Y00#2022

AI-assisted (Claude Code); reviewed and run locally.

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

@tedin7 tedin7 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.

Review of head 282f630 (comment only).

Findings: 0 P1, 0 P2.

  • The fix is correct. AMD format names list fields from the most significant bit, and the R10G10B10A2 layout (x in bits 9:0, w in bits 31:30) is BUF_FMT_2_10_10_10_UNORM (gfx10 code 50, legacy DFMT 9). Code 44 / DFMT 8 (10_10_10_2) has a 2-bit x field in bits 1:0, so refusing it is right.
  • Legacy table (_legacy_field(9, 0): 50), the format table and the pinned legacy word 0x00048FAC agree with each other.
  • Tests cover both directions: the load check adds an invalid 10_10_10_2_UNORM case, the store controls reject code 44 and legacy 0x00040FAC, and the draw test adds a refused-store run. Docs are updated to match.
  • No concurrent open or recent merged PR changes this table. #2006 touches the fetch format in gfx2hlsl, a different file.

Commands run locally on the PR head:

  • python3 -B tests/compute_load_format_check.py -> exit 0
  • descriptor_store_controls() from tests/compute_store_check.py -> passed
  • python3 tests/docs_links_check.py -> Checked 18 Markdown files and 404 links
  • python3 tests/bidi_controls_check.py -> pass
  • git diff --check origin/main...HEAD -> clean
  • Mutation 1: tools/compute_store_aot.py format table 50: ("unorm10", 4) -> 44: -> store controls FAIL (killed)
  • Mutation 2: legacy table _legacy_field(9, 0): 50 -> _legacy_field(8, 0): 50 -> store controls FAIL (killed)
  • Files are .py and docs only. CI: Build and test on Windows = pass, Linux Python checks = pass, gfx1013 fixtures assemble = pass.

AI-assisted; commands listed were executed locally.

@stan495 stan495 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Verified head 282f6301 on Windows x64 (dev preset, MSVC 19.44.35228.0, SDK/DXC 10.0.26100.0):

  • python -B tests/compute_load_format_check.py -> passed
  • ctest --preset dev --no-tests=error -R 'compute_store_aot_.*format' -V -> 8/8 passed (compute_store_aot_mubuf_load_format_d16_{hardware,warp}, compute_store_aot_mubuf_format_{hardware,warp}, compute_store_aot_mubuf_store_format_{hardware,warp}, compute_store_aot_mubuf_store_format_xyz_{hardware,warp})
  • ctest --preset dev --no-tests=error -R '^compute_store_aot_descriptor_load_format_' -V -> 2/2 passed (compute_store_aot_descriptor_load_format_{hardware,warp}; 7 dispatches, 14 wrong references, 11 mutated sources checked, debug_errors=0 debug_warnings=0)
    • Hardware: AMD Radeon RX 7900 XTX (vendor=1002 device=744c, driver 32.0.32029.2010)
    • WARP: Microsoft Basic Render Driver (vendor=1414 device=008c, driver 10.0.26100.9818)

Verdict: Approved at 282f6301.

@R0Y00
R0Y00 merged commit 2e4f44c into R0Y00:main Nov 25, 2026
5 checks passed
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.

4 participants