feat(rdna2): support MIMG load/store/resinfo, bilinear, compare, and gather4 #126

Manually merged
github merged 2 commits from gh-pr/126/head into gh-pr/126/base 2026-11-26 05:33:02 +00:00
Owner

@⁠Lewandox on GitHub · 2026-11-24 11:04 UTC · original
Lewandox:feat/rdna2-mimg-load-store-sampling → main · +1064 −93 · 14 files · 2 commits · merged 2026-11-24 14:05 UTC

Part of #21.

Summary

Extends 2D RDNA 2 MIMG support in both the reference interpreter (emu/rdna2_exec_image.py) and HLSL recompiler (emu/rdna2_hlsl_image.py) with bit-exact parity:

  1. Direct image ops (no sampler):
    • image_load: integer (x, y) fetch with OOB returning zeros, dst_sel swizzle, and dmask packing.
    • image_store: integer (x, y) write with OOB no-op, full/partial dmask read-modify-write for both 32_32_32_32_FLOAT and 8_8_8_8_UNORM (matching precise float32-to-UNORM8 rounding), and AllMemoryBarrierWithGroupSync() in compute HLSL.
    • image_get_resinfo: returns (width, height, 1, 1) at mip == 0 and (0, 0, 0, 1) for out-of-range mips without dst_sel swizzle.
  2. Extended sampling, filtering, and addressing:
    • Bilinear filtering (FILTER_LINEAR = 1) using explicit precise float intermediates in HLSL and matching float32 rounding in Python to prevent FMA drift.
    • Additional S# clamp modes: CLAMP_MIRROR (1), CLAMP_MIRROR_ONCE_LAST_TEXEL (3), CLAMP_BORDER (6), and CLAMP_MIRROR_ONCE_BORDER (7), plus the 3 standard border colors (BORDER_TRANS_BLACK, BORDER_OPAQUE_BLACK, BORDER_OPAQUE_WHITE).
    • image_sample_lz, image_sample_c / image_sample_c_lz (3-register (z_ref, s, t) layout, depth compare ops 0..7, point and bilinear PCF), and image_gather4 / image_gather4_lz (hardware (x0, y1), (x1, y1), (x1, y0), (x0, y0) order, single-channel dmask validation, NSA support).

Tests & Verification

  • Added tests/test_rdna2_image_ops.py (+20 tests: 13 CPU unit tests + 7 @gpu bit-exact parity tests covering image_load/image_store/image_get_resinfo, bilinear + mirror/border clamp modes, image_sample_c_lz PCF with NSA, and image_gather4_lz).
  • Updated obsolete negative assertions in tests/test_rdna2_image.py (anisotropic filter) and tests/test_rdna2_exec.py (image_load_mip).
  • Synced all 8 READMEs (578 -> 598 tests).
  • Verified locally:
    • ruff check --select W605,F,E9 PrototypeScarlett tests tools -> All checks passed
    • pytest tests/test_rdna2_image.py tests/test_rdna2_image_ops.py tests/test_rdna2_hlsl.py tests/test_rdna2_graphics.py tests/test_rdna2_exec.py tests/test_readme_sync.py -> all CPU tests green (@gpu tests ready for Windows DXC/GPU CI).
**@⁠Lewandox** on GitHub · 2026-11-24 11:04 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/126) `Lewandox:feat/rdna2-mimg-load-store-sampling` → `main` · +1064 −93 · 14 files · 2 commits · merged 2026-11-24 14:05 UTC Part of #21. ### Summary Extends 2D RDNA 2 `MIMG` support in both the reference interpreter (`emu/rdna2_exec_image.py`) and HLSL recompiler (`emu/rdna2_hlsl_image.py`) with bit-exact parity: 1. **Direct image ops (no sampler):** - `image_load`: integer `(x, y)` fetch with OOB returning zeros, `dst_sel` swizzle, and `dmask` packing. - `image_store`: integer `(x, y)` write with OOB no-op, full/partial `dmask` read-modify-write for both `32_32_32_32_FLOAT` and `8_8_8_8_UNORM` (matching `precise` float32-to-UNORM8 rounding), and `AllMemoryBarrierWithGroupSync()` in compute HLSL. - `image_get_resinfo`: returns `(width, height, 1, 1)` at `mip == 0` and `(0, 0, 0, 1)` for out-of-range mips without `dst_sel` swizzle. 2. **Extended sampling, filtering, and addressing:** - Bilinear filtering (`FILTER_LINEAR = 1`) using explicit `precise float` intermediates in HLSL and matching float32 rounding in Python to prevent FMA drift. - Additional `S#` clamp modes: `CLAMP_MIRROR` (1), `CLAMP_MIRROR_ONCE_LAST_TEXEL` (3), `CLAMP_BORDER` (6), and `CLAMP_MIRROR_ONCE_BORDER` (7), plus the 3 standard border colors (`BORDER_TRANS_BLACK`, `BORDER_OPAQUE_BLACK`, `BORDER_OPAQUE_WHITE`). - `image_sample_lz`, `image_sample_c` / `image_sample_c_lz` (3-register `(z_ref, s, t)` layout, depth compare ops `0..7`, point and bilinear PCF), and `image_gather4` / `image_gather4_lz` (hardware `(x0, y1), (x1, y1), (x1, y0), (x0, y0)` order, single-channel `dmask` validation, NSA support). ### Tests & Verification - Added `tests/test_rdna2_image_ops.py` (+20 tests: 13 CPU unit tests + 7 `@gpu` bit-exact parity tests covering `image_load`/`image_store`/`image_get_resinfo`, bilinear + mirror/border clamp modes, `image_sample_c_lz` PCF with NSA, and `image_gather4_lz`). - Updated obsolete negative assertions in `tests/test_rdna2_image.py` (anisotropic filter) and `tests/test_rdna2_exec.py` (`image_load_mip`). - Synced all 8 READMEs (`578` -> `598` tests). - Verified locally: - `ruff check --select W605,F,E9 PrototypeScarlett tests tools` -> All checks passed - `pytest tests/test_rdna2_image.py tests/test_rdna2_image_ops.py tests/test_rdna2_hlsl.py tests/test_rdna2_graphics.py tests/test_rdna2_exec.py tests/test_readme_sync.py` -> all CPU tests green (`@gpu` tests ready for Windows DXC/GPU CI).
Conflits des README (8 langues) résolus avec les chiffres de main, recalculés
après fusion : 599 encodages RDNA 2 exécutés sur 1 487 (40 %) et 647 tests
collectés par la suite complète.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LwHrL6fhkpeG9ByE1rJxrt
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:33:00 +00:00
github manually merged commit 7e5a8e9d2b into gh-pr/126/base 2026-11-26 05:33:02 +00:00
Author
Owner

@⁠Lewandox on GitHub · 2026-11-24 12:10 UTC · original

Rebased onto main (b15d882) and addressed all blocking and non-blocking review points in 30b95a5:

  1. Mip levels (BASE_LEVEL / LAST_LEVEL): rdna2_image.image() now decodes base_level (bits 15:12) and last_level (bits 19:16) of SQ_IMG_RSRC_WORD3 and rejects any descriptor with base_level != 0 or last_level != 0 by name (test_image_descriptor_rejects_mipmapped_levels).
  2. README sync: Updated all 8 READMEs to 540 encodings (matching coverage() on top of #129) and 614 automated tests.
  3. Expanded @gpu coverage: Parametrized GPU byte-for-byte parity tests across all 6 supported clamp modes (0, 1, 2, 3, 6, 7) × both filters (POINT, LINEAR), both filters × non-LZ/LZ image_sample_c, and non-LZ/LZ image_gather4.
  4. Citations: Documented the GFX10 SQ_TEX_* descriptor numbering, depth compare direction, UNORM8 store rounding, and gather4 texel order.

CI (lint + pytest) is green and the PR is ready for re-review.

**@⁠Lewandox** on GitHub · 2026-11-24 12:10 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/126#issuecomment-7131059314) Rebased onto `main` (`b15d882`) and addressed all blocking and non-blocking review points in `30b95a5`: 1. **Mip levels (`BASE_LEVEL` / `LAST_LEVEL`):** `rdna2_image.image()` now decodes `base_level` (bits `15:12`) and `last_level` (bits `19:16`) of `SQ_IMG_RSRC_WORD3` and rejects any descriptor with `base_level != 0` or `last_level != 0` by name (`test_image_descriptor_rejects_mipmapped_levels`). 2. **README sync:** Updated all 8 READMEs to `540` encodings (matching `coverage()` on top of `#129`) and `614` automated tests. 3. **Expanded `@gpu` coverage:** Parametrized GPU byte-for-byte parity tests across all 6 supported clamp modes (`0, 1, 2, 3, 6, 7`) × both filters (`POINT`, `LINEAR`), both filters × non-LZ/LZ `image_sample_c`, and non-LZ/LZ `image_gather4`. 4. **Citations:** Documented the GFX10 `SQ_TEX_*` descriptor numbering, depth compare direction, UNORM8 store rounding, and gather4 texel order. CI (`lint` + `pytest`) is green and the PR is ready for re-review.
Author
Owner

@⁠KainanP on GitHub · 2026-11-24 13:20 UTC · original

Essai sur NVIDIA (RTX 4060 Laptop, pilote 32.0.16.1047, Windows 11), commit 30b95a5, runtime compilé :

python -m pytest                                   → 600 passed, 14 skipped
pytest tests/test_rdna2_exec.py tests/test_rdna2_image.py tests/test_rdna2_image_ops.py tests/test_rdna2_graphics.py → 74 passed
ANYXBOXX_GPU=warp (mêmes fichiers)                 → 74 passed

Rien à signaler sur cette carte : toutes les comparaisons GPU/interpréteur passent octet par octet.

Essai fait avec l'aide d'une IA (Claude Code).

**@⁠KainanP** on GitHub · 2026-11-24 13:20 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/126#issuecomment-7132692651) Essai sur NVIDIA (RTX 4060 Laptop, pilote 32.0.16.1047, Windows 11), commit `30b95a5`, runtime compilé : ``` python -m pytest → 600 passed, 14 skipped pytest tests/test_rdna2_exec.py tests/test_rdna2_image.py tests/test_rdna2_image_ops.py tests/test_rdna2_graphics.py → 74 passed ANYXBOXX_GPU=warp (mêmes fichiers) → 74 passed ``` Rien à signaler sur cette carte : toutes les comparaisons GPU/interpréteur passent octet par octet. _Essai fait avec l'aide d'une IA (Claude Code)._
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-24 11:39 UTC · original · requested changes

Review of #126 (MIMG load/store/resinfo, bilinear, compare, gather4). Changes requested.

Passing: 438 tests passed (GPU tests run, dxc present); the 5 test_native.py failures are the known ones and also fail on origin/main; ruff clean; 598 tests matches the README.

Blocking:

  1. Mip levels are not decoded. rdna2_image.image() ignores the T# BASE_LEVEL/LAST_LEVEL fields (no "level" in rdna2_image.py). image_sample (implicit LOD) therefore always reads level 0 of a mipmapped texture, and image_get_resinfo always returns a mip count of 1. Please reject descriptors with more than one level by name (rule 3), or implement the level selection and the mip count, with a test on each.
  2. README: the GPU row still says 521 encodings. The branch computes 532 (coverage()), so the row must say 532 (the combined count after #129 is 540, see the merge note).
  3. GPU coverage of rule 4: the byte-for-byte GPU tests cover only three clamp/filter/border combinations for bilinear, one bilinear compare and one gather4 (LZ forms only). Please parametrize over the supported clamp modes (0, 1, 2, 3, 6, 7), both filters, and the non-LZ forms of sample_c and gather4.

Non-blocking: cite the source for the numbering of the clamp, filter, compare and border constants (GFX10 SQ_TEX_* values), the depth compare direction, the UNORM store rounding (floor(v*255+0.5)) and the gather4 texel order.

🤖 Generated with Claude Code

**@⁠LooperSalty** on GitHub · 2026-11-24 11:39 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/126#pullrequestreview-6038521136) · **requested changes** Review of #126 (MIMG load/store/resinfo, bilinear, compare, gather4). Changes requested. Passing: 438 tests passed (GPU tests run, dxc present); the 5 `test_native.py` failures are the known ones and also fail on origin/main; ruff clean; 598 tests matches the README. Blocking: 1. Mip levels are not decoded. `rdna2_image.image()` ignores the T# BASE_LEVEL/LAST_LEVEL fields (no "level" in rdna2_image.py). `image_sample` (implicit LOD) therefore always reads level 0 of a mipmapped texture, and `image_get_resinfo` always returns a mip count of 1. Please reject descriptors with more than one level by name (rule 3), or implement the level selection and the mip count, with a test on each. 2. README: the GPU row still says 521 encodings. The branch computes 532 (`coverage()`), so the row must say 532 (the combined count after #129 is 540, see the merge note). 3. GPU coverage of rule 4: the byte-for-byte GPU tests cover only three clamp/filter/border combinations for bilinear, one bilinear compare and one gather4 (LZ forms only). Please parametrize over the supported clamp modes (0, 1, 2, 3, 6, 7), both filters, and the non-LZ forms of sample_c and gather4. Non-blocking: cite the source for the numbering of the clamp, filter, compare and border constants (GFX10 SQ_TEX_* values), the depth compare direction, the UNORM store rounding (`floor(v*255+0.5)`) and the gather4 texel order. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Author
Owner

@⁠LooperSalty on GitHub · 2026-11-24 13:30 UTC · original · review (dismissed)

Les points bloquants de la revue du 11:39 sont traités dans 30b95a5 (réponse du 12:10) : rejet nommé des T# à plusieurs niveaux (test_image_descriptor_rejects_mipmapped_levels), README à 614 tests et 540 encodages (cohérent avec la suite), GPU paramétré sur les modes de clamp, les deux filtres et les formes non LZ. Vérifié : test_rdna2_exec.py, test_rdna2_image.py, test_rdna2_image_ops.py, test_rdna2_graphics.py : 64 passed sur GPU et sur WARP ; suite complète sans échec hors les tests natifs liés au runtime local ; ruff propre. Les références des constantes (non bloquantes) restent souhaitables. Approuvée.

**@⁠LooperSalty** on GitHub · 2026-11-24 13:30 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/126#pullrequestreview-6040057489) · **review (dismissed)** Les points bloquants de la revue du 11:39 sont traités dans 30b95a5 (réponse du 12:10) : rejet nommé des T# à plusieurs niveaux (`test_image_descriptor_rejects_mipmapped_levels`), README à 614 tests et 540 encodages (cohérent avec la suite), GPU paramétré sur les modes de clamp, les deux filtres et les formes non LZ. Vérifié : `test_rdna2_exec.py`, `test_rdna2_image.py`, `test_rdna2_image_ops.py`, `test_rdna2_graphics.py` : 64 passed sur GPU et sur WARP ; suite complète sans échec hors les tests natifs liés au runtime local ; ruff propre. Les références des constantes (non bloquantes) restent souhaitables. Approuvée.
This discussion has been locked. Commenting is limited to contributors.
No description provided.