rdna2-hwprobe: mip selection and resinfo probe; RDNA2 rules for gather4_l bias/clamp and 2D-array resinfo #361

Closed
github-bot wants to merge 1 commit from gh-pr/361/head into gh-pr/361/base
Owner

@⁠SchmashinPrunes on GitHub · 2026-11-24 13:51 UTC · original
SchmashinPrunes:rdna2-mip-select → main · +352 −1 · 4 files · 1 commits · closed without merging

RDNA2 measurements for two descriptor questions:

  • #306, question 3: does the S# LOD_BIAS apply to image_gather4_l, and in what order do bias, clamp and base level combine?
  • The image_get_resinfo 2D-array layer word: the BLOCKERS formula that QuentinDanblon's design question on #306 relies on.

Library / area: tools/rdna2-hwprobe (no runtime code), docs/BLOCKERS.md

Exports changed (exports.txt rows): none

Source of the behaviour:

  • Results recorded on RDNA2 hardware: the gfx1036 iGPU of a Ryzen 5 9600X, ROCm/HIP 5.7.1, raw wave32 kernels.
  • That is RDNA2, not the console's gfx1013.
  • Descriptor field positions are from Mesa's gfx10-rsrc.json. They match the ones #306 uses.
  • No game or console files, and no third-party code.

Probe

  • g4_fill writes a 16×16 R32_FLOAT image with 5 levels through image_store_mip. The texel at level m, (x, y) holds m·1000 + y·16 + x, so the level layout in memory doesn't matter.
  • Each case then builds its T# and S# and runs image_gather4_l, image_gather4_lz and image_sample_l (point xy filter).
  • 72,900 cases cover every combination of:
    • 20 explicit LODs;
    • 9 LOD_BIAS values;
    • 9 S# MIN/MAX_LOD pairs;
    • 5 T# BASE/LAST_LEVEL pairs;
    • 3 T# MIN_LOD values;
    • 3 mip filters.
  • image_get_resinfo covers 2D array, 2D and 3D: 8 layer counts × 6 base/last pairs × 7 levels.
  • Two runs were identical.

What RDNA2 does

All fields are in levels: S# and T# LODs are u4.8, LOD_BIAS is s6.8.

  • The LOD: rel = max(clamp(lod + LOD_BIAS, S# MIN_LOD, S# MAX_LOD), T# MIN_LOD − BASE_LEVEL). So:
    • LOD_BIAS does apply to _l;
    • the S# clamp comes after the bias and counts from BASE_LEVEL, which is the D3D order #306 uses;
    • T# MIN_LOD is an absolute level.
  • Point or linear mip filter: level = clamp(BASE_LEVEL + floor(rel + 0.5), BASE_LEVEL, LAST_LEVEL).
    • An exact .5 rounds up: LOD 0.5 gathers from level 1, and 1.5 from level 2.
    • The nearest-level rule on main (l > 0.5 ? ceil(l + 0.5) − 1 : 0, hlsl.rs) picks the lower level at every exact .5. It's the same rule #306 keeps, so I'm noting it there rather than changing it here.
  • Mip filter none: level = max(BASE_LEVEL, floor(T# MIN_LOD)), clamped to LAST_LEVEL. The LOD and the S# fields are ignored.
  • No blending of levels: gather4 never blends two levels. With a linear mip filter it reads the same nearest level as with point. image_sample_l blends floor(rel) with the next level.
  • image_gather4_lz reads BASE_LEVEL and ignores the S# fields. When floor(T# MIN_LOD) > BASE_LEVEL it returns 0 in all four components.
  • image_get_resinfo on a 2D array returns DEPTH + 1 at every level and every BASE_LEVEL: 100 layers still give 100 at level 3. The BLOCKERS line "max(1, layers >> (BASE_LEVEL + level)); 100 layers at level 3 give 12" does not hold on RDNA2.
    • Only 3D images minify the depth.
    • A plain 2D image returns 0 in the third word.
    • Past the last level, all three words are 0. That matches the existing DONE line.

mip_probe.py check reproduces all of the above with 0 differences. Two deliberate mutations are caught:

  • swapping in main's nearest-level rule fails 8,666 gather4_l cases;
  • swapping in the layer-minify formula fails 112 resinfo cases.

Change

  • tools/rdna2-hwprobe/mip_probe.py (new): gen writes the kernels and inputs; check <in> <out> compares a recording with the rules above and exits non-zero on any difference.
  • tools/rdna2-hwprobe/mip_runner.cpp (new): a HIP runner that keeps one image buffer across the kernels of a run.
  • README.txt: a section with the commands.
  • docs/BLOCKERS.md:
    • the gather4_l entry gets a MEASURED line with the rule above;
    • the 2D-array resinfo OPEN line is closed, because the translator's unminified host array size is already the RDNA2 value, so no BASE_LEVEL wiring is needed for it.

Tests

  • On the gfx1036 machine, following the README from these files: check printed 0 differences for gather4_l, gather4_lz, sample_l and resinfo (2D array, 2D, 3D).
  • pr_gate.py --base origin/main --head HEAD: 4 files checked, 0 problems.
  • No crate changes.

#360 also appends a section to tools/rdna2-hwprobe/README.txt. Whichever lands second needs a trivial merge there.

  • cargo test unaffected (no crate changes)
  • No game or console files and no binaries included
  • No fake success

🤖 Generated with Claude Code

**@⁠SchmashinPrunes** on GitHub · 2026-11-24 13:51 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/361) `SchmashinPrunes:rdna2-mip-select` → `main` · +352 −1 · 4 files · 1 commits · closed without merging RDNA2 measurements for two descriptor questions: - **#306, question 3:** does the S# LOD_BIAS apply to `image_gather4_l`, and in what order do bias, clamp and base level combine? - **The `image_get_resinfo` 2D-array layer word:** the BLOCKERS formula that QuentinDanblon's design question on #306 relies on. **Library / area:** `tools/rdna2-hwprobe` (no runtime code), `docs/BLOCKERS.md` **Exports changed (exports.txt rows):** none **Source of the behaviour:** - Results recorded on RDNA2 hardware: the gfx1036 iGPU of a Ryzen 5 9600X, ROCm/HIP 5.7.1, raw wave32 kernels. - That is RDNA2, not the console's gfx1013. - Descriptor field positions are from Mesa's `gfx10-rsrc.json`. They match the ones #306 uses. - No game or console files, and no third-party code. ### Probe - `g4_fill` writes a 16×16 R32_FLOAT image with 5 levels through `image_store_mip`. The texel at level m, (x, y) holds m·1000 + y·16 + x, so the level layout in memory doesn't matter. - Each case then builds its T# and S# and runs `image_gather4_l`, `image_gather4_lz` and `image_sample_l` (point xy filter). - 72,900 cases cover every combination of: - 20 explicit LODs; - 9 LOD_BIAS values; - 9 S# MIN/MAX_LOD pairs; - 5 T# BASE/LAST_LEVEL pairs; - 3 T# MIN_LOD values; - 3 mip filters. - `image_get_resinfo` covers 2D array, 2D and 3D: 8 layer counts × 6 base/last pairs × 7 levels. - Two runs were identical. ### What RDNA2 does All fields are in levels: S# and T# LODs are u4.8, LOD_BIAS is s6.8. - **The LOD:** `rel = max(clamp(lod + LOD_BIAS, S# MIN_LOD, S# MAX_LOD), T# MIN_LOD − BASE_LEVEL)`. So: - LOD_BIAS **does** apply to `_l`; - the S# clamp comes after the bias and counts from BASE_LEVEL, which is the D3D order #306 uses; - T# MIN_LOD is an absolute level. - **Point or linear mip filter:** `level = clamp(BASE_LEVEL + floor(rel + 0.5), BASE_LEVEL, LAST_LEVEL)`. - An **exact .5 rounds up**: LOD 0.5 gathers from level 1, and 1.5 from level 2. - The nearest-level rule on main (`l > 0.5 ? ceil(l + 0.5) − 1 : 0`, hlsl.rs) picks the lower level at every exact .5. It's the same rule #306 keeps, so I'm noting it there rather than changing it here. - **Mip filter none:** `level = max(BASE_LEVEL, floor(T# MIN_LOD))`, clamped to LAST_LEVEL. The LOD and the S# fields are ignored. - **No blending of levels:** gather4 never blends two levels. With a linear mip filter it reads the same nearest level as with point. `image_sample_l` blends floor(rel) with the next level. - **`image_gather4_lz`** reads BASE_LEVEL and ignores the S# fields. When floor(T# MIN_LOD) > BASE_LEVEL it returns 0 in all four components. - **`image_get_resinfo` on a 2D array returns DEPTH + 1 at every level and every BASE_LEVEL:** 100 layers still give 100 at level 3. The BLOCKERS line "max(1, layers >> (BASE_LEVEL + level)); 100 layers at level 3 give 12" does not hold on RDNA2. - Only 3D images minify the depth. - A plain 2D image returns 0 in the third word. - Past the last level, all three words are 0. That matches the existing DONE line. `mip_probe.py check` reproduces all of the above with 0 differences. Two deliberate mutations are caught: - swapping in main's nearest-level rule fails 8,666 gather4_l cases; - swapping in the layer-minify formula fails 112 resinfo cases. ### Change - `tools/rdna2-hwprobe/mip_probe.py` (new): `gen` writes the kernels and inputs; `check <in> <out>` compares a recording with the rules above and exits non-zero on any difference. - `tools/rdna2-hwprobe/mip_runner.cpp` (new): a HIP runner that keeps one image buffer across the kernels of a run. - `README.txt`: a section with the commands. - `docs/BLOCKERS.md`: - the gather4_l entry gets a MEASURED line with the rule above; - the 2D-array resinfo OPEN line is closed, because the translator's unminified host array size is already the RDNA2 value, so no BASE_LEVEL wiring is needed for it. ### Tests - On the gfx1036 machine, following the README from these files: `check` printed 0 differences for gather4_l, gather4_lz, sample_l and resinfo (2D array, 2D, 3D). - `pr_gate.py --base origin/main --head HEAD`: 4 files checked, 0 problems. - No crate changes. #360 also appends a section to `tools/rdna2-hwprobe/README.txt`. Whichever lands second needs a trivial merge there. - [x] `cargo test` unaffected (no crate changes) - [x] No game or console files and no binaries included - [x] No fake success 🤖 Generated with [Claude Code](https://claude.com/claude-code)
mip_probe.py and mip_runner.cpp record image_gather4_l, image_gather4_lz,
image_sample_l and image_get_resinfo on gfx1036 over explicit LOD, S#
LOD_BIAS / MIN_LOD / MAX_LOD / MIP_FILTER and T# BASE_LEVEL / LAST_LEVEL /
MIN_LOD, and check a recording against the rules found.

BLOCKERS: the measured mip rule is added to the gather4_l entry (bias
applies to _l, clamp after bias, exact .5 rounds up, T# MIN_LOD is an
absolute level). The 2D-array resinfo OPEN line is closed: RDNA2 does not
minify the layer word, so the current translator output is the RDNA2 value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 06:20:12 +00:00
github-bot closed this pull request 2026-11-26 06:20:12 +00:00
Author
Owner

@⁠omonkeyz on GitHub · 2026-11-25 13:50 UTC · original

Applied on main in b931581 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

**@⁠omonkeyz** on GitHub · 2026-11-25 13:50 UTC · [original](https://github.com/omonkeyz/xbox-emulator/pull/361#issuecomment-7164374601) Applied on main in b931581 (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.