test: allow one 8-bit filter weight step in the linear sampler probes #2786

Merged
tedin7 merged 1 commit from upstream-pr/2794 into main 2026-11-27 18:42:16 +00:00
tedin7 commented 2026-11-26 09:56:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T09:56:33Z.


Part of #1723

What this unblocks: startup_sampler_x_hardware and startup_sampler_x_swapped_hardware stop failing on GPUs whose texture sampler quantises the LOD weight to a different, spec-legal step (reported on a GeForce GTX 1080 Ti in #2781).

What changed

tests/startup_sampler_x.cpp compared linear-filter probes with a fixed 0.01 tolerance. On the GTX 1080 Ti, table 2 probe 3 (u = v = 0.0625, LOD 0.5) read 34.25 where the reference is exactly 34. The two mips differ by 64 there, so 34.25 is a mip weight of 129/256 instead of 128/256: one 1/256 step.

The linear tolerance is now 0.01 + (1/256) * (2 * texel range of both 2x2 footprints + gap between the two bilinear results). Point sampling stays exact. The probe coverage check (probes must separate every address mode, LOD limit, sampler and the point filter) is unchanged.

Why this is correct

Source: Microsoft DirectX-Specs, D3D11.3 functional spec, "Texture Filtering" (bilinear weights and mip weight need at least 8 fractional bits, so a one-step difference is legal). A wrong filter, wrong LOD clamp or a swapped table still moves the probes by far more than one step.

Verification

  • x86_64-w64-mingw32-g++ -std=c++20 -fsyntax-only tests/startup_sampler_x.cpp (with the generated shader header stubbed): no errors.
  • Unchanged-behaviour check on an RTX 3090 (vkd3d-proton, Linux), startup_sampler_x_hardware, _warp and startup_sampler_x_swapped_hardware pass with the old tolerance on that GPU; the new tolerance only widens it.
  • Win2025 WARP dev+release: pending Stage-2.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5507829845 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2794). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T09:56:33Z. --- Part of #1723 What this unblocks: `startup_sampler_x_hardware` and `startup_sampler_x_swapped_hardware` stop failing on GPUs whose texture sampler quantises the LOD weight to a different, spec-legal step (reported on a GeForce GTX 1080 Ti in #2781). ## What changed `tests/startup_sampler_x.cpp` compared linear-filter probes with a fixed 0.01 tolerance. On the GTX 1080 Ti, table 2 probe 3 (u = v = 0.0625, LOD 0.5) read 34.25 where the reference is exactly 34. The two mips differ by 64 there, so 34.25 is a mip weight of 129/256 instead of 128/256: one 1/256 step. The linear tolerance is now `0.01 + (1/256) * (2 * texel range of both 2x2 footprints + gap between the two bilinear results)`. Point sampling stays exact. The probe coverage check (probes must separate every address mode, LOD limit, sampler and the point filter) is unchanged. ## Why this is correct Source: Microsoft DirectX-Specs, D3D11.3 functional spec, "Texture Filtering" (bilinear weights and mip weight need at least 8 fractional bits, so a one-step difference is legal). A wrong filter, wrong LOD clamp or a swapped table still moves the probes by far more than one step. ## Verification - `x86_64-w64-mingw32-g++ -std=c++20 -fsyntax-only tests/startup_sampler_x.cpp` (with the generated shader header stubbed): no errors. - Unchanged-behaviour check on an RTX 3090 (vkd3d-proton, Linux), `startup_sampler_x_hardware`, `_warp` and `startup_sampler_x_swapped_hardware` pass with the old tolerance on that GPU; the new tolerance only widens it. - Win2025 WARP dev+release: pending Stage-2. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T10:36:24Z.


Independent review of head 6ceb980ba (the sampler probe tolerance): PASS.

Verification:

  • Windows Server 2025 (D3D12 WARP), ctest -R '^startup_sampler_x': dev 4/4 and release 4/4 (startup_sampler_x_hardware, _warp, _swapped_hardware, _swapped_warp).
  • Wrong-value control: with the reference moved by one texel in u (bilinear(s, mip, p.u + 1.0f / texture_size, p.v) in reference()), all four tests fail on WARP with a value mismatch ("table 2 probe 0 ... expected 3.5, got 2.5"). So a real off-by-one texel still fails.
  • Tolerance is the one-step bound and not wider: recomputing the five linear probes with each of the three weights (two bilinear, one mip) off by exactly one 1/256 step gives a worst legal deviation of 0.25 to 0.28; the new tolerance is 0.27 to 0.38 (1.06 to 1.43 times that, the difference being the existing 0.01 float slack). The 0.25 that the GTX 1080 Ti showed in #2781 (mip weight 129/256, gap 64) is inside it.
  • Note, not blocking: at the last linear probe (u=0.125, v=0.0625, lod 1.5) a one-texel shift in u moves the value by 0.25, below its new tolerance of 0.268, so that single probe no longer separates it (the old 0.01 did). The other four linear probes still do (deltas 1.0, 8.0 and 0.625), as the mutant run above shows.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189588517 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2794#issuecomment-7189588517). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T10:36:24Z. --- Independent review of head 6ceb980ba (the sampler probe tolerance): PASS. Verification: - Windows Server 2025 (D3D12 WARP), `ctest -R '^startup_sampler_x'`: dev 4/4 and release 4/4 (`startup_sampler_x_hardware`, `_warp`, `_swapped_hardware`, `_swapped_warp`). - Wrong-value control: with the reference moved by one texel in u (`bilinear(s, mip, p.u + 1.0f / texture_size, p.v)` in `reference()`), all four tests fail on WARP with a value mismatch ("table 2 probe 0 ... expected 3.5, got 2.5"). So a real off-by-one texel still fails. - Tolerance is the one-step bound and not wider: recomputing the five linear probes with each of the three weights (two bilinear, one mip) off by exactly one 1/256 step gives a worst legal deviation of 0.25 to 0.28; the new tolerance is 0.27 to 0.38 (1.06 to 1.43 times that, the difference being the existing 0.01 float slack). The 0.25 that the GTX 1080 Ti showed in #2781 (mip weight 129/256, gap 64) is inside it. - Note, not blocking: at the last linear probe (u=0.125, v=0.0625, lod 1.5) a one-texel shift in u moves the value by 0.25, below its new tolerance of 0.268, so that single probe no longer separates it (the old 0.01 did). The other four linear probes still do (deltas 1.0, 8.0 and 0.625), as the mutant run above shows. AI-assisted; commands listed were executed locally.
chatgpt-codex-connector[bot commented 2026-11-26 11:03:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-26T10:36:36Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T10:42:02.740318Z 6ceb980 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7189592905 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2794#issuecomment-7189592905). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-26T10:36:36Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"6ceb980ba65e9cee3ec2a7a5956f336397178829","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-26T10:42:02.740318Z">2026-11-26T10:42:02.740318Z</relative-time> | `6ceb980` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
Alexofbulgaria commented 2026-11-27 16:43:08 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Alexofbulgaria on 2026-11-27T16:43:08Z.


Native Windows hardware verification

Source-built Release at clean head 6ceb980ba65e9cee3ec2a7a5956f336397178829 on Windows build 26300.10075 with MSVC 19.44.35230 and DXC 1.9.2602.17.

Machine and backend Adapter and driver Passed Failed Skipped
Desktop hardware Intel Arc A770 (8086:56a0), 32.0.101.9175 6 0 0
Laptop hardware RTX 2070 Max-Q (10de:1f14), 32.0.15.8129 6 0 0
Desktop WARP Microsoft Basic Render Driver, 10.0.26100.10068 6 0 0
Laptop WARP Microsoft Basic Render Driver, 10.0.26100.10068 6 0 0

Ran each registered startup_sampler_x and startup_sampler_x_swapped case three times per backend using ctest --test-dir <release-build> --no-tests=error -V -R '^startup_sampler_x(_swapped)?_(hardware|warp)$', with hardware and WARP selected in separate runs. Each run had 0 mismatches out of 21. The D3D12 debug layer reported zero errors and warnings throughout.

The laptop read 34 at the probe where the GTX 1080 Ti reported 34.25. These results add native Arc and NVIDIA regression coverage for this head.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7223589030 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2794#issuecomment-7223589030). Originally posted by [Alexofbulgaria](https://github.com/Alexofbulgaria) on 2026-11-27T16:43:08Z. --- ### Native Windows hardware verification Source-built Release at clean head `6ceb980ba65e9cee3ec2a7a5956f336397178829` on Windows build `26300.10075` with MSVC `19.44.35230` and DXC `1.9.2602.17`. | Machine and backend | Adapter and driver | Passed | Failed | Skipped | | --- | --- | ---: | ---: | ---: | | Desktop hardware | Intel Arc A770 (`8086:56a0`), `32.0.101.9175` | 6 | 0 | 0 | | Laptop hardware | RTX 2070 Max-Q (`10de:1f14`), `32.0.15.8129` | 6 | 0 | 0 | | Desktop WARP | Microsoft Basic Render Driver, `10.0.26100.10068` | 6 | 0 | 0 | | Laptop WARP | Microsoft Basic Render Driver, `10.0.26100.10068` | 6 | 0 | 0 | Ran each registered `startup_sampler_x` and `startup_sampler_x_swapped` case three times per backend using `ctest --test-dir <release-build> --no-tests=error -V -R '^startup_sampler_x(_swapped)?_(hardware|warp)$'`, with hardware and WARP selected in separate runs. Each run had 0 mismatches out of 21. The D3D12 debug layer reported zero errors and warnings throughout. The laptop read 34 at the probe where the GTX 1080 Ti reported 34.25. These results add native Arc and NVIDIA regression coverage for this head.
pigalot commented 2026-11-27 18:24:53 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by pigalot on 2026-11-27T18:24:53Z.

Review: APPROVED


Independently reviewed 6ceb980b integrated over main 429f11d5 (tree d6733b68, clean merge).

What I traced. tolerance_for() uses the same LOD clamp as reference(), and point samplers stay exact. I also checked that the coverage gate is still meaningful under the wider tolerance. That gate compares linear references with point samples by exact ==. For each linear probe, I measured the distance from the reference to the nearest point sample the gate tries (both neighbouring mips, ±1/16 in u and v):

probe reference nearest point distance new tolerance
0 2.5 2 0.5 0.336
1 6 3 3 0.377
2 6.5 10 3.5 0.383
3 34 11 23 0.330
4 98 66 32 0.268

So a device that point-samples still fails the comparison, not just the gate.

What I ran. I built offscreen_check in dev and release, then ran
ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_sampler_x(_swapped)?_(hardware|warp)$'.
4/4 passed in Debug and Release /O2, with no skips. The hardware and WARP runs both read exactly 2.5,6,6.5,34,98 on table 2, with 0 mismatches of 21.

Mutants. I applied each one to reference() and ran it on WARP:

  • Mip weight forced to 0 (f = 0.0f): this fails at the coverage gate with "Linear probe matches a point sample".
  • Quarter-texel shift in u (tx = u * n - 0.25f in bilinear()): this passes on this head, with 0 mismatches of 21 on both WARP and the RTX 5090.
    • On main 429f11d5 the same mutant fails with table 2 probe 0 (u=0.125 v=0.0625 lod=0) expected 2.75, got 2.5 (5 of 21).

git diff --check is clean.

Non-blocking finding. The quarter-texel shift moves the five linear references by 0.25, 0.25, 0.25, 0.125 and 0.125. Each of those is inside its new tolerance (0.27–0.38), so table 2 no longer detects a sub-texel u error that main caught. This extends tedin7's note about the one-texel shift at probe 4 to every linear probe.

I don't think the formula is wrong. The cause is that one legal mip-weight step across this texture's mip gap of 64 is worth 0.25, while one texel in u is worth only 1. That is why the GTX 1080 Ti reading in #2781 needs the wider window.

A follow-up could restore the sensitivity by changing the fixture rather than the tolerance. One untested direction:

  • give the texel pattern a u step that is large next to mip gap / 256 (today one texel in u is worth 1, one row is worth 8 and one mip is worth 64);
  • or add a linear probe whose two mips differ by little;
  • then rerun the coverage gate.

This is not a reason to hold the PR. Tolerating the spec-legal step is the point of the change, and the remaining sensitivity is stated above.

Verdict: approve on 6ceb980b.

Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; debug layer on.
CI: Build and test on Windows passes on 6ceb980b.

This reply was AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6092061198 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2794#pullrequestreview-6092061198). Originally posted by [pigalot](https://github.com/pigalot) on 2026-11-27T18:24:53Z. **Review:** APPROVED --- Independently reviewed `6ceb980b` integrated over `main` `429f11d5` (tree `d6733b68`, clean merge). **What I traced.** `tolerance_for()` uses the same LOD clamp as `reference()`, and point samplers stay exact. I also checked that the coverage gate is still meaningful under the wider tolerance. That gate compares linear references with point samples by exact `==`. For each linear probe, I measured the distance from the reference to the nearest point sample the gate tries (both neighbouring mips, ±1/16 in u and v): | probe | reference | nearest point | distance | new tolerance | |---|---|---|---|---| | 0 | 2.5 | 2 | 0.5 | 0.336 | | 1 | 6 | 3 | 3 | 0.377 | | 2 | 6.5 | 10 | 3.5 | 0.383 | | 3 | 34 | 11 | 23 | 0.330 | | 4 | 98 | 66 | 32 | 0.268 | So a device that point-samples still fails the comparison, not just the gate. **What I ran.** I built `offscreen_check` in `dev` and `release`, then ran `ctest --test-dir out/build/<preset> --no-tests=error -j 1 -V -R '^startup_sampler_x(_swapped)?_(hardware|warp)$'`. 4/4 passed in Debug and Release `/O2`, with no skips. The hardware and WARP runs both read exactly `2.5,6,6.5,34,98` on table 2, with 0 mismatches of 21. **Mutants.** I applied each one to `reference()` and ran it on WARP: - **Mip weight forced to 0** (`f = 0.0f`): this fails at the coverage gate with "Linear probe matches a point sample". - **Quarter-texel shift in u** (`tx = u * n - 0.25f` in `bilinear()`): this passes on this head, with 0 mismatches of 21 on both WARP and the RTX 5090. - On `main` `429f11d5` the same mutant fails with `table 2 probe 0 (u=0.125 v=0.0625 lod=0) expected 2.75, got 2.5` (5 of 21). `git diff --check` is clean. **Non-blocking finding.** The quarter-texel shift moves the five linear references by 0.25, 0.25, 0.25, 0.125 and 0.125. Each of those is inside its new tolerance (0.27–0.38), so table 2 no longer detects a sub-texel u error that `main` caught. This extends tedin7's note about the one-texel shift at probe 4 to every linear probe. I don't think the formula is wrong. The cause is that one legal mip-weight step across this texture's mip gap of 64 is worth 0.25, while one texel in u is worth only 1. That is why the GTX 1080 Ti reading in #2781 needs the wider window. A follow-up could restore the sensitivity by changing the fixture rather than the tolerance. One untested direction: - give the texel pattern a u step that is large next to `mip gap / 256` (today one texel in u is worth 1, one row is worth 8 and one mip is worth 64); - or add a linear probe whose two mips differ by little; - then rerun the coverage gate. This is not a reason to hold the PR. Tolerating the spec-legal step is the point of the change, and the remaining sensitivity is stated above. **Verdict:** approve on `6ceb980b`. Environment: NVIDIA GeForce RTX 5090, driver 32.0.16.1088; WARP 10.0.26100.9818; Windows 11 25H2 build 26200.9974; MSVC 19.52.37029; DXC 1.9.2602.17; debug layer on. CI: `Build and test on Windows` passes on `6ceb980b`. This reply was 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!2786
No description provided.