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

Merged
roansystemlabs merged 1 commit from upstream-pr/2298 into main 2026-11-25 11:00:19 +00:00
roansystemlabs commented 2026-11-25 10:45:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by roansystemlabs on 2026-11-25T10:45:01Z.


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6602680159 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2298). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T10:45:01Z. --- 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.
upstream-sync closed this pull request 2026-11-25 11:02:26 +00:00
tedin7 commented 2026-11-25 11:02:26 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:54:14Z.

Review: COMMENTED


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.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6056246145 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2298#pullrequestreview-6056246145). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:54:14Z. **Review:** COMMENTED --- 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.
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!2290
No description provided.