startup: check the translated sampler bindings #1473

Merged
Asimmimx merged 1 commit from upstream-pr/1480 into main 2026-11-24 13:07:54 +00:00
Asimmimx commented 2026-11-24 12:40:59 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Asimmimx on 2026-11-24T12:40:59Z.


Change

Refs #1149. This adds a device-free check for src/startup_stubs/translated_sampler_bindings.h, which the draw path in d3d12_draw.inl uses. The header does four things:

  • decodes 16-byte title sampler words into desktop samplers;
  • accepts or refuses smpheap manifest lines;
  • snapshots title sampler memory;
  • decides by snapshot equality whether a draw reuses its sampler table.

The tests that reach it are startup_sampler_heap_warp, _wrapped_warp, startup_image_3d_warp, startup_image_load_mip_warp, startup_image_2d_array_warp and startup_inline_sampler_warp. Their draws sample wrap, clamp and border samplers along U, on one-texel-high or point-sampled textures, and read one channel. No test sends an smpheap manifest through the device wrapper, so the snapshot comparison has no end-to-end coverage. 14 of 16 single-point mutants left all six tests passing (table below).

startup_translated_sampler_bindings includes only the header and checks hand-worked values. The D3D12 enum numbers are written out, and the GCN field positions are CLAMP_X/Y/Z at word 0 bits 0–8, MAX_ANISO_RATIO at 9–11, and the mag, min, Z and mip filters at word 2 bits 20–27. It covers:

  • each of the eight clamp modes on each axis, with distinct values per axis;
  • anisotropy ratios 0 to 7 and the 16x cap;
  • the filter fields and the bits the decoder must ignore;
  • border_sampler, sampler_root_parameter and the constants;
  • 17 accepted and refused manifest lines;
  • snapshot counts at the 2048 and 2047 entry limits, null and top-of-memory addresses, unaligned records across pages, and records up to a PAGE_NOACCESS page;
  • snapshot equality, one field at a time.

startup_translated_sampler_bindings_shared_axis_control runs with --mutate shared-axis, which expects V and W to repeat U, and must fail (WILL_FAIL).

The change is test, CMake and docs/startup-runtime.md only. The CMake block follows the startup_sampler_heap sources, apart from the other open #1149 PRs.

Verification

Commit 93672b99 (main) plus this change, dev preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818.

ctest --preset dev --no-tests=error -R '^startup_(translated_sampler_bindings(_shared_axis_control)?|(sampler_heap|sampler_heap_wrapped|image_3d|inline_sampler)_warp)$' -V
startup_translated_sampler_bindings ....................... Passed
startup_translated_sampler_bindings_shared_axis_control ... Passed   (32 of 56 cases fail, as the control intends)
startup_sampler_heap_warp / _wrapped_warp / startup_image_3d_warp / startup_inline_sampler_warp  Passed

The six existing WARP tests, startup_image_load_mip_warp and startup_image_2d_array_warp included, passed on the unmodified header. tests/docs_links_check.py, tests/bidi_controls_check.py and git diff --check passed.

Mutation probe

I applied each mutation to the header alone, rebuilt offscreen_check and d3d12_xs_shim, ran the tests, then reverted. None of this is committed. "Existing" means the six WARP tests above.

Mutant Existing New check
control: clamp mode 2 decoded as WRAP killed (sampler_heap, inline_sampler) fails
AddressV read from bit 4 instead of 3 survived fails
AddressW read from V's bits survived fails
MIRROR and MIRROR_ONCE swapped survived fails
min and mag filter bits swapped survived fails
point mip filter read as linear survived fails
16x anisotropy cap removed survived fails
static border colour set to opaque black survived fails
border_sampler with border on U only survived fails
fallback entry other than 2047 accepted survived fails
second smpheap line accepted survived fails
snapshot ignores the reserved entry (2048 instead of 2047) survived fails
snapshot equality ignores the words survived fails
snapshot equality ignores the readable bits survived fails
partially copied record not zeroed survived survived
invalid-token entry not reset to the fallback survived survived (needs a device)
unbound entries counted as out of range survived survived (needs a device)

Notes:

  • Partial copy. The check puts data in the readable half of a record that crosses into an inaccessible page. On this Windows build ReadProcessMemory copied nothing of that record, so the zeroing could not be observed.
  • Counters. The two counters in create_sampler_snapshot_heap need an ID3D12Device, and the shim only logs them. They are a possible follow-up.
  • Mode 7. MIRROR_ONCE_BORDER becomes BORDER, and the half-border modes keep their edge texel. The check pins the current mapping; it does not show the mapping is the right one.

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.
  • I did not include game files, dumps, distribution links or secrets.

AI-assisted (Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6582006510 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1480). Originally posted by [Asimmimx](https://github.com/Asimmimx) on 2026-11-24T12:40:59Z. --- ## Change Refs #1149. This adds a device-free check for `src/startup_stubs/translated_sampler_bindings.h`, which the draw path in `d3d12_draw.inl` uses. The header does four things: - decodes 16-byte title sampler words into desktop samplers; - accepts or refuses `smpheap` manifest lines; - snapshots title sampler memory; - decides by snapshot equality whether a draw reuses its sampler table. The tests that reach it are `startup_sampler_heap_warp`, `_wrapped_warp`, `startup_image_3d_warp`, `startup_image_load_mip_warp`, `startup_image_2d_array_warp` and `startup_inline_sampler_warp`. Their draws sample wrap, clamp and border samplers along U, on one-texel-high or point-sampled textures, and read one channel. No test sends an `smpheap` manifest through the device wrapper, so the snapshot comparison has no end-to-end coverage. 14 of 16 single-point mutants left all six tests passing (table below). `startup_translated_sampler_bindings` includes only the header and checks hand-worked values. The D3D12 enum numbers are written out, and the GCN field positions are `CLAMP_X/Y/Z` at word 0 bits 0–8, `MAX_ANISO_RATIO` at 9–11, and the mag, min, Z and mip filters at word 2 bits 20–27. It covers: - each of the eight clamp modes on each axis, with distinct values per axis; - anisotropy ratios 0 to 7 and the 16x cap; - the filter fields and the bits the decoder must ignore; - `border_sampler`, `sampler_root_parameter` and the constants; - 17 accepted and refused manifest lines; - snapshot counts at the 2048 and 2047 entry limits, null and top-of-memory addresses, unaligned records across pages, and records up to a `PAGE_NOACCESS` page; - snapshot equality, one field at a time. `startup_translated_sampler_bindings_shared_axis_control` runs with `--mutate shared-axis`, which expects V and W to repeat U, and must fail (`WILL_FAIL`). The change is test, CMake and `docs/startup-runtime.md` only. The CMake block follows the `startup_sampler_heap` sources, apart from the other open #1149 PRs. ## Verification Commit `93672b99` (`main`) plus this change, `dev` preset (Debug), Windows 11 Pro build 26300.9974, MSVC 19.51.36260, Windows SDK 10.0.26100.0, WARP 10.0.26100.9818. ```powershell ctest --preset dev --no-tests=error -R '^startup_(translated_sampler_bindings(_shared_axis_control)?|(sampler_heap|sampler_heap_wrapped|image_3d|inline_sampler)_warp)$' -V ``` ```text startup_translated_sampler_bindings ....................... Passed startup_translated_sampler_bindings_shared_axis_control ... Passed (32 of 56 cases fail, as the control intends) startup_sampler_heap_warp / _wrapped_warp / startup_image_3d_warp / startup_inline_sampler_warp Passed ``` The six existing WARP tests, `startup_image_load_mip_warp` and `startup_image_2d_array_warp` included, passed on the unmodified header. `tests/docs_links_check.py`, `tests/bidi_controls_check.py` and `git diff --check` passed. ## Mutation probe I applied each mutation to the header alone, rebuilt `offscreen_check` and `d3d12_xs_shim`, ran the tests, then reverted. None of this is committed. "Existing" means the six WARP tests above. | Mutant | Existing | New check | |---|---|---| | control: clamp mode 2 decoded as WRAP | killed (sampler_heap, inline_sampler) | fails | | AddressV read from bit 4 instead of 3 | survived | fails | | AddressW read from V's bits | survived | fails | | MIRROR and MIRROR_ONCE swapped | survived | fails | | min and mag filter bits swapped | survived | fails | | point mip filter read as linear | survived | fails | | 16x anisotropy cap removed | survived | fails | | static border colour set to opaque black | survived | fails | | `border_sampler` with border on U only | survived | fails | | `fallback` entry other than 2047 accepted | survived | fails | | second `smpheap` line accepted | survived | fails | | snapshot ignores the reserved entry (2048 instead of 2047) | survived | fails | | snapshot equality ignores the words | survived | fails | | snapshot equality ignores the readable bits | survived | fails | | partially copied record not zeroed | survived | survived | | invalid-token entry not reset to the fallback | survived | survived (needs a device) | | unbound entries counted as out of range | survived | survived (needs a device) | Notes: - **Partial copy.** The check puts data in the readable half of a record that crosses into an inaccessible page. On this Windows build `ReadProcessMemory` copied nothing of that record, so the zeroing could not be observed. - **Counters.** The two counters in `create_sampler_snapshot_heap` need an `ID3D12Device`, and the shim only logs them. They are a possible follow-up. - **Mode 7.** MIRROR_ONCE_BORDER becomes BORDER, and the half-border modes keep their edge texel. The check pins the current mapping; it does not show the mapping is the right one. ## 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. - [x] I did not include game files, dumps, distribution links or secrets. AI-assisted (Claude Code).
upstream-sync closed this pull request 2026-11-24 14:02:50 +00:00
ChazY11 commented 2026-11-24 14:03:23 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T13:06:09Z.


Two of your sixteen mutants reproduced — both invisible to the six GPU tests

Independent reviewer, not the author. Reviewed d043bd91; nothing pushed to the branch. Mutations were made locally in
src/startup_stubs/translated_sampler_bindings.h, rebuilt, reverted; working tree is clean.

Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11.

cmake --preset dev
cmake --build --preset dev --target startup_translated_sampler_bindings_check
ctest --preset dev --no-tests=error -R '^(startup_translated_sampler_bindings|startup_sampler_heap_(warp|wrapped_warp)|startup_inline_sampler_warp|startup_image_load_mip_warp)$'

Unmodified branch — startup_translated_sampler_bindings and the four GPU sampler tests all pass.

Mutant A — snapshot equality stops comparing the words

-    return reserved_fallback == other.reserved_fallback && count == other.count &&
-           readable == other.readable && words == other.words;
+    return reserved_fallback == other.reserved_fallback && count == other.count &&
+           readable == other.readable;
startup_translated_sampler_bindings ... ***Failed   "1 FAILED in 57 cases"
startup_sampler_heap_warp ............. Passed
startup_inline_sampler_warp ........... Passed

Mutant B — mip filter decoded as linear for every value

-        : D3D12_ENCODE_BASIC_FILTER(min & 1, mag & 1, mip == 2 ? 1 : 0, ...);
+        : D3D12_ENCODE_BASIC_FILTER(min & 1, mag & 1, 1, ...);
startup_translated_sampler_bindings ... ***Failed   "43 FAILED in 57 cases"
startup_sampler_heap_warp ............. Passed
startup_sampler_heap_wrapped_warp ..... Passed
startup_image_load_mip_warp ........... Passed
startup_inline_sampler_warp ........... Passed

Both mutants leave every GPU test green and only the new device-free check notices. That is the same shape you describe
for 14 of the 16 mutants, and it is the property that makes the check worth having in CI where no adapter exists.

I sampled two of the sixteen rather than all of them; if you want the full set confirmed, say so and I will run the rest.

One thing I want to keep

The N FAILED in M cases summary is exactly the right level of detail: mutant A says 1 of 57, mutant B says 43 of 57, so
the size of the breakage is visible without opening the source. Please keep that line if the case list changes.

Verdict

Reviewed d043bd91. Device-free, two new CMake lines and one test file, no change to the header it checks, and the
mutants it is meant to catch are caught. No objection from me.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7132350831 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1480#issuecomment-7132350831). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T13:06:09Z. --- ## Two of your sixteen mutants reproduced — both invisible to the six GPU tests Independent reviewer, not the author. Reviewed `d043bd91`; nothing pushed to the branch. Mutations were made locally in `src/startup_stubs/translated_sampler_bindings.h`, rebuilt, reverted; working tree is clean. Environment: Windows 11 build 26300.9974, MSVC 14.44.35207, SDK 10.0.26100, DXC 1.8.2502.11. ```powershell cmake --preset dev cmake --build --preset dev --target startup_translated_sampler_bindings_check ctest --preset dev --no-tests=error -R '^(startup_translated_sampler_bindings|startup_sampler_heap_(warp|wrapped_warp)|startup_inline_sampler_warp|startup_image_load_mip_warp)$' ``` Unmodified branch — `startup_translated_sampler_bindings` and the four GPU sampler tests all pass. ### Mutant A — snapshot equality stops comparing the words ```diff - return reserved_fallback == other.reserved_fallback && count == other.count && - readable == other.readable && words == other.words; + return reserved_fallback == other.reserved_fallback && count == other.count && + readable == other.readable; ``` ```text startup_translated_sampler_bindings ... ***Failed "1 FAILED in 57 cases" startup_sampler_heap_warp ............. Passed startup_inline_sampler_warp ........... Passed ``` ### Mutant B — mip filter decoded as linear for every value ```diff - : D3D12_ENCODE_BASIC_FILTER(min & 1, mag & 1, mip == 2 ? 1 : 0, ...); + : D3D12_ENCODE_BASIC_FILTER(min & 1, mag & 1, 1, ...); ``` ```text startup_translated_sampler_bindings ... ***Failed "43 FAILED in 57 cases" startup_sampler_heap_warp ............. Passed startup_sampler_heap_wrapped_warp ..... Passed startup_image_load_mip_warp ........... Passed startup_inline_sampler_warp ........... Passed ``` Both mutants leave every GPU test green and only the new device-free check notices. That is the same shape you describe for 14 of the 16 mutants, and it is the property that makes the check worth having in CI where no adapter exists. I sampled two of the sixteen rather than all of them; if you want the full set confirmed, say so and I will run the rest. ### One thing I want to keep The `N FAILED in M cases` summary is exactly the right level of detail: mutant A says 1 of 57, mutant B says 43 of 57, so the size of the breakage is visible without opening the source. Please keep that line if the case list changes. ### Verdict Reviewed `d043bd91`. Device-free, two new CMake lines and one test file, no change to the header it checks, and the mutants it is meant to catch are caught. No objection from me.
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!1473
No description provided.