startup: apply sampler heap entries' MIN_LOD and MAX_LOD #2279

Merged
roansystemlabs merged 1 commit from upstream-pr/2287 into main 2026-11-25 10:20:35 +00:00
roansystemlabs commented 2026-11-25 10:09:25 +00:00 (Migrated from github.com)

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


Fixes #2221.

Change

Item 1 of #2221, the runtime decoder side. dynamic_sampler() in src/startup_stubs/translated_sampler_bindings.h builds the stand-in's sampler table from the title's own heap words. Until now it set MinLOD = 0 and an unbounded MaxLOD, so a heap entry's LOD clamp was dropped. It now passes lod_limits = true to decode_sampler(), reusing the LOD lines that #2051 added for smpl manifest lines. No new decoding is introduced.

  • Format: MIN_LOD is sampler word 1 bits 11:0 and MAX_LOD is bits 23:12. Both are unsigned 4.8, so each field is divided by 256.
    • Source: AMD "RDNA 2" Instruction Set Architecture, section 8.2.7, table 46 "Image Sampler Definition": min lod at descriptor bits 43:32, described as u4.8 in resource view space, and max lod at 55:44.
    • The same layout is in Mesa src/amd/registers/gfx10-rsrc.json (SQ_IMG_SAMP_WORD1: MIN_LOD [0, 11], MAX_LOD [12, 23], PERF_MIP [24, 27], PERF_Z [28, 31]).
    • RADV radv_sampler.c encodes both fields with radv_float_to_ufixed(x, 8).
  • Static samplers are unchanged. The translator chooses between an smp line (MinLOD = 0, unbounded MaxLOD) and an smpl line (limits carried): #2051 for image_sample_b, #2265 for constant samplers of image_sample, _l and _lz.
  • Default-sampler shortcut: a run-time heap load without a bound table still becomes an all-zero static smp sampler, as before. It has no title words to decode.
  • The border fallback is unchanged. border_sampler() also goes through dynamic_sampler(), but it is not a title descriptor: its word 1 is 0 by construction, not a clamp. It therefore keeps the full mip range, as on main. It is used for missing, out-of-range, unreadable or invalid entries and for the reserved entry 2047.
  • Comments: the comment above decode_sampler() now says that dynamic_sampler() always sets the flag. The comment in tests/mesh_heap_sampler_draw.cpp (#2220) no longer says that the decoder ignores the fields; its local decode is kept.

#2221 is closed by three changes:

  • item 2 (ComparisonFunc, warning 1361) landed in #2228;
  • the constant-sampler side of item 1 landed in #2265 (#2177);
  • this PR covers the remaining heap entries.

Since #2265, the translator logs once per module that a heap sampler's MIN_LOD, MAX_LOD and LOD bias are not validated (#2221). That line stays accurate after this change, which is why it is untouched here:

  • the limits are now applied at run time, but not validated;
  • a heap entry's LOD bias is still not carried (MipLODBias stays 0).

If you prefer the line to point elsewhere once #2221 is closed, that is a one-line translator follow-up.

Verification

Commit db3c8255, on 77a204d6. Windows 11 build 26200, MSVC 14.44, dev preset (Debug), D3D12 debug layer enabled. Adapters: NVIDIA GeForce RTX 3070 (10de:2484, driver 32.0.16.2101) and WARP 10.0.26100.9818.

New startup_sampler_lod_{warp,hardware} (offscreen_check <adapter> --startup-sampler-lod). The test uses the production code path end to end:

  • the manifest lines smpheap 2048 1 fallback 2047 and smpc 0 0x1012 0x100000 0x0 0x0 go through TranslatedSamplers::read_manifest_line();
  • create_translated_root() builds the root signature;
  • two 16-byte heap records pass through snapshot_samplers(), create_sampler_snapshot_heap() and dynamic_sampler().

The two heap entries differ only in word 1:

  • entry 0 has MIN_LOD 2 (0x00fff200);
  • entry 1 has MAX_LOD 1 (0x00100000).

Words 0, 2 and 3 are the same: clamp-to-last-texel in X and Y, point filters. A source-built pixel shader (tests/startup_sampler_lod.hlsl, compiled with DXC vs_6_0/ps_6_0 at build time) reads an 8×8 R32_FLOAT texture with four mips, where every texel of mip m holds 0.125 + 0.25·m. Each draw writes one pixel, using SampleLevel at an explicit LOD:

Probe Sampler LOD / reference Expected Read (WARP and RTX 3070) _dropped_ control
0 entry 0 (MIN_LOD 2) LOD 0 mip 2 0.625 (mip 2) 0.125 (mip 0)
1 entry 0 LOD 3 mip 3 0.875 (mip 3) 0.875
2 entry 1 (MAX_LOD 1) LOD 3 mip 1 0.375 (mip 1) 0.875 (mip 3)
3 entry 1 LOD 0 mip 0 0.125 (mip 0) 0.125
4 static smpc (LESS) reference 0.0625 1 1 1
5 static smpc (LESS) reference 0.25 0 0 0
  • Dropped clamp control: startup_sampler_lod_dropped_{warp,hardware} decode the same words, then reset MinLOD/MaxLOD to 0 and D3D12_FLOAT32_MAX, the values heap entries had before this change. The control must then read mip 0 for probe 0 and mip 3 for probe 2. It passes only on the exact line wrong_mip=2 unexpected=0, and it passed on both adapters.
  • Comparison sampler: the decoded static smpc sampler keeps ComparisonFunc = LESS (Filter = 0x80). This is checked on the CPU, and on the GPU by probes 4 and 5: ALWAYS would read 1 for both and NEVER would read 0 for both.
  • Fail-first: on 3089406b, with the new tests and main's header:
    • startup_sampler_lod_{warp,hardware} failed with mismatches=2 (probe 0 read mip 0, probe 2 read mip 3);
    • startup_translated_sampler_bindings failed on every table-entry LOD range;
    • the dropped controls passed.
  • Warning 1361: counted before and after with the same draw.
    • On f277710e, before #2228, every startup_sampler_lod_* run reported debug_warnings=1024, all of them 1361 (1024 is where the debug layer's stored-message count stops), with and without this change.
    • On main after #2228 the count is debug_errors=0 debug_warnings=0, with and without this change.
    • The fix for 1361 is #2228's; this change neither adds nor removes it.
  • Device-free check: startup_translated_sampler_bindings now expects the decoded range for table entries and for the smpl path, an unbounded range for smp statics, and an unbounded range for the border fallback. The new cases are:
    • a whole level;
    • a fraction (1.75 / 1.25, which also passes MIN_LOD above MAX_LOD through);
    • the smallest step (1/256);
    • the largest value (4095/256);
    • PERF_MIP/PERF_Z set, which is ignored.
cmake --preset dev
cmake --build --preset dev
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 3 runs; debug_errors=0 debug_warnings=0 in every startup_sampler_lod and startup_sampler_heap draw
ctest --preset dev --no-tests=error -R "^(startup_sampler|startup_translated_sampler|startup_image_|mesh_|compute_mesh_texture_|offscreen_)"
# 112 tests: 110 passed, 2 skipped (mesh_two_exits_{warp,hardware}: "requires LLVM 15 with AMDGPU"), 0 failed.
# Includes mesh_heap_sampler_* (#2220, through dynamic_sampler()) and startup_image_sample_lod_* (#2265).

Not run:

  • a heap entry with MIN_LOD above MAX_LOD on a device (it is passed through as decoded and checked only without a device);
  • the release preset;
  • the GitHub Actions jobs;
  • the R32_FLOAT capability skip path, which never triggers here because both adapters report the capabilities.

The test does not depend on the debug layer: it reports warnings but does not require any.

Evidence and follow-up

The test generates its own fixture: the sampler words and texel values are written in tests/startup_sampler_lod.cpp, and the shader is in tests/startup_sampler_lod.hlsl. Both are under the repository license. The draw uses whole-level LODs, so it does not depend on how point mip filtering rounds a fractional LOD; the device-free check covers the fractional values.

tests/mesh_heap_sampler_draw.cpp (#2220) still applies MinLOD/MaxLOD itself after dynamic_sampler(). It now sets the same values, so that local decode could be dropped in a follow-up if wanted.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for every check I ran.
  • I considered a negative control or failure case for a new fixture.
  • I updated README/docs when a capability or build requirement changed (docs/startup-runtime.md).
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6602055654 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2287). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T10:09:25Z. --- Fixes #2221. ## Change Item 1 of #2221, the runtime decoder side. `dynamic_sampler()` in `src/startup_stubs/translated_sampler_bindings.h` builds the stand-in's sampler table from the title's own heap words. Until now it set `MinLOD = 0` and an unbounded `MaxLOD`, so a heap entry's LOD clamp was dropped. It now passes `lod_limits = true` to `decode_sampler()`, reusing the LOD lines that #2051 added for `smpl` manifest lines. No new decoding is introduced. - **Format:** `MIN_LOD` is sampler word 1 bits 11:0 and `MAX_LOD` is bits 23:12. Both are unsigned 4.8, so each field is divided by 256. - Source: AMD "RDNA 2" Instruction Set Architecture, section 8.2.7, table 46 "Image Sampler Definition": `min lod` at descriptor bits 43:32, described as u4.8 in resource view space, and `max lod` at 55:44. - The same layout is in Mesa [`src/amd/registers/gfx10-rsrc.json`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-23.3.6/src/amd/registers/gfx10-rsrc.json) (`SQ_IMG_SAMP_WORD1`: `MIN_LOD` [0, 11], `MAX_LOD` [12, 23], `PERF_MIP` [24, 27], `PERF_Z` [28, 31]). - RADV [`radv_sampler.c`](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-23.3.6/src/amd/vulkan/radv_sampler.c) encodes both fields with `radv_float_to_ufixed(x, 8)`. - **Static samplers are unchanged.** The translator chooses between an `smp` line (`MinLOD = 0`, unbounded `MaxLOD`) and an `smpl` line (limits carried): #2051 for `image_sample_b`, #2265 for constant samplers of `image_sample`, `_l` and `_lz`. - **Default-sampler shortcut:** a run-time heap load without a bound table still becomes an all-zero static `smp` sampler, as before. It has no title words to decode. - **The border fallback is unchanged.** `border_sampler()` also goes through `dynamic_sampler()`, but it is not a title descriptor: its word 1 is 0 by construction, not a clamp. It therefore keeps the full mip range, as on `main`. It is used for missing, out-of-range, unreadable or invalid entries and for the reserved entry 2047. - **Comments:** the comment above `decode_sampler()` now says that `dynamic_sampler()` always sets the flag. The comment in `tests/mesh_heap_sampler_draw.cpp` (#2220) no longer says that the decoder ignores the fields; its local decode is kept. #2221 is closed by three changes: - item 2 (`ComparisonFunc`, warning 1361) landed in #2228; - the constant-sampler side of item 1 landed in #2265 (#2177); - this PR covers the remaining heap entries. Since #2265, the translator logs once per module that a heap sampler's `MIN_LOD`, `MAX_LOD` and LOD bias are not validated (#2221). That line stays accurate after this change, which is why it is untouched here: - the limits are now applied at run time, but not validated; - a heap entry's LOD bias is still not carried (`MipLODBias` stays 0). If you prefer the line to point elsewhere once #2221 is closed, that is a one-line translator follow-up. ## Verification Commit `db3c8255`, on `77a204d6`. Windows 11 build 26200, MSVC 14.44, `dev` preset (Debug), D3D12 debug layer enabled. Adapters: NVIDIA GeForce RTX 3070 (`10de:2484`, driver 32.0.16.2101) and WARP 10.0.26100.9818. New `startup_sampler_lod_{warp,hardware}` (`offscreen_check <adapter> --startup-sampler-lod`). The test uses the production code path end to end: - the manifest lines `smpheap 2048 1 fallback 2047` and `smpc 0 0x1012 0x100000 0x0 0x0` go through `TranslatedSamplers::read_manifest_line()`; - `create_translated_root()` builds the root signature; - two 16-byte heap records pass through `snapshot_samplers()`, `create_sampler_snapshot_heap()` and `dynamic_sampler()`. The two heap entries differ only in word 1: - entry 0 has `MIN_LOD` 2 (`0x00fff200`); - entry 1 has `MAX_LOD` 1 (`0x00100000`). Words 0, 2 and 3 are the same: clamp-to-last-texel in X and Y, point filters. A source-built pixel shader (`tests/startup_sampler_lod.hlsl`, compiled with DXC `vs_6_0`/`ps_6_0` at build time) reads an 8×8 `R32_FLOAT` texture with four mips, where every texel of mip m holds `0.125 + 0.25·m`. Each draw writes one pixel, using `SampleLevel` at an explicit LOD: | Probe | Sampler | LOD / reference | Expected | Read (WARP and RTX 3070) | `_dropped_` control | |---|---|---|---|---|---| | 0 | entry 0 (`MIN_LOD` 2) | LOD 0 | mip 2 | 0.625 (mip 2) | 0.125 (mip 0) | | 1 | entry 0 | LOD 3 | mip 3 | 0.875 (mip 3) | 0.875 | | 2 | entry 1 (`MAX_LOD` 1) | LOD 3 | mip 1 | 0.375 (mip 1) | 0.875 (mip 3) | | 3 | entry 1 | LOD 0 | mip 0 | 0.125 (mip 0) | 0.125 | | 4 | static `smpc` (`LESS`) | reference 0.0625 | 1 | 1 | 1 | | 5 | static `smpc` (`LESS`) | reference 0.25 | 0 | 0 | 0 | - **Dropped clamp control:** `startup_sampler_lod_dropped_{warp,hardware}` decode the same words, then reset `MinLOD`/`MaxLOD` to 0 and `D3D12_FLOAT32_MAX`, the values heap entries had before this change. The control must then read mip 0 for probe 0 and mip 3 for probe 2. It passes only on the exact line `wrong_mip=2 unexpected=0`, and it passed on both adapters. - **Comparison sampler:** the decoded static `smpc` sampler keeps `ComparisonFunc = LESS` (`Filter = 0x80`). This is checked on the CPU, and on the GPU by probes 4 and 5: `ALWAYS` would read 1 for both and `NEVER` would read 0 for both. - **Fail-first:** on `3089406b`, with the new tests and `main`'s header: - `startup_sampler_lod_{warp,hardware}` failed with `mismatches=2` (probe 0 read mip 0, probe 2 read mip 3); - `startup_translated_sampler_bindings` failed on every table-entry LOD range; - the dropped controls passed. - **Warning 1361:** counted before and after with the same draw. - On `f277710e`, before #2228, every `startup_sampler_lod_*` run reported `debug_warnings=1024`, all of them 1361 (1024 is where the debug layer's stored-message count stops), with and without this change. - On `main` after #2228 the count is `debug_errors=0 debug_warnings=0`, with and without this change. - The fix for 1361 is #2228's; this change neither adds nor removes it. - **Device-free check:** `startup_translated_sampler_bindings` now expects the decoded range for table entries and for the `smpl` path, an unbounded range for `smp` statics, and an unbounded range for the border fallback. The new cases are: - a whole level; - a fraction (1.75 / 1.25, which also passes `MIN_LOD` above `MAX_LOD` through); - the smallest step (1/256); - the largest value (4095/256); - `PERF_MIP`/`PERF_Z` set, which is ignored. ```powershell cmake --preset dev cmake --build --preset dev 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 3 runs; debug_errors=0 debug_warnings=0 in every startup_sampler_lod and startup_sampler_heap draw ctest --preset dev --no-tests=error -R "^(startup_sampler|startup_translated_sampler|startup_image_|mesh_|compute_mesh_texture_|offscreen_)" # 112 tests: 110 passed, 2 skipped (mesh_two_exits_{warp,hardware}: "requires LLVM 15 with AMDGPU"), 0 failed. # Includes mesh_heap_sampler_* (#2220, through dynamic_sampler()) and startup_image_sample_lod_* (#2265). ``` Not run: - a heap entry with `MIN_LOD` above `MAX_LOD` on a device (it is passed through as decoded and checked only without a device); - the `release` preset; - the GitHub Actions jobs; - the `R32_FLOAT` capability skip path, which never triggers here because both adapters report the capabilities. The test does not depend on the debug layer: it reports warnings but does not require any. ## Evidence and follow-up The test generates its own fixture: the sampler words and texel values are written in `tests/startup_sampler_lod.cpp`, and the shader is in `tests/startup_sampler_lod.hlsl`. Both are under the repository license. The draw uses whole-level LODs, so it does not depend on how point mip filtering rounds a fractional LOD; the device-free check covers the fractional values. `tests/mesh_heap_sampler_draw.cpp` (#2220) still applies `MinLOD`/`MaxLOD` itself after `dynamic_sampler()`. It now sets the same values, so that local decode could be dropped in a follow-up if wanted. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for every check I ran. - [x] I considered a negative control or failure case for a new fixture. - [x] I updated README/docs when a capability or build requirement changed (`docs/startup-runtime.md`). - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted.
upstream-sync closed this pull request 2026-11-25 11:02:20 +00:00
tedin7 commented 2026-11-25 11:02:20 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Review of head db3c825565b4b27abd7cd3301d92ce1a92e3cad1 (comment only).

Scope / overlap. #2265 (static sampler lod_limits for smpl, image_sample_b, constant-sampler image_sample/_l/_lz) is already in origin/main. This PR does not redo it. It reuses the decode_sampler(..., lod_limits=true) path from #2265 and turns it on for sampler-heap entries (dynamic_sampler, src/startup_stubs/translated_sampler_bindings.h:185-190). No overlap in files or logic beyond that shared call. Titles and bodies are neutral and clean-room (the Mesa gfx10 register layout is cited in the existing comment).

Logic.

  • MIN_LOD = word1[11:0], MAX_LOD = word1[23:12], unsigned 4.8 fixed point, so /256. Matches the decoder from #2265.
  • border_sampler() resets MaxLOD to D3D12_FLOAT32_MAX (translated_sampler_bindings.h:193-199). This is needed because the synthetic fallback has word1 = 0, which would otherwise clamp it to mip 0. The reserved fallback in tests/startup_sampler_heap.cpp:74 copies border_sampler(), so it keeps the full range. Good.
  • Behavior change to be aware of: a title heap entry with word1 = 0 now samples mip 0 only (before: unbounded). This is the intended hardware semantics and is documented in docs/startup-runtime.md, but it will change any title that leaves word1 at 0 on a mipped texture.

Findings.

  • P2: CMakeLists.txt / tests/startup_sampler_lod.cpp: the fixture uses entries with MIN_LOD 2 and MAX_LOD 1 (MinLOD > MaxLOD). D3D12 documents MinLOD <= MaxLOD for D3D12_SAMPLER_DESC, and the debug layer reports a violation. WARP accepts it, but a hardware adapter may not behave the same. The _hardware variant of the test therefore does not prove the same thing as _warp. Consider clamping MinLOD = min(MinLOD, MaxLOD) in the decoder (and testing it), or use a valid pair for the hardware-run assertions. If the inverted pair is a deliberate hardware-semantics probe, say so in the doc line.
  • Nit: docs/startup-runtime.md line wraps oddly ("...at explicit LODs; a / static smpc sampler..."). Cosmetic.

Checks run locally (Linux).

  • git diff --stat origin/main...HEAD: 9 files, +340/-9.
  • python3 tests/docs_links_check.py -> pass (18 files, 435 links).
  • python3 tests/bidi_controls_check.py -> pass (1568 files).
  • git diff --check origin/main...HEAD -> clean.
  • Mutation: changed decode_sampler(words, 0, false, true) to false in dynamic_sampler. No Linux check fails, because all touched tests (startup_sampler_lod_*, startup_translated_sampler_bindings_check, mesh_heap_sampler_draw) are D3D12/Windows only. So the kill of this mutation depends on the Windows jobs (the _dropped_ control and the WARP readback). Reverted with git checkout -- ..
  • I did not run the Windows WARP pass locally. At review time the Windows CI job was still pending (Linux Python job green, mergeable). Please confirm startup_sampler_lod_{warp,hardware} and startup_translated_sampler_bindings* are green there before Ready.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6055595524 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2287#pullrequestreview-6055595524). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:11:02Z. **Review:** COMMENTED --- Review of head `db3c825565b4b27abd7cd3301d92ce1a92e3cad1` (comment only). **Scope / overlap.** #2265 (static sampler `lod_limits` for `smpl`, `image_sample_b`, constant-sampler `image_sample/_l/_lz`) is already in `origin/main`. This PR does not redo it. It reuses the `decode_sampler(..., lod_limits=true)` path from #2265 and turns it on for sampler-heap entries (`dynamic_sampler`, `src/startup_stubs/translated_sampler_bindings.h:185-190`). No overlap in files or logic beyond that shared call. Titles and bodies are neutral and clean-room (the Mesa gfx10 register layout is cited in the existing comment). **Logic.** - `MIN_LOD` = word1[11:0], `MAX_LOD` = word1[23:12], unsigned 4.8 fixed point, so `/256`. Matches the decoder from #2265. - `border_sampler()` resets `MaxLOD` to `D3D12_FLOAT32_MAX` (`translated_sampler_bindings.h:193-199`). This is needed because the synthetic fallback has word1 = 0, which would otherwise clamp it to mip 0. The reserved fallback in `tests/startup_sampler_heap.cpp:74` copies `border_sampler()`, so it keeps the full range. Good. - Behavior change to be aware of: a title heap entry with word1 = 0 now samples mip 0 only (before: unbounded). This is the intended hardware semantics and is documented in `docs/startup-runtime.md`, but it will change any title that leaves word1 at 0 on a mipped texture. **Findings.** - P2: `CMakeLists.txt` / `tests/startup_sampler_lod.cpp`: the fixture uses entries with `MIN_LOD` 2 and `MAX_LOD` 1 (MinLOD > MaxLOD). D3D12 documents `MinLOD <= MaxLOD` for `D3D12_SAMPLER_DESC`, and the debug layer reports a violation. WARP accepts it, but a hardware adapter may not behave the same. The `_hardware` variant of the test therefore does not prove the same thing as `_warp`. Consider clamping `MinLOD = min(MinLOD, MaxLOD)` in the decoder (and testing it), or use a valid pair for the hardware-run assertions. If the inverted pair is a deliberate hardware-semantics probe, say so in the doc line. - Nit: `docs/startup-runtime.md` line wraps oddly ("...at explicit LODs; a / static `smpc` sampler..."). Cosmetic. **Checks run locally (Linux).** - `git diff --stat origin/main...HEAD`: 9 files, +340/-9. - `python3 tests/docs_links_check.py` -> pass (18 files, 435 links). - `python3 tests/bidi_controls_check.py` -> pass (1568 files). - `git diff --check origin/main...HEAD` -> clean. - Mutation: changed `decode_sampler(words, 0, false, true)` to `false` in `dynamic_sampler`. No Linux check fails, because all touched tests (`startup_sampler_lod_*`, `startup_translated_sampler_bindings_check`, `mesh_heap_sampler_draw`) are D3D12/Windows only. So the kill of this mutation depends on the Windows jobs (the `_dropped_` control and the WARP readback). Reverted with `git checkout -- .`. - I did not run the Windows WARP pass locally. At review time the Windows CI job was still pending (Linux Python job green, mergeable). Please confirm `startup_sampler_lod_{warp,hardware}` and `startup_translated_sampler_bindings*` are green there before Ready. AI-assisted; commands listed were executed locally.
roansystemlabs commented 2026-11-25 11:02:32 +00:00 (Migrated from github.com)

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


Thanks for the careful review, @tedin7. The doc line was ambiguous, and that is on us: "(MIN_LOD 2, MAX_LOD 1)" named one field from each of two entries. The draw uses MIN_LOD 2 with MAX_LOD 4095/256, and MIN_LOD 0 with MAX_LOD 1. So no MinLOD > MaxLOD sampler reached D3D12 in _warp or _hardware. The only inverted pair (1.75/1.25) was a device-free decode case.

Agreed that D3D12 requires MinLOD <= MaxLOD. For the record, I wrote a standalone probe on WARP and an RTX 3070. Creating a heap sampler and a static sampler with (1.75, 1.25) logged no debug-layer message, while MaxAnisotropy 17 in the same probe was reported. That covers creation only, not a draw. I did not add a clamp in the decoder: the RDNA 2 ISA (§8.2.7, table 46) defines the fields but not what the sampler does with min > max, so a clamp would pick a behaviour we have no source for.

Since #2287 was already merged, the changes are in #2298:

  • the draw now refuses a fixture entry whose decoded MinLOD is above MaxLOD;
  • the doc line names both pairs, says an inverted pair is passed through unchanged, and has the wrap fixed;
  • the device-free inverted case is now separate and named, and the fraction case uses a valid pair.

On that head, the sampler LOD tests pass on WARP and the RTX 3070 with debug_errors=0 debug_warnings=0 in every draw. The full commands are in #2298.

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160122441 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2287#issuecomment-7160122441). Originally posted by [roansystemlabs](https://github.com/roansystemlabs) on 2026-11-25T10:45:05Z. --- Thanks for the careful review, @tedin7. The doc line was ambiguous, and that is on us: "(`MIN_LOD` 2, `MAX_LOD` 1)" named one field from each of two entries. The draw uses `MIN_LOD` 2 with `MAX_LOD` 4095/256, and `MIN_LOD` 0 with `MAX_LOD` 1. So no `MinLOD > MaxLOD` sampler reached D3D12 in `_warp` or `_hardware`. The only inverted pair (1.75/1.25) was a device-free decode case. Agreed that D3D12 requires `MinLOD <= MaxLOD`. For the record, I wrote a standalone probe on WARP and an RTX 3070. Creating a heap sampler and a static sampler with (1.75, 1.25) logged no debug-layer message, while `MaxAnisotropy` 17 in the same probe was reported. That covers creation only, not a draw. I did not add a clamp in the decoder: the RDNA 2 ISA (§8.2.7, table 46) defines the fields but not what the sampler does with min > max, so a clamp would pick a behaviour we have no source for. Since #2287 was already merged, the changes are in #2298: - the draw now refuses a fixture entry whose decoded `MinLOD` is above `MaxLOD`; - the doc line names both pairs, says an inverted pair is passed through unchanged, and has the wrap fixed; - the device-free inverted case is now separate and named, and the fraction case uses a valid pair. On that head, the sampler LOD tests pass on WARP and the RTX 3070 with `debug_errors=0 debug_warnings=0` in every draw. The full commands are in #2298. AI-assisted.
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!2279
No description provided.