textures: draw BC7 mip chains through the final texel #204

Manually merged
github merged 1 commit from gh-pr/204/head into gh-pr/204/base 2026-11-26 21:34:21 +00:00
Owner

@⁠Vonsek on GitHub · 2026-11-21 18:21 UTC · original
Vonsek:codex/bc7-small-mips → main · +45 −7 · 4 files · 1 commits · merged 2026-11-21 18:24 UTC

Change

Read each BC7 mip as a grid of complete 16-byte blocks and retain one reference color per logical texel. Both draw commands now accept mips down to 1×1. A rectangular chain can continue when one axis reaches one texel. The base texture still requires block-aligned dimensions. The tail command validates the supplied levels against the actual mip sequence, including its final level.

Verification

Base d1f7c33, change cc1c1a9, Windows 11 x64 build 26200. Commands from the fresh worktree:

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

Before the reader change, the WARP CTest failed with Invalid single-level BC7 case dimensions or header when the square chain reached its 2×2 mip. Before the CLI change, the 13-level strip returned exit code 2 at argument validation. With this commit both CTests and the direct WARP check passed. WARP 10.0.26100.9818 and the RTX 5080 on driver 32.0.16.1692 reported zero maximum absolute error on the 2×2 and 1×1 square mips, and on all 13 levels of the 4096×4 strip. Both adapters ran with the debug layer unavailable, with no skips.

Evidence and follow-up

The MIT-licensed fixture builds mode-6 blocks in Python. Each generated strip has a distinct endpoint per mip and a known interpolated pattern inside each block. The check compares all four channels of every visible texel. The controls reject a repeated 1×1 level, an unaligned 2×1 base, and a stale red reference value at (0, 0) in the final mip.

The case layout and extent limits are recorded in the experiment notes. Microsoft describes logical versus physical mip dimensions in its block-compression guide.

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 updated the extent and case-layout documentation.
  • I did not include game files, dumps, distribution links or secrets.
**@⁠Vonsek** on GitHub · 2026-11-21 18:21 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204) `Vonsek:codex/bc7-small-mips` → `main` · +45 −7 · 4 files · 1 commits · merged 2026-11-21 18:24 UTC ## Change Read each BC7 mip as a grid of complete 16-byte blocks and retain one reference color per logical texel. Both draw commands now accept mips down to 1×1. A rectangular chain can continue when one axis reaches one texel. The base texture still requires block-aligned dimensions. The tail command validates the supplied levels against the actual mip sequence, including its final level. ## Verification Base `d1f7c33`, change `cc1c1a9`, Windows 11 x64 build 26200. Commands from the 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 $bc7Python = (Resolve-Path out/pe-env/Scripts/python.exe).Path cmake --preset dev "-DINTAKE_PYTHON=$bc7Python" cmake --build --preset dev --target offscreen_check --parallel 4 ctest --preset dev --no-tests=error -R '^bc7_draw_(warp|hardware)$' -V $bc7Dxc = (Get-Command dxc.exe).Source .\out\pe-env\Scripts\python.exe -B tests/bc7_draw_check.py $bc7Dxc out/build/dev/offscreen_check.exe warp ``` Before the reader change, the WARP CTest failed with `Invalid single-level BC7 case dimensions or header` when the square chain reached its 2×2 mip. Before the CLI change, the 13-level strip returned exit code 2 at argument validation. With this commit both CTests and the direct WARP check passed. WARP 10.0.26100.9818 and the RTX 5080 on driver 32.0.16.1692 reported zero maximum absolute error on the 2×2 and 1×1 square mips, and on all 13 levels of the 4096×4 strip. Both adapters ran with the debug layer unavailable, with no skips. ## Evidence and follow-up The MIT-licensed fixture builds mode-6 blocks in Python. Each generated strip has a distinct endpoint per mip and a known interpolated pattern inside each block. The check compares all four channels of every visible texel. The controls reject a repeated 1×1 level, an unaligned 2×1 base, and a stale red reference value at (0, 0) in the final mip. The case layout and extent limits are recorded in [the experiment notes](https://github.com/Vonsek/Xbox2Windows/blob/cc1c1a9/docs/experiments.md#drawing-bc7-textures-with-a-recompiled-pixel-shader). Microsoft describes logical versus physical mip dimensions in its [block-compression guide](https://learn.microsoft.com/en-us/windows/win32/direct3d10/d3d10-graphics-programming-guide-resources-block-compression). 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 updated the extent and case-layout documentation. - [x] I did not include game files, dumps, distribution links or secrets.
A small BC7 level still occupies whole compressed blocks. Size the upload from the block grid while sampling against logical texels, and let rectangular mip chains continue after one axis reaches one.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 21:34:19 +00:00
github manually merged commit cc1c1a920e into gh-pr/204/base 2026-11-26 21:34:21 +00:00
@ -298,0 +302,4 @@
{
return (upper.width > 1 || upper.height > 1) &&
lower.width == std::max<UINT>(1, upper.width / 2) &&
lower.height == std::max<UINT>(1, upper.height / 2);
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:29 UTC · original

P2 Badge Select the intended LOD for non-power-of-two mip chains

For a valid 188×4 chain down to 1×1, this now accepts the 2×1 penultimate level, but draw_verified still uses that level's logical dimensions as the viewport. With the FILTER_MIN_MAG_MIP_POINT sampler in tests/pixel_aot_vs.hlsl, the implicit LOD is log2(188/2) ≈ 6.55, selecting mip 7 (1×1) while verification expects mip 6 (2×1). Correct compressed data therefore produces a false pixel_mismatch. Adjust the LOD/viewport selection for rounded-down non-power-of-two mips and cover such a chain in the fixture.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#discussion_r4654299986) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Select the intended LOD for non-power-of-two mip chains** For a valid 188×4 chain down to 1×1, this now accepts the 2×1 penultimate level, but `draw_verified` still uses that level's logical dimensions as the viewport. With the `FILTER_MIN_MAG_MIP_POINT` sampler in `tests/pixel_aot_vs.hlsl`, the implicit LOD is `log2(188/2) ≈ 6.55`, selecting mip 7 (1×1) while verification expects mip 6 (2×1). Correct compressed data therefore produces a false `pixel_mismatch`. Adjust the LOD/viewport selection for rounded-down non-power-of-two mips and cover such a chain in the fixture. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
@ -317,3 +326,3 @@
UINT first = 0;
const auto parsed = std::from_chars(arg.data(), arg.data() + arg.size(), first);
if (parsed.ec != std::errc{} || parsed.ptr != arg.data() + arg.size() || first > 10)
if (parsed.ec != std::errc{} || parsed.ptr != arg.data() + arg.size() || first > 12)
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:29 UTC · original

P2 Badge Reconstruct clamped axes before validating late tails

For the new 4096×4 strip, supplying its 2×1 and 1×1 levels with first resident mip 11, or just its 1×1 level with first resident mip 12, passes this widened range check but fails the following bounds validation. Reconstructing both base axes with level.width << first and level.height << first incorrectly expands the already-clamped height, yielding 4096×2048 or 4096×4096 and triggering Logical BC7 texture exceeds fixture bounds. In fact, every mip-12 tail is rejected this way. Carry the logical base extents through validation and resource creation, or otherwise account for axes that have already clamped to one texel.

Useful? React with 👍 / 👎.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#discussion_r4654299987) **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Reconstruct clamped axes before validating late tails** For the new 4096×4 strip, supplying its 2×1 and 1×1 levels with first resident mip 11, or just its 1×1 level with first resident mip 12, passes this widened range check but fails the following bounds validation. Reconstructing both base axes with `level.width << first` and `level.height << first` incorrectly expands the already-clamped height, yielding 4096×2048 or 4096×4096 and triggering `Logical BC7 texture exceeds fixture bounds`. In fact, every mip-12 tail is rejected this way. Carry the logical base extents through validation and resource creation, or otherwise account for axes that have already clamped to one texel. Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:29 UTC · original

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:29:11.387645Z cc1c1a9 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.

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#issuecomment-7067290030) <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"cc1c1a920e23fb00ab3f0f89b2da3eba0fb5b32e","has_any_findings":true,"has_unresolved_findings":true,"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:29:11.387645Z">2026-11-21T18:29:11.387645Z</relative-time> | `cc1c1a9` | 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>
@ -298,0 +302,4 @@
{
return (upper.width > 1 || upper.height > 1) &&
lower.width == std::max<UINT>(1, upper.width / 2) &&
lower.height == std::max<UINT>(1, upper.height / 2);
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 18:41 UTC · original · edited 2026-11-21 18:42 UTC

Confirmed on the stated 188×4 chain. With the merged renderer, both WARP and an RTX 5080 reported the first mismatch at mip 6, pixel (0, 0), red 0.0627441 expected and 0.0313721 observed. A local change centers the unrounded viewport over the logical render target. With the same source-built blocks and shader, both adapters matched all eight channels at mip 6 and all four at mip 7. The local regression suite also checks 28×128 and 128×28 chains, including a view starting at mip 2. The follow-up is in #226.

**@⁠Vonsek** on GitHub · 2026-11-21 18:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#discussion_r4654343093) · edited 2026-11-21 18:42 UTC Confirmed on the stated 188×4 chain. With the merged renderer, both WARP and an RTX 5080 reported the first mismatch at mip 6, pixel (0, 0), red 0.0627441 expected and 0.0313721 observed. A local change centers the unrounded viewport over the logical render target. With the same source-built blocks and shader, both adapters matched all eight channels at mip 6 and all four at mip 7. The local regression suite also checks 28×128 and 128×28 chains, including a view starting at mip 2. The follow-up is in [#226](https://git.gtahub.st/github/R0Y00--Xbox2Windows/pulls/226).
@ -317,3 +326,3 @@
UINT first = 0;
const auto parsed = std::from_chars(arg.data(), arg.data() + arg.size(), first);
if (parsed.ec != std::errc{} || parsed.ptr != arg.data() + arg.size() || first > 10)
if (parsed.ec != std::errc{} || parsed.ptr != arg.data() + arg.size() || first > 12)
Author
Owner

@⁠Vonsek on GitHub · 2026-11-21 18:41 UTC · original · edited 2026-11-21 19:13 UTC

Confirmed on WARP with the same source-built mip files. At commit cc1c1a9 the full 4096×4 chain through level 12 passed. Supplying only the 2×1 and 1×1 cases with first resident level 11, or only the 1×1 case with first resident level 12, returned exit code 1 with Logical BC7 texture exceeds fixture bounds. These are input-validation failures before texture creation. A 1×1 resident case and its mip index alone cannot distinguish a 4096×4 base from a 4×4096 base. Supporting both faithfully requires carrying the intended base dimensions through validation, resource creation and the fallback draws. The separate local viewport change addresses the first review finding only. The implementation is in #248. WARP and the RTX 5080 both verified the 4096×4 and 4×4096 fallback draws when given their respective base sizes, including when only the 1×1 mip was supplied.

**@⁠Vonsek** on GitHub · 2026-11-21 18:41 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#discussion_r4654343918) · edited 2026-11-21 19:13 UTC Confirmed on WARP with the same source-built mip files. At commit cc1c1a9 the full 4096×4 chain through level 12 passed. Supplying only the 2×1 and 1×1 cases with first resident level 11, or only the 1×1 case with first resident level 12, returned exit code 1 with `Logical BC7 texture exceeds fixture bounds`. These are input-validation failures before texture creation. A 1×1 resident case and its mip index alone cannot distinguish a 4096×4 base from a 4×4096 base. Supporting both faithfully requires carrying the intended base dimensions through validation, resource creation and the fallback draws. The separate local viewport change addresses the first review finding only. The implementation is in [#248](https://git.gtahub.st/github/R0Y00--Xbox2Windows/pulls/248). WARP and the RTX 5080 both verified the 4096×4 and 4×4096 fallback draws when given their respective base sizes, including when only the 1×1 mip was supplied.
Author
Owner

@⁠chatgpt-codex-connector[bot] on GitHub · 2026-11-21 18:29 UTC · original · reviewed

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: cc1c1a920e

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback".

**@⁠chatgpt-codex-connector[bot]** on GitHub · 2026-11-21 18:29 UTC · [original](https://github.com/R0Y00/Xbox2Windows/pull/204#pullrequestreview-6007275801) · **reviewed** <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `cc1c1a920e` <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". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@⁠codex address that feedback". </details>
This discussion has been locked. Commenting is limited to contributors.
No description provided.