textures: preserve implicit LOD for rounded mip dimensions #223
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/226"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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, change8cd88b7, Windows 11 x64 build 26200, Python 3.12.10. From a fresh worktree: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
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.
8cd88b7ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
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
8cd88b7against the renderer built fromf02c237. Both backends reproduced the mismatch at mip 4 of the 28×128 case, pixel (0, 0). The green channel expected0.188232and returned0.0941162. With the renderer from8cd88b7, both orientations matched all 32 channels at mip 4 on both backends, with zero maximum absolute error.All four tests passed on the PR head, with no skips.