startup: keep the sampler LOD fixture inside MinLOD <= MaxLOD #2298

Manually merged
github merged 1 commit from gh-pr/2298/head into gh-pr/2298/base 2026-11-27 00:13:43 +00:00
Owner

@⁠roansystemlabs on GitHub · 2026-11-25 10:45 UTC · original
roansystemlabs:startup/2287-lod-range → main · +13 −6 · 3 files · 1 commits · merged 2026-11-25 11:00 UTC

Refs #2221.

Change

Follow-up to the review of #2287, which was already merged. The docs line "(MIN_LOD 2, MAX_LOD 1)" read as one heap entry with an inverted pair. The draw actually uses two valid entries: MIN_LOD 2 with MAX_LOD 4095/256, and MIN_LOD 0 with MAX_LOD 1. So no MinLOD > MaxLOD sampler reached D3D12 in startup_sampler_lod_{warp,hardware}. This PR makes that explicit and enforced:

  • tests/startup_sampler_lod.cpp: the draw refuses a fixture entry whose decoded MinLOD is above MaxLOD, and the header comment names both pairs.
  • tests/startup_translated_sampler_bindings_check.cpp: "lod fractions" uses a valid pair (1.25/1.75). The inverted pair (1.75/1.25) is now its own named, device-free case, "min lod above max lod". It checks that the decoder passes such title words through unchanged.
  • docs/startup-runtime.md: names both pairs and says that an inverted pair is passed through unchanged. It also notes that D3D12 documents MaxLOD >= MinLOD and that the console behaviour for that case is not established here. The line wrap is fixed.

No clamp is added to the decoder. The RDNA 2 ISA (§8.2.7, table 46) defines MIN_LOD and MAX_LOD but not what the sampler does when min > max, so a clamp would pick a behaviour without a source.

Verification

On 476e5bc4 (base 25317c63), Windows 11, preset dev, D3D12 debug layer on, WARP and an RTX 3070:

  • ctest --preset dev --no-tests=error -R "startup_sampler_lod_|startup_translated_sampler_bindings|startup_sampler_comparison|startup_sampler_heap_|mesh_heap_sampler_" -V: 15/15 passed in each of three runs.
    • startup_sampler_lod mismatches=0;
    • _dropped_: wrong_mip=2 unexpected=0;
    • startup_translated_sampler_bindings: PASS (63 cases);
    • debug_errors=0 debug_warnings=0 in every draw.
  • ctest --preset dev --no-tests=error -R "startup_sampler|startup_translated_sampler|startup_image_|mesh_|compute_mesh_texture_|offscreen_": 118/118 passed, 0 skipped.
  • git diff --check origin/main...HEAD: clean.

Not run: a mutant that triggers the new fixture check; the condition is one line.

Evidence and follow-up

  • A standalone probe (not part of this PR) on WARP 10.0.26100.9818 and an RTX 3070 (driver 32.0.16.2101) tested pairs (2, 15.996), (0, 1) and (1.75, 1.25). For each pair it called CreateSampler and created a static sampler in a root signature. The debug layer logged no message at creation for any of the pairs, while MaxAnisotropy 17 in the same probe was reported. This covers creation only, not a draw with the inverted pair, and does not change the documented MinLOD <= MaxLOD requirement.
  • Open point: constant and smpl samplers in gfx2hlsl.py already refuse MIN_LOD above MAX_LOD (#2177), while sampler heap entries keep the pair unchanged. Whether heap entries should be refused as well is left open.

AI-assisted.

**@⁠roansystemlabs** on GitHub · 2026-11-25 10:45 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2298) `roansystemlabs:startup/2287-lod-range` → `main` · +13 −6 · 3 files · 1 commits · merged 2026-11-25 11:00 UTC Refs #2221. ## Change Follow-up to the review of #2287, which was already merged. The docs line "(`MIN_LOD` 2, `MAX_LOD` 1)" read as one heap entry with an inverted pair. The draw actually uses two valid entries: `MIN_LOD` 2 with `MAX_LOD` 4095/256, and `MIN_LOD` 0 with `MAX_LOD` 1. So no `MinLOD > MaxLOD` sampler reached D3D12 in `startup_sampler_lod_{warp,hardware}`. This PR makes that explicit and enforced: - `tests/startup_sampler_lod.cpp`: the draw refuses a fixture entry whose decoded `MinLOD` is above `MaxLOD`, and the header comment names both pairs. - `tests/startup_translated_sampler_bindings_check.cpp`: "lod fractions" uses a valid pair (1.25/1.75). The inverted pair (1.75/1.25) is now its own named, device-free case, "min lod above max lod". It checks that the decoder passes such title words through unchanged. - `docs/startup-runtime.md`: names both pairs and says that an inverted pair is passed through unchanged. It also notes that D3D12 documents `MaxLOD >= MinLOD` and that the console behaviour for that case is not established here. The line wrap is fixed. No clamp is added to the decoder. The RDNA 2 ISA (§8.2.7, table 46) defines `MIN_LOD` and `MAX_LOD` but not what the sampler does when min > max, so a clamp would pick a behaviour without a source. ## Verification On `476e5bc4` (base `25317c63`), Windows 11, preset `dev`, D3D12 debug layer on, WARP and an RTX 3070: - `ctest --preset dev --no-tests=error -R "startup_sampler_lod_|startup_translated_sampler_bindings|startup_sampler_comparison|startup_sampler_heap_|mesh_heap_sampler_" -V`: 15/15 passed in each of three runs. - `startup_sampler_lod mismatches=0`; - `_dropped_`: `wrong_mip=2 unexpected=0`; - `startup_translated_sampler_bindings: PASS (63 cases)`; - `debug_errors=0 debug_warnings=0` in every draw. - `ctest --preset dev --no-tests=error -R "startup_sampler|startup_translated_sampler|startup_image_|mesh_|compute_mesh_texture_|offscreen_"`: 118/118 passed, 0 skipped. - `git diff --check origin/main...HEAD`: clean. Not run: a mutant that triggers the new fixture check; the condition is one line. ## Evidence and follow-up - A standalone probe (not part of this PR) on WARP 10.0.26100.9818 and an RTX 3070 (driver 32.0.16.2101) tested pairs (2, 15.996), (0, 1) and (1.75, 1.25). For each pair it called `CreateSampler` and created a static sampler in a root signature. The debug layer logged no message at creation for any of the pairs, while `MaxAnisotropy` 17 in the same probe was reported. This covers creation only, not a draw with the inverted pair, and does not change the documented `MinLOD <= MaxLOD` requirement. - Open point: constant and `smpl` samplers in `gfx2hlsl.py` already refuse `MIN_LOD` above `MAX_LOD` (#2177), while sampler heap entries keep the pair unchanged. Whether heap entries should be refused as well is left open. AI-assisted.
Review of #2287: the docs line read as one entry with MIN_LOD 2 and
MAX_LOD 1. The two heap entries are MIN_LOD 2 with MAX_LOD 4095/256 and
MIN_LOD 0 with MAX_LOD 1, both valid for D3D12_SAMPLER_DESC
(MaxLOD >= MinLOD). The draw now refuses a fixture entry whose decoded
MinLOD is above MaxLOD, and the docs name both pairs.

The device-free check keeps one MIN_LOD-above-MAX_LOD case, now separate
and named, because the decoder passes such title words through
unchanged: D3D12 documents MaxLOD >= MinLOD and no source here says what
the console sampler does with that pair. The fraction case uses a valid
pair. Also fixes the docs line wrap.

AI-assisted.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:13:40 +00:00
github manually merged commit 476e5bc44d into gh-pr/2298/base 2026-11-27 00:13:43 +00:00
Author
Owner

@⁠tedin7 on GitHub · 2026-11-25 10:54 UTC · original · reviewed

Review of head 476e5bc44d: 0 P1, 0 P2.

  • The LOD fixture words are now MinLOD <= MaxLOD (entry 0: MIN_LOD 2, MAX_LOD 4095/256; entry 1: MIN_LOD 0, MAX_LOD 1). The new guard in startup_sampler_lod.cpp throws if a decoded fixture entry breaks this.
  • The device-free decoder check keeps the inverted pair as an explicit "passed through unchanged" case, and the doc states the console behaviour is not established. The decoder is untouched, so the claim is accurate.
  • The "lod fractions" fixture is fixed to MIN 1.25 / MAX 1.75, which is a valid order and gives the same fraction coverage.
  • No other open PR covers this slice.

Commands executed locally:

  • python3 tests/docs_links_check.py: 18 files, 436 links OK.
  • python3 tests/bidi_controls_check.py: OK.
  • git diff --check origin/main...HEAD: clean.
  • Win2025 WARP, Debug and Release /O2: ctest -R '^startup_sampler_lod_|startup_translated_sampler_bindings' is 6/6 passed in both presets. This includes the _dropped_ and shared-axis controls.
  • Mutation: swapped the MIN_LOD field to read bits 23:12 in src/startup_stubs/translated_sampler_bindings.h, then ran startup_translated_sampler_bindings on Win2025. It FAILS on min lod 2, max lod 1, lod fractions and others. Reverted.
  • CI Build and test on Windows: SUCCESS.

AI-assisted; commands listed were executed locally.

**@⁠tedin7** on GitHub · 2026-11-25 10:54 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/2298#pullrequestreview-6056246145) · **reviewed** Review of head 476e5bc44ddd63dcd5875213ac8fc673153adb3a: 0 P1, 0 P2. - The LOD fixture words are now MinLOD <= MaxLOD (entry 0: MIN_LOD 2, MAX_LOD 4095/256; entry 1: MIN_LOD 0, MAX_LOD 1). The new guard in `startup_sampler_lod.cpp` throws if a decoded fixture entry breaks this. - The device-free decoder check keeps the inverted pair as an explicit "passed through unchanged" case, and the doc states the console behaviour is not established. The decoder is untouched, so the claim is accurate. - The "lod fractions" fixture is fixed to MIN 1.25 / MAX 1.75, which is a valid order and gives the same fraction coverage. - No other open PR covers this slice. Commands executed locally: - `python3 tests/docs_links_check.py`: 18 files, 436 links OK. - `python3 tests/bidi_controls_check.py`: OK. - `git diff --check origin/main...HEAD`: clean. - Win2025 WARP, Debug and Release /O2: `ctest -R '^startup_sampler_lod_|startup_translated_sampler_bindings'` is 6/6 passed in both presets. This includes the `_dropped_` and shared-axis controls. - Mutation: swapped the MIN_LOD field to read bits 23:12 in `src/startup_stubs/translated_sampler_bindings.h`, then ran `startup_translated_sampler_bindings` on Win2025. It FAILS on min lod 2, max lod 1, lod fractions and others. Reverted. - CI `Build and test on Windows`: SUCCESS. AI-assisted; commands listed were executed locally.
This discussion has been locked. Commenting is limited to contributors.
No description provided.