textures: add an opt-in BC7 tiled layout query #1211

Merged
Jess-Doit merged 2 commits from upstream-pr/1218 into main 2026-11-24 04:30:13 +00:00
Jess-Doit commented 2026-11-24 04:06:11 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by Jess-Doit on 2026-11-24T04:06:11Z.


Change

Refs #1140.

With X2W_D3D12_PERMISSIVE=1 and X2W_XG_BC7_4K_S_LAYOUT=1, the xg_xs stand-in can report standard GFX10 4 KiB tiled geometry for a single-slice, single-mip BC7_UNORM 2D texture. The diagnostic selects this layout explicitly. Native XG selector values and detiling on upload are follow-ups. CopyIntoSubresource returns E_NOTIMPL for these tiled objects and preserves the caller's destination.

Verification

Tested 61c14219 (rebased on 81c377e5) on Windows 10 22H2 build 19045.6456. The source-built 64 × 64 and 81 × 69 cases matched 4 KiB and 16 KiB from the BC7 tile oracle, respectively, with zero mip offsets and intact guards. Both copy calls returned E_NOTIMPL. Forcing the desktop query failed both presets at the 81 × 69 span. The accepted 64 × 64 desktop control reported 64 KiB total size and alignment. Restoring the tiled query passed 8/8 in each preset with zero skips, including the neighboring swizzle selection, factory, caller, and BC7 round-trip tests.

With an x64 MSVC environment, the repo's Python dependencies in $python, and the pinned Mesa AddrLib source in $addrLib:

. .\tools\dev.ps1
$filter = '^(startup_xg_bc7_layout|gfx10_texture_roundtrip(_controls)?|xg_swizzle_(select|select_mutation|factory|factory_no_write)|cpu_native_xg_swizzle)$'
foreach ($preset in 'dev', 'release') {
    cmake --preset $preset "-DINTAKE_PYTHON=$python" "-DXBOX2WINDOWS_ADDRLIB_DIR=$addrLib"
    cmake --build --preset $preset -j 2 --target startup_stub_xg_xs xg_swizzle_select_check pe_map cpu_xg_swizzle_caller cpu_xg_swizzle_provider_clobber cpu_xg_swizzle_provider_linear
    ctest --preset $preset --no-tests=error -R $filter -V
}

The desktop-footprint mutation ran on the pre-rebase commit 7e73ffad; the rebased commit passed 8/8 again in both presets.

AI-assisted (Codex, reviewed with Claude Code).

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6574370175 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1218). Originally posted by [Jess-Doit](https://github.com/Jess-Doit) on 2026-11-24T04:06:11Z. --- ## Change Refs #1140. With `X2W_D3D12_PERMISSIVE=1` and `X2W_XG_BC7_4K_S_LAYOUT=1`, the `xg_xs` stand-in can report standard GFX10 4 KiB tiled geometry for a single-slice, single-mip `BC7_UNORM` 2D texture. The diagnostic selects this layout explicitly. Native XG selector values and detiling on upload are follow-ups. `CopyIntoSubresource` returns `E_NOTIMPL` for these tiled objects and preserves the caller's destination. ## Verification Tested `61c14219` (rebased on `81c377e5`) on Windows 10 22H2 build `19045.6456`. The source-built 64 × 64 and 81 × 69 cases matched 4 KiB and 16 KiB from the BC7 tile oracle, respectively, with zero mip offsets and intact guards. Both copy calls returned `E_NOTIMPL`. Forcing the desktop query failed both presets at the 81 × 69 span. The accepted 64 × 64 desktop control reported 64 KiB total size and alignment. Restoring the tiled query passed 8/8 in each preset with zero skips, including the neighboring swizzle selection, factory, caller, and BC7 round-trip tests. With an x64 MSVC environment, the repo's Python dependencies in `$python`, and the pinned Mesa AddrLib source in `$addrLib`: ```powershell . .\tools\dev.ps1 $filter = '^(startup_xg_bc7_layout|gfx10_texture_roundtrip(_controls)?|xg_swizzle_(select|select_mutation|factory|factory_no_write)|cpu_native_xg_swizzle)$' foreach ($preset in 'dev', 'release') { cmake --preset $preset "-DINTAKE_PYTHON=$python" "-DXBOX2WINDOWS_ADDRLIB_DIR=$addrLib" cmake --build --preset $preset -j 2 --target startup_stub_xg_xs xg_swizzle_select_check pe_map cpu_xg_swizzle_caller cpu_xg_swizzle_provider_clobber cpu_xg_swizzle_provider_linear ctest --preset $preset --no-tests=error -R $filter -V } ``` The desktop-footprint mutation ran on the pre-rebase commit `7e73ffad`; the rebased commit passed 8/8 again in both presets. AI-assisted (Codex, reviewed with Claude Code).
upstream-sync closed this pull request 2026-11-24 06:47:00 +00:00
tedin7 commented 2026-11-24 06:47:01 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:21:39Z.

Review: COMMENTED


Reviewed commit 61c14219.

Diff & edge-case audit

  • src/startup_stubs/xg_xs.cpp: use_bc7_4k_s_layout gates on X2W_XG_BC7_4K_S_LAYOUT and strictly restricts to 2D DXGI_FORMAT_BC7_UNORM, D3D12_TEXTURE_LAYOUT_UNKNOWN, Width/Height in [1, D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION] (16384), 1 slice, 1 mip, non-MSAA (Count=1, Quality=0), Alignment=0, Flags=D3D12_RESOURCE_FLAG_NONE.
  • write_bc7_4k_s_layout: pads dimensions to 64 texels (16x16 BC7 blocks, 4096 bytes/tile); max padded_width/padded_height is 16384, pitch_bytes is 65536, and bytes is computed in uint64_t (max 256 MiB), with no integer overflow. computer_copy_into returns E_NOTIMPL for this profile without modifying the destination.
  • tests/startup_xg_bc7_layout_check.py, CMakeLists.txt, docs/startup-runtime.md: Clean and title-neutral; tests/startup_xg_bc7_layout_check.py compares 64x64 and 81x69 against gfx10_texture_roundtrip_check.oracle_surface and checks guard bytes and CopyIntoSubresource E_NOTIMPL.

Checks run on Linux (61c14219)

  • /root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py: PASS (16 Markdown files, 274 links).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py: PASS (1019 files).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py: PASS.
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/xgameruntime_table_check.py: PASS (28 exports).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/gpu_report_format_check.py: PASS (10/10).
  • /root/.local/share/x2w-rev-venv/bin/python -B tests/hardware_reports_check.py: PASS (11/11).

Note: Windows MSVC build and startup_xg_bc7_layout (tests/startup_xg_bc7_layout_check.py, which loads startup_stub_xg_xs via ctypes.WinDLL) were not executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6033607566 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1218#pullrequestreview-6033607566). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:21:39Z. **Review:** COMMENTED --- Reviewed commit `61c14219`. ### Diff & edge-case audit - `src/startup_stubs/xg_xs.cpp`: `use_bc7_4k_s_layout` gates on `X2W_XG_BC7_4K_S_LAYOUT` and strictly restricts to 2D `DXGI_FORMAT_BC7_UNORM`, `D3D12_TEXTURE_LAYOUT_UNKNOWN`, `Width`/`Height` in `[1, D3D12_REQ_TEXTURE2D_U_OR_V_DIMENSION]` (`16384`), 1 slice, 1 mip, non-MSAA (`Count=1, Quality=0`), `Alignment=0`, `Flags=D3D12_RESOURCE_FLAG_NONE`. - `write_bc7_4k_s_layout`: pads dimensions to `64` texels (16x16 BC7 blocks, 4096 bytes/tile); max `padded_width`/`padded_height` is `16384`, `pitch_bytes` is `65536`, and `bytes` is computed in `uint64_t` (max 256 MiB), with no integer overflow. `computer_copy_into` returns `E_NOTIMPL` for this profile without modifying the destination. - `tests/startup_xg_bc7_layout_check.py`, `CMakeLists.txt`, `docs/startup-runtime.md`: Clean and title-neutral; `tests/startup_xg_bc7_layout_check.py` compares `64x64` and `81x69` against `gfx10_texture_roundtrip_check.oracle_surface` and checks guard bytes and `CopyIntoSubresource` `E_NOTIMPL`. ### Checks run on Linux (`61c14219`) - `/root/.local/share/x2w-rev-venv/bin/python -B tests/docs_links_check.py`: **PASS** (16 Markdown files, 274 links). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/bidi_controls_check.py`: **PASS** (1019 files). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/form_coverage_check.py`: **PASS**. - `/root/.local/share/x2w-rev-venv/bin/python -B tests/xgameruntime_table_check.py`: **PASS** (28 exports). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/gpu_report_format_check.py`: **PASS** (10/10). - `/root/.local/share/x2w-rev-venv/bin/python -B tests/hardware_reports_check.py`: **PASS** (11/11). Note: Windows MSVC build and `startup_xg_bc7_layout` (`tests/startup_xg_bc7_layout_check.py`, which loads `startup_stub_xg_xs` via `ctypes.WinDLL`) were **not** executed locally.
tedin7 commented 2026-11-24 06:50:19 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T04:25:16Z.


Windows Server 2025 retest at 61c14219 (Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, WARP):

Debug (dev preset)

Commands:

cmake --preset dev
cmake --build --preset dev --target startup_stub_xg_xs -- -j 6
ctest --preset dev -R "^startup_xg_bc7_layout$" --no-tests=error --output-on-failure

Results: 1 passed, 0 failed, 0 skipped (Total Test time: 0.34 sec)

  • startup_xg_bc7_layout: Passed (0.31 sec)

Release (/O2, release preset)

Commands:

cmake --preset release
cmake --build --preset release --target startup_stub_xg_xs -- -j 6
ctest --preset release -R "^startup_xg_bc7_layout$" --no-tests=error --output-on-failure

Results: 1 passed, 0 failed, 0 skipped (Total Test time: 0.20 sec)

  • startup_xg_bc7_layout: Passed (0.17 sec)
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7122002561 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1218#issuecomment-7122002561). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T04:25:16Z. --- Windows Server 2025 retest at `61c14219` (`Windows Server 2025 Build 26100, MSVC 14.44.35207, AMD Ryzen 5 PRO 5650U, WARP`): ### Debug (`dev` preset) Commands: ```powershell cmake --preset dev cmake --build --preset dev --target startup_stub_xg_xs -- -j 6 ctest --preset dev -R "^startup_xg_bc7_layout$" --no-tests=error --output-on-failure ``` Results: **1 passed, 0 failed, 0 skipped** (Total Test time: `0.34 sec`) - `startup_xg_bc7_layout`: Passed (`0.31 sec`) ### Release (`/O2`, `release` preset) Commands: ```powershell cmake --preset release cmake --build --preset release --target startup_stub_xg_xs -- -j 6 ctest --preset release -R "^startup_xg_bc7_layout$" --no-tests=error --output-on-failure ``` Results: **1 passed, 0 failed, 0 skipped** (Total Test time: `0.20 sec`) - `startup_xg_bc7_layout`: Passed (`0.17 sec`)
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!1211
No description provided.