textures: preserve implicit LOD for rounded mip dimensions #223

Merged
Vonsek merged 1 commit from upstream-pr/226 into main 2026-11-21 19:11:48 +00:00
Vonsek commented 2026-11-21 18:42:33 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Vonsek on 2026-11-21T18:42:33Z.


Change

Addresses the mip-selection finding on #204. Keep implicit mip selection stable when a BC7 level has rounded-down logical dimensions. For a 28×128 texture, mip 4 has a 1×8 render target. Mapping the entire width to one pixel gives a horizontal derivative of 28 texels per pixel, large enough for the point-mip sampler to select level 5. A centered 1.75×8 viewport gives the intended derivative of 16 while keeping the same eight readback texels.

Verification

Base f02c237, change 8cd88b7, Windows 11 x64 build 26200, Python 3.12.10. From a fresh worktree:

python -m venv out/pe-env
.\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt
. ./tools/dev.ps1
$npotPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path
cmake --preset dev "-DINTAKE_PYTHON=$npotPython"
cmake --build --preset dev --target offscreen_check --parallel 4
ctest --preset dev --no-tests=error -R '^(bc7_draw|pixel_aot)_(warp|hardware)$' -V
$npotDxc = (Get-Command dxc.exe).Source
.\out\pe-env\Scripts\python.exe -B tests/bc7_draw_check.py $npotDxc out/build/dev/offscreen_check.exe warp

Before the change, both WARP and hardware failed the independent 28×128 reproducer at mip 4, pixel (0, 0). With the block's red endpoint set to the mip number times eight, the shader returned 0.15686 (level 5) against the expected 0.125488 (level 4). The 188×4 case from review also failed on both adapters at mip 6, pixel (0, 0). Red was 0.0627441 expected and 0.0313721 observed. With the change both mip 6 and mip 7 matched exactly. The new regression test failed at the rounded level on the base renderer. After the change, each adapter matched all 32 channels at mip 4 in both orientations and checked the chain down to 1×1. All four CTests and the direct WARP invocation passed. WARP used the Microsoft Basic Render Driver 10.0.26100.9818. Hardware used the NVIDIA GeForce RTX 5080 on driver 32.0.16.1692. The debug layer was unavailable for both. No skips.

Evidence and follow-up

The MIT-licensed fixture generates a repeating mode-6 BC7 block that gives each level a different endpoint. It keeps only the visible texels from each edge block in the expected RGBA image. The 28×128 chain starts at resident mip 2, and the transposed 128×28 chain starts at mip 0. The new comparison runs through the existing translated copy shader and point sampler.

AI-assisted contribution.

Checklist

  • This pull request covers one reviewable behavior.
  • I included the exact command and result for the fixture checks.
  • I considered a negative control or failure case for a new fixture.
  • I checked whether README or build instructions needed a change; the existing commands apply.
  • I did not include game files, dumps, distribution links or secrets.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6532885748 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/226). Originally posted by [Vonsek](https://github.com/Vonsek) on 2026-11-21T18:42:33Z. --- ## Change Addresses [the mip-selection finding on #204](https://github.com/R0Y00/Xbox2Windows/pull/204#discussion_r4654299986). Keep implicit mip selection stable when a BC7 level has rounded-down logical dimensions. For a 28×128 texture, mip 4 has a 1×8 render target. Mapping the entire width to one pixel gives a horizontal derivative of 28 texels per pixel, large enough for the point-mip sampler to select level 5. A centered 1.75×8 viewport gives the intended derivative of 16 while keeping the same eight readback texels. ## Verification Base `f02c237`, change `8cd88b7`, Windows 11 x64 build 26200, Python 3.12.10. From a fresh worktree: ```powershell python -m venv out/pe-env .\out\pe-env\Scripts\python.exe -m pip install -r requirements-dev.txt . ./tools/dev.ps1 $npotPython = (Resolve-Path out/pe-env/Scripts/python.exe).Path cmake --preset dev "-DINTAKE_PYTHON=$npotPython" cmake --build --preset dev --target offscreen_check --parallel 4 ctest --preset dev --no-tests=error -R '^(bc7_draw|pixel_aot)_(warp|hardware)$' -V $npotDxc = (Get-Command dxc.exe).Source .\out\pe-env\Scripts\python.exe -B tests/bc7_draw_check.py $npotDxc out/build/dev/offscreen_check.exe warp ``` Before the change, both WARP and hardware failed the independent 28×128 reproducer at mip 4, pixel (0, 0). With the block's red endpoint set to the mip number times eight, the shader returned 0.15686 (level 5) against the expected 0.125488 (level 4). The 188×4 case from review also failed on both adapters at mip 6, pixel (0, 0). Red was 0.0627441 expected and 0.0313721 observed. With the change both mip 6 and mip 7 matched exactly. The new regression test failed at the rounded level on the base renderer. After the change, each adapter matched all 32 channels at mip 4 in both orientations and checked the chain down to 1×1. All four CTests and the direct WARP invocation passed. WARP used the Microsoft Basic Render Driver 10.0.26100.9818. Hardware used the NVIDIA GeForce RTX 5080 on driver 32.0.16.1692. The debug layer was unavailable for both. No skips. ## Evidence and follow-up The MIT-licensed fixture generates a repeating mode-6 BC7 block that gives each level a different endpoint. It keeps only the visible texels from each edge block in the expected RGBA image. The 28×128 chain starts at resident mip 2, and the transposed 128×28 chain starts at mip 0. The new comparison runs through the existing translated copy shader and point sampler. AI-assisted contribution. ## Checklist - [x] This pull request covers one reviewable behavior. - [x] I included the exact command and result for the fixture checks. - [x] I considered a negative control or failure case for a new fixture. - [x] I checked whether README or build instructions needed a change; the existing commands apply. - [x] I did not include game files, dumps, distribution links or secrets.
upstream-sync closed this pull request 2026-11-24 06:41:54 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 06:47:51 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-21T18:42:42Z.


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-21T18:46:09.959824Z 8cd88b7 PR opened
ℹ️ 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:7067455170 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/226#issuecomment-7067455170). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-21T18:42:42Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"8cd88b72c439338e292b0e5798ffee7ae660c339","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-21T18:46:09.959824Z">2026-11-21T18:46:09.959824Z</relative-time> | `8cd88b7` | PR opened | <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>
RonLogic commented 2026-11-24 06:47:52 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by RonLogic on 2026-11-21T19:01:43Z.


Independent before/after check on Windows 11 build 26300.9974 with an RTX 4070 (driver 32.0.16.2124) and in-box WARP (10.0.26100.9818). The D3D12 debug layer was enabled on both backends.

I ran the updated BC7 fixture from 8cd88b7 against the renderer built from f02c237. Both backends reproduced the mismatch at mip 4 of the 28×128 case, pixel (0, 0). The green channel expected 0.188232 and returned 0.0941162. With the renderer from 8cd88b7, both orientations matched all 32 channels at mip 4 on both backends, with zero maximum absolute error.

ctest --test-dir out/build/followup --no-tests=error -R '^(bc7_draw|pixel_aot)_(warp|hardware)$' -V

All four tests passed on the PR head, with no skips.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7067703522 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/226#issuecomment-7067703522). Originally posted by [RonLogic](https://github.com/RonLogic) on 2026-11-21T19:01:43Z. --- Independent before/after check on Windows 11 build 26300.9974 with an RTX 4070 (driver 32.0.16.2124) and in-box WARP (10.0.26100.9818). The D3D12 debug layer was enabled on both backends. I ran the updated BC7 fixture from `8cd88b7` against the renderer built from `f02c237`. Both backends reproduced the mismatch at mip 4 of the 28×128 case, pixel (0, 0). The green channel expected `0.188232` and returned `0.0941162`. With the renderer from `8cd88b7`, both orientations matched all 32 channels at mip 4 on both backends, with zero maximum absolute error. ```powershell ctest --test-dir out/build/followup --no-tests=error -R '^(bc7_draw|pixel_aot)_(warp|hardware)$' -V ``` All four tests passed on the PR head, with no skips.
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!223
No description provided.