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

Merged
archielcqp-a11y merged 1 commit from upstream-pr/2192 into main 2026-11-25 05:53:36 +00:00
archielcqp-a11y commented 2026-11-25 03:31:48 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by archielcqp-a11y on 2026-11-25T03:31:48Z.


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

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6596555297 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2192). Originally posted by [archielcqp-a11y](https://github.com/archielcqp-a11y) on 2026-11-25T03:31:48Z. --- 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. ```powershell 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](https://claude.com/claude-code)
tedin7 commented 2026-11-25 04:04:15 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T03:40:00Z.

Review: COMMENTED


Review of head 282f63012e (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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6051518372 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2192#pullrequestreview-6051518372). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T03:40:00Z. **Review:** COMMENTED --- Review of head 282f63012e54a07db6267ce24dba6b9c75ec7152 (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.
upstream-sync closed this pull request 2026-11-25 06:01:22 +00:00
stan495 commented 2026-11-25 06:01:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by stan495 on 2026-11-25T05:32:17Z.

Review: APPROVED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6052329601 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2192#pullrequestreview-6052329601). Originally posted by [stan495](https://github.com/stan495) on 2026-11-25T05:32:17Z. **Review:** APPROVED --- 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`.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!2184
No description provided.