tests: make explicit gradients select the mip above a MinLod floor #2655

Merged
RavenCurseBurg merged 2 commits from upstream-pr/2663 into main 2026-11-26 01:22:54 +00:00
RavenCurseBurg commented 2026-11-26 01:09:09 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RavenCurseBurg on 2026-11-26T01:09:09Z.


Change

The MinLod smoke test used an explicit gradient covering only a quarter of a texel on the base level and a minimum LOD of 1. A shader that discarded both gradients could still sample the expected green mip.

This adds the complementary case. The X and Y gradients each span two texels on the existing 8×8 texture, so the expected LOD is 1 even with a floor of 0. The same constant UV with implicit derivatives reads red mip 0. The fixture uses its existing mip texture, checks all covered pixels and retains its clear-color check outside the triangle.

Verification

At 17a52445 on Windows 11 build 26100.9711 I ran

python -B tests/spirv_window/minlod.py $as $val $cross $dxc $renderer warp
python -B tests/spirv_window/minlod.py $as $val $cross $dxc $renderer hardware

I selected each physical card with XBOX2WINDOWS_ADAPTER. On all three backends the new case passed. I then replaced every Grad sample in the test with an implicit sample at the same floor. All four previous cases still passed. With the new case, each backend reported the first mismatch at pixel (0,0), channel R, expected 0x00000000, actual 0x3f800000 (red in place of green).

Adapter Driver
Intel UHD Graphics 770 32.0.101.5973
NVIDIA GeForce RTX 4060 32.0.15.9579
Microsoft WARP 10.0.26100.9711

The source-built public tools used SPIRV-Tools 262bdab4, patched SPIRV-Cross 57e4efcc, DXC 1.9.2609 (-T ps_6_0 -E main) and the offscreen renderer built at c601e6e9. The desktop debug layer was unavailable.

Evidence and follow-up

In a separate four-mip experiment I compared the translated Grad|MinLod instruction with a direct HLSL SampleGrad at 14 clamp/gradient settings per device. All 42 pairs of 8×8 RGBA readbacks matched bit for bit (10,752 channel comparisons). Both paths also matched the independent mip blend within 2/256. That sweep covers constant orthogonal gradients and solid-color mips. The original finite mismatches are still open in #809.

Refs #809.

AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6617176319 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2663). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-26T01:09:09Z. --- ## Change The MinLod smoke test used an explicit gradient covering only a quarter of a texel on the base level and a minimum LOD of 1. A shader that discarded both gradients could still sample the expected green mip. This adds the complementary case. The X and Y gradients each span two texels on the existing 8×8 texture, so the expected LOD is 1 even with a floor of 0. The same constant UV with implicit derivatives reads red mip 0. The fixture uses its existing mip texture, checks all covered pixels and retains its clear-color check outside the triangle. ## Verification At `17a52445` on Windows 11 build 26100.9711 I ran ```powershell python -B tests/spirv_window/minlod.py $as $val $cross $dxc $renderer warp python -B tests/spirv_window/minlod.py $as $val $cross $dxc $renderer hardware ``` I selected each physical card with `XBOX2WINDOWS_ADAPTER`. On all three backends the new case passed. I then replaced every Grad sample in the test with an implicit sample at the same floor. All four previous cases still passed. With the new case, each backend reported the first mismatch at pixel (0,0), channel R, expected `0x00000000`, actual `0x3f800000` (red in place of green). | Adapter | Driver | | --- | --- | | Intel UHD Graphics 770 | 32.0.101.5973 | | NVIDIA GeForce RTX 4060 | 32.0.15.9579 | | Microsoft WARP | 10.0.26100.9711 | The source-built public tools used SPIRV-Tools `262bdab4`, patched SPIRV-Cross `57e4efcc`, DXC 1.9.2609 (`-T ps_6_0 -E main`) and the offscreen renderer built at `c601e6e9`. The desktop debug layer was unavailable. ## Evidence and follow-up In a separate four-mip experiment I compared the translated `Grad|MinLod` instruction with a direct HLSL `SampleGrad` at 14 clamp/gradient settings per device. All 42 pairs of 8×8 RGBA readbacks matched bit for bit (10,752 channel comparisons). Both paths also matched the independent mip blend within 2/256. That sweep covers constant orthogonal gradients and solid-color mips. The original finite mismatches are still open in #809. Refs #809. AI-assisted contribution using Codex (GPT-6.2 Astra, xhigh).
upstream-sync closed this pull request 2026-11-26 02:05:00 +00:00
tedin7 commented 2026-11-26 02:05:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:16:37Z.

Review: COMMENTED


Review of head 07be2124 (after updating with main). Code review only.

What I checked:

  • tests/spirv_window/minlod.spvasm / minlod.py: new grad-above-clamp case. Gradients of 0.25 on the 8x8 texture span two texels, so the explicit LOD is 1 with a floor of 0. It expects the same exact readback as the other passing cases (64 pixels, max error 0, green mip 1). The no-clamp negative control is unchanged. This does guard what the title says: a lowering that drops the Grad operands would read red mip 0 and fail the exact readback.
  • Constants %zero, %quarter exist in the fixture; no production code is touched (2 files, 4 lines).
  • Sibling cases (implicit, bias, grad) are untouched and still run in the same loop. No other open or merged PR covers this slice.

Commands run (Linux):

  • spirv-as + spirv-val --target-env vulkan1.2 on all five generated variants -> all valid
  • python3 tests/docs_links_check.py, python3 tests/bidi_controls_check.py -> passed
  • git diff --check origin/main...HEAD -> clean
  • The draw readback needs D3D12, so it is not run on Linux; the Windows WARP run follows separately.

Findings: none blocking.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6067254741 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2663#pullrequestreview-6067254741). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T01:16:37Z. **Review:** COMMENTED --- Review of head 07be2124 (after updating with main). Code review only. What I checked: - `tests/spirv_window/minlod.spvasm` / `minlod.py`: new `grad-above-clamp` case. Gradients of 0.25 on the 8x8 texture span two texels, so the explicit LOD is 1 with a floor of 0. It expects the same exact readback as the other passing cases (64 pixels, max error 0, green mip 1). The `no-clamp` negative control is unchanged. This does guard what the title says: a lowering that drops the Grad operands would read red mip 0 and fail the exact readback. - Constants `%zero`, `%quarter` exist in the fixture; no production code is touched (2 files, 4 lines). - Sibling cases (`implicit`, `bias`, `grad`) are untouched and still run in the same loop. No other open or merged PR covers this slice. Commands run (Linux): - `spirv-as` + `spirv-val --target-env vulkan1.2` on all five generated variants -> all valid - `python3 tests/docs_links_check.py`, `python3 tests/bidi_controls_check.py` -> passed - `git diff --check origin/main...HEAD` -> clean - The draw readback needs D3D12, so it is not run on Linux; the Windows WARP run follows separately. Findings: none blocking. AI-assisted; commands listed were executed locally.
tedin7 commented 2026-11-26 02:05:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-26T01:22:26Z.


Windows WARP check for head 07be2124 (after updating with main): not verified here.

On Windows Server 2025 (build 26100, D3D12 WARP), ctest -R minlod ran 8 tests in dev and release. All 8 were reported as Skipped (exit 77), including spirv_minlod_warp. The test skips when the SPIRV-Cross build on the machine lacks MinLod support (tools/setup-spirv-tools.ps1 not applied), so the new grad-above-clamp draw readback did not execute on our side.

  • Linux: all five SPIR-V variants assemble and validate; docs/bidi checks and git diff --check pass.
  • The author's own Windows run in the PR body covers WARP and hardware.
  • Merge is left to whoever can run the draw with a MinLod-capable SPIRV-Cross build (MasterDomino or @R0Y00).

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7179709179 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/2663#issuecomment-7179709179). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-26T01:22:26Z. --- Windows WARP check for head 07be2124 (after updating with main): not verified here. On Windows Server 2025 (build 26100, D3D12 WARP), `ctest -R minlod` ran 8 tests in dev and release. All 8 were reported as Skipped (exit 77), including `spirv_minlod_warp`. The test skips when the SPIRV-Cross build on the machine lacks MinLod support (`tools/setup-spirv-tools.ps1` not applied), so the new `grad-above-clamp` draw readback did not execute on our side. - Linux: all five SPIR-V variants assemble and validate; docs/bidi checks and `git diff --check` pass. - The author's own Windows run in the PR body covers WARP and hardware. - Merge is left to whoever can run the draw with a MinLod-capable SPIRV-Cross build (MasterDomino or @R0Y00). 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!2655
No description provided.