docs, tests: describe heap sampler LOD limits as applied at run time #2322

Merged
roansystemlabs merged 1 commit from upstream-pr/2330 into main 2026-11-25 13:08:14 +00:00
roansystemlabs commented 2026-11-25 12:36:06 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T12:36:06Z.


Refs #2221.

Follow-up to #2287 and #2298, which said this cleanup could come separately. There is no behaviour change; the diff touches two docs and one test fixture.

Docs. docs/startup-runtime.md and docs/experiments.md still said a heap sampler translates "with an unbounded LOD range". Since #2287, the run-time heap table applies each entry's MIN_LOD and MAX_LOD through dynamic_sampler(). Both passages now describe what main does:

  • gfx2hlsl.py still does not validate a heap sampler and logs that once per module;
  • with X2W_SAMPLER_HEAP=1, a table entry applies its MIN_LOD and MAX_LOD at run time;
  • its LOD bias is not carried;
  • a MIN_LOD above MAX_LOD is passed through unchanged;
  • the default-sampler shortcut keeps a static sampler with an unbounded LOD range.

Test. tests/mesh_heap_sampler_draw.cpp decoded MinLOD/MaxLOD a second time after dynamic_sampler(). The body of #2287 offered to drop that decode, and this change does. fixture_sampler() now returns dynamic_sampler(words) unchanged, so the mesh draw exercises the production decode. The fixture, expected colours and assertions are the same.

Evidence. Windows 11, WARP and an RTX 3070, with the debug layer on:

ctest --preset dev --no-tests=error -R "^(mesh_heap_sampler_|startup_sampler_|startup_translated_sampler_bindings)" -V
  • Before (main with the old fixture) and after: 19/19 passed.
  • Every mesh case line is identical before and after: 0 of 1,024 mismatches on the five words, and the swapped-entry and default-shortcut controls still fail as intended.
  • debug_errors=0 debug_warnings=0 on every draw.
  • Negative control, a local change that was not committed: dynamic_sampler() was made to decode without the LOD fields. mesh_heap_sampler_draw_{warp,hardware} then fail at word 0x20 with 1,024 of 1,024 mismatches, so the clamp the mesh draw depends on now comes from dynamic_sampler(). startup_sampler_lod_* and startup_translated_sampler_bindings fail under the same change.
  • python -B tests/docs_links_check.py passes.

Not tested: AMD or Intel GPUs, and console hardware.

Open question, no code change without your call. Constant and smpl samplers in gfx2hlsl.py already refuse MIN_LOD above MAX_LOD (#2177). A heap entry with the same pair is passed to D3D12 unchanged. Should heap entries:

  1. keep being accepted as they are today, or
  2. be refused like the constant samplers? A refused entry would fall back to the border sampler and be counted.

We have no source for what the console sampler does with that pair. The RDNA 2 ISA (§8.2.7, table 46) defines the fields but not the inverted case, so we have left the behaviour as it is.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6604614527 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2330). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T12:36:06Z. --- Refs #2221. Follow-up to #2287 and #2298, which said this cleanup could come separately. There is no behaviour change; the diff touches two docs and one test fixture. **Docs.** `docs/startup-runtime.md` and `docs/experiments.md` still said a heap sampler translates "with an unbounded LOD range". Since #2287, the run-time heap table applies each entry's MIN_LOD and MAX_LOD through `dynamic_sampler()`. Both passages now describe what main does: - `gfx2hlsl.py` still does not validate a heap sampler and logs that once per module; - with `X2W_SAMPLER_HEAP=1`, a table entry applies its MIN_LOD and MAX_LOD at run time; - its LOD bias is not carried; - a MIN_LOD above MAX_LOD is passed through unchanged; - the default-sampler shortcut keeps a static sampler with an unbounded LOD range. **Test.** `tests/mesh_heap_sampler_draw.cpp` decoded MinLOD/MaxLOD a second time after `dynamic_sampler()`. The body of #2287 offered to drop that decode, and this change does. `fixture_sampler()` now returns `dynamic_sampler(words)` unchanged, so the mesh draw exercises the production decode. The fixture, expected colours and assertions are the same. **Evidence.** Windows 11, WARP and an RTX 3070, with the debug layer on: ``` ctest --preset dev --no-tests=error -R "^(mesh_heap_sampler_|startup_sampler_|startup_translated_sampler_bindings)" -V ``` - Before (main with the old fixture) and after: 19/19 passed. - Every mesh case line is identical before and after: 0 of 1,024 mismatches on the five words, and the swapped-entry and default-shortcut controls still fail as intended. - `debug_errors=0 debug_warnings=0` on every draw. - Negative control, a local change that was not committed: `dynamic_sampler()` was made to decode without the LOD fields. `mesh_heap_sampler_draw_{warp,hardware}` then fail at word 0x20 with 1,024 of 1,024 mismatches, so the clamp the mesh draw depends on now comes from `dynamic_sampler()`. `startup_sampler_lod_*` and `startup_translated_sampler_bindings` fail under the same change. - `python -B tests/docs_links_check.py` passes. Not tested: AMD or Intel GPUs, and console hardware. **Open question, no code change without your call.** Constant and `smpl` samplers in `gfx2hlsl.py` already refuse MIN_LOD above MAX_LOD (#2177). A heap entry with the same pair is passed to D3D12 unchanged. Should heap entries: 1. keep being accepted as they are today, or 2. be refused like the constant samplers? A refused entry would fall back to the border sampler and be counted. We have no source for what the console sampler does with that pair. The RDNA 2 ISA (§8.2.7, table 46) defines the fields but not the inverted case, so we have left the behaviour as it is. AI-assisted.
upstream-sync closed this pull request 2026-11-25 14:04:45 +00:00
tedin7 commented 2026-11-25 14:04:46 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T13:10:31Z.

Review: COMMENTED


Review of head 2102ab014a2797b32c158954670c0cdf361e6c42 (docs + one test fixture, no production code).

Findings: 0 P1, 0 P2.

  • tests/mesh_heap_sampler_draw.cpp: the fixture no longer re-decodes MIN_LOD/MAX_LOD. It now relies on dynamic_sampler() -> decode_sampler(words, 0, false, true) in src/startup_stubs/translated_sampler_bindings.h, which divides word 1 bits 11:0 / 23:12 by 256 (4.8 fixed point). The test therefore guards the real code path instead of a copy.
  • Docs (docs/experiments.md, docs/startup-runtime.md) match the code: heap entries apply MIN/MAX LOD, bias is not carried, MIN_LOD > MAX_LOD passes through, default-sampler shortcut stays unbounded (border_sampler() resets MaxLOD).
  • No other open PR covers the same slice (searched open PR titles).

Commands executed locally:

  • python3 tests/docs_links_check.py -> 18 files, 451 links OK
  • python3 tests/bidi_controls_check.py -> no bidi controls
  • git diff --check origin/main...HEAD -> clean
  • Mutation: in dynamic_sampler() pass lod_limits=false. Win2025 WARP Debug ctest -R '^mesh_heap_sampler_draw_warp$' -> Failed (mutation killed). Reverted.
  • Win2025 WARP, --targets offscreen_check --regex '^(mesh_heap_sampler_draw_warp|startup_sampler_heap_warp|startup_sampler_lod_warp|startup_sampler_lod_dropped_warp)$': Debug 4/4 passed, Release /O2 4/4 passed.
  • An earlier full direct-scope Win2025 run passed all four of these tests; its only failure was an unrelated timeout in compute_store_aot_descriptor_load_format_warp under VM load (file not touched by this PR).
  • GitHub CI: Build and test on Windows, Linux Python checks, gfx1013 fixtures all SUCCESS.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6058215373 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2330#pullrequestreview-6058215373). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T13:10:31Z. **Review:** COMMENTED --- Review of head `2102ab014a2797b32c158954670c0cdf361e6c42` (docs + one test fixture, no production code). Findings: 0 P1, 0 P2. - `tests/mesh_heap_sampler_draw.cpp`: the fixture no longer re-decodes MIN_LOD/MAX_LOD. It now relies on `dynamic_sampler()` -> `decode_sampler(words, 0, false, true)` in `src/startup_stubs/translated_sampler_bindings.h`, which divides word 1 bits 11:0 / 23:12 by 256 (4.8 fixed point). The test therefore guards the real code path instead of a copy. - Docs (`docs/experiments.md`, `docs/startup-runtime.md`) match the code: heap entries apply MIN/MAX LOD, bias is not carried, MIN_LOD > MAX_LOD passes through, default-sampler shortcut stays unbounded (`border_sampler()` resets MaxLOD). - No other open PR covers the same slice (searched open PR titles). Commands executed locally: - `python3 tests/docs_links_check.py` -> 18 files, 451 links OK - `python3 tests/bidi_controls_check.py` -> no bidi controls - `git diff --check origin/main...HEAD` -> clean - Mutation: in `dynamic_sampler()` pass `lod_limits=false`. Win2025 WARP Debug `ctest -R '^mesh_heap_sampler_draw_warp$'` -> **Failed** (mutation killed). Reverted. - Win2025 WARP, `--targets offscreen_check --regex '^(mesh_heap_sampler_draw_warp|startup_sampler_heap_warp|startup_sampler_lod_warp|startup_sampler_lod_dropped_warp)$'`: Debug 4/4 passed, Release /O2 4/4 passed. - An earlier full direct-scope Win2025 run passed all four of these tests; its only failure was an unrelated timeout in `compute_store_aot_descriptor_load_format_warp` under VM load (file not touched by this PR). - GitHub CI: Build and test on Windows, Linux Python checks, gfx1013 fixtures all SUCCESS. AI-assisted; commands listed were executed locally.
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!2322
No description provided.