runtime: trace UI texture row-pitch bands and fix XG mip-0 and CopyTextureRegion tracking #3141

Merged
legacy-code-archaeologist merged 2 commits from upstream-pr/3141 into main 2026-11-27 21:24:57 +00:00
legacy-code-archaeologist commented 2026-11-27 17:59:50 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T17:59:50Z.


Fixes #3132

Summary

Adds a stage-by-stage synthetic reproduction and regression ( ests/startup_ui_texture_bands_check.cpp) for alternating nonzero/black horizontal row bands after an indexed textured UI draw following a gradient pass, and fixes two shared runtime gaps uncovered along the tested upload paths.

Investigation & Stage-by-Stage Findings

Using a source-built 32x32 3-mip DXGI_FORMAT_R8G8B8A8_UNORM texture (R = 24 + y6, G = 32 + x6, B = 64 + mip*80, A = 255;
ow_bytes = 128, desktop RowPitch = 256), a preceding indexed gradient draw, and a translated indexed textured quad (DrawIndexedInstanced) on both WARP (Microsoft Basic Render Driver, 10.0.26100.9711) and hardware (Intel(R) HD Graphics 530, 31.0.101.2111) on Windows 10.0.26100:

  • Working paths (1024/1024 exact pixels across mips 0, 1, 2; UV (0.01562, 0.01562) -> (0.01562, 0.04688) across y=0..1):
    • Path 1 (Linear reference, CopyTextureRegion slot 16): gpu texels mip0 y0=[(24,32,64,255),(24,38,64,255)] y1=[(30,32,64,255),(30,38,64,255)], post-UI RT exact across mips 0, 1 ((24,32,144,255)), and 2 ((24,32,224,255)).
    • **Path 1b (CopyTextureRegion into slot 133 texture + 16 frames + itle_memory mutation to
<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:5531037861 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3141). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T17:59:50Z. --- Fixes #3132 ### Summary Adds a stage-by-stage synthetic reproduction and regression ( ests/startup_ui_texture_bands_check.cpp) for alternating nonzero/black horizontal row bands after an indexed textured UI draw following a gradient pass, and fixes two shared runtime gaps uncovered along the tested upload paths. ### Investigation & Stage-by-Stage Findings Using a source-built 32x32 3-mip DXGI_FORMAT_R8G8B8A8_UNORM texture (R = 24 + y*6, G = 32 + x*6, B = 64 + mip*80, A = 255; ow_bytes = 128, desktop RowPitch = 256), a preceding indexed gradient draw, and a translated indexed textured quad (DrawIndexedInstanced) on both WARP (Microsoft Basic Render Driver, 10.0.26100.9711) and hardware (Intel(R) HD Graphics 530, 31.0.101.2111) on Windows 10.0.26100: - **Working paths (1024/1024 exact pixels across mips 0, 1, 2; UV (0.01562, 0.01562) -> (0.01562, 0.04688) across y=0..1):** - **Path 1 (Linear reference, CopyTextureRegion slot 16):** gpu texels mip0 y0=[(24,32,64,255),(24,38,64,255)] y1=[(30,32,64,255),(30,38,64,255)], post-UI RT exact across mips 0, 1 ((24,32,144,255)), and 2 ((24,32,224,255)). - **Path 1b (CopyTextureRegion into slot 133 texture + 16 frames + itle_memory mutation to
tedin7 commented 2026-11-27 20:50:21 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-27T20:50:21Z.

Review: COMMENTED


Review of 788f919b (comment only). I ran the new test and its neighbours on this exact head on Windows Server 2025. Setup: build 26100, MSVC 14.44.35207, WARP 10.0.26100.33648 ("Microsoft Basic Render Driver"), dev and release.

The new regression test fails here in both presets. startup_ui_texture_bands_warp and startup_ui_texture_bands_hardware both fail after 0.05-0.14 s. Their last output is the stand-in's D3D12XboxCreateDevice adapter=... riid=189819f1-... -> line, and no FAIL <case> line follows. On this host the _hardware run also lands on the Basic Render Driver.

  • Several early exits in main() return a bare code with no message (return 5 right after D3D12XboxCreateDevice, then 6 to 12). So the log cannot tell which step failed. My guess from the output is device creation, but I cannot confirm it.
  • Could you print one line before each early return, naming the step and the HRESULT? Could you also check the test on a WARP-only Windows Server host? The neighbouring device tests on the same host pass in both presets: startup_list_copy_* and startup_list_copy_texture_*, all startup_xg_* tiling and BC tests, and startup_stream_draw_*. So the stand-in itself starts there.

Behaviour changes worth a second look:

  • Mip count. full_mips() changes what MipLevels == 0 means in computer_layout and computer_copy_into: the full chain, where it used to be one mip. That matches desktop D3D12. But it changes the layout and the subresource % mips split for every XG texture created with MipLevels == 0, not only the UI case. A test that pins the layout of such a texture (for example 32x32, 6 mips) against the desktop footprints would protect this.
  • The full_mips code itself reads correctly. 1D ignores Height, 3D includes depth, array sizes are not counted, and the result is clamped to max_mips.
  • mark_gpu_written after CopyTextureRegion. It now marks subresource destinations; placed-footprint destinations are not marked. Moving the list_copy_texture.inl include after list_copy.inl is what makes that function visible there. The header comment was updated to match. This part looks right to me.

Merge: I am leaving the merge to R0Y00. The new test does not pass on our Windows host, and #3132 comes from a rendering problem seen while running a title, which we cannot check ourselves. The PR does not touch the native compute path or any file the cpp-migration branch changes.

Commands:

  • cmake --build --preset <dev|release> --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check offscreen_check startup_stream_consumer
  • ctest --preset <dev|release> -R '^startup_ui_texture_bands|^startup_list_copy|^startup_xg|^xg_|^startup_texture|^startup_stream_draw': 27 of 29 passed or skipped in each preset; the 2 failures are the new tests
  • git diff origin/main...pull/3141/head (read)

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093234377 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3141#pullrequestreview-6093234377). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-27T20:50:21Z. **Review:** COMMENTED --- Review of 788f919b (comment only). I ran the new test and its neighbours on this exact head on Windows Server 2025. Setup: build 26100, MSVC 14.44.35207, WARP `10.0.26100.33648` ("Microsoft Basic Render Driver"), dev and release. **The new regression test fails here in both presets.** `startup_ui_texture_bands_warp` and `startup_ui_texture_bands_hardware` both fail after 0.05-0.14 s. Their last output is the stand-in's `D3D12XboxCreateDevice adapter=... riid=189819f1-... ->` line, and no `FAIL <case>` line follows. On this host the `_hardware` run also lands on the Basic Render Driver. - Several early exits in `main()` return a bare code with no message (`return 5` right after `D3D12XboxCreateDevice`, then 6 to 12). So the log cannot tell which step failed. My guess from the output is device creation, but I cannot confirm it. - Could you print one line before each early return, naming the step and the HRESULT? Could you also check the test on a WARP-only Windows Server host? The neighbouring device tests on the same host pass in both presets: `startup_list_copy_*` and `startup_list_copy_texture_*`, all `startup_xg_*` tiling and BC tests, and `startup_stream_draw_*`. So the stand-in itself starts there. **Behaviour changes worth a second look:** - **Mip count.** `full_mips()` changes what `MipLevels == 0` means in `computer_layout` and `computer_copy_into`: the full chain, where it used to be one mip. That matches desktop D3D12. But it changes the layout and the `subresource % mips` split for every XG texture created with `MipLevels == 0`, not only the UI case. A test that pins the layout of such a texture (for example 32x32, 6 mips) against the desktop footprints would protect this. - **The `full_mips` code itself reads correctly.** 1D ignores Height, 3D includes depth, array sizes are not counted, and the result is clamped to `max_mips`. - **`mark_gpu_written` after `CopyTextureRegion`.** It now marks subresource destinations; placed-footprint destinations are not marked. Moving the `list_copy_texture.inl` include after `list_copy.inl` is what makes that function visible there. The header comment was updated to match. This part looks right to me. **Merge:** I am leaving the merge to R0Y00. The new test does not pass on our Windows host, and #3132 comes from a rendering problem seen while running a title, which we cannot check ourselves. The PR does not touch the native compute path or any file the `cpp-migration` branch changes. Commands: - `cmake --build --preset <dev|release> --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check offscreen_check startup_stream_consumer` - `ctest --preset <dev|release> -R '^startup_ui_texture_bands|^startup_list_copy|^startup_xg|^xg_|^startup_texture|^startup_stream_draw'`: 27 of 29 passed or skipped in each preset; the 2 failures are the new tests - `git diff origin/main...pull/3141/head` (read) AI-assisted; commands listed were executed locally.
legacy-code-archaeologist commented 2026-11-27 21:07:00 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by legacy-code-archaeologist on 2026-11-27T21:07:00Z.


@tedin7 Thank you for the detailed review and testing on Windows Server 2025! I found two causes for the failure and addressed all three points:

  1. Root cause of the Windows Server 2025 failure (D3D12XboxCreateDevice + _hardware adapter selection):

    • main() previously created the reference ComPtr<ID3D12Device> desktop via D3D12CreateDevice before calling D3D12XboxCreateDevice. Because X2W_D3D12_DEBUG=1 is set in the test environment, D3D12XboxCreateDevice (d3d12_xs_device.cpp) calls D3D12GetDebugInterface -> EnableDebugLayer(). On hosts with d3d12SDKLayers.dll installed (absent locally and on GH Actions), calling EnableDebugLayer() while a live ID3D12Device already exists triggers live-device removal on the process-singleton device. main() now calls D3D12XboxCreateDevice first, and only creates desktop afterward.
    • pick_adapter("hardware") previously only checked DXGI_ADAPTER_FLAG_SOFTWARE, allowing Microsoft Basic Render Driver (0x1414:0x008c) to be picked on hosted Server VMs. It now skips (desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) || (desc.VendorId == 0x1414 && desc.DeviceId == 0x008c) and returns 77 when no physical FL 12_0 adapter is present.
  2. Step + HRESULT diagnostics before every early exit:

    • Added fail_step(step, hr, rc) and replaced all bare early returns in main() and pick_adapter() with explicit stderr diagnostics naming the failing step and HRESULT (plus GetLastError() / CreatePipelineState HRESULT inside publish_translated_pso and make_committed).
  3. Pinning XGCreateTextureComputer MipLevels == 0 layout against desktop GetCopyableFootprints (Path 2c):

    • Added check_xg_mip0_layout(desktop) verifying XG slot 2 (computer_layout) header/plane/per-mip records (Size, Offset, SliceSize, RowPitch, Width, Height, DepthOrSlices, alignment) against desktop->GetCopyableFootprints and verifying CopyIntoSubresource (slot 8) byte placement + out-of-range E_INVALIDARG across:
      • 32x32 RGBA8 2D (MipLevels=0 -> 6 mips, all 6 subresources 0..5)
      • 32x32 RGBA8 2D-Array (ArraySize=2, MipLevels=0 -> 6 mips x 2 slices = 12 subresources, pinning subresource % mips and subresource / mips + slice_stride = 0x10000)
      • 32x8 RGBA8 2D (MipLevels=0 -> 6 mips)
      • 16x1 RGBA8 1D-Array (ArraySize=4, MipLevels=0 -> 5 mips)
      • 8x4x16 RGBA8 3D (MipLevels=0 -> 5 mips)

Local verification (Windows 11, MSVC 19.52, Intel HD Graphics 530; note d3d12SDKLayers.dll is not installed locally, so re-running on Windows Server 2025 is appreciated):

  • cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check offscreen_check startup_stream_consumer: passed
  • cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check: passed
  • ctest --preset dev --no-tests=error -R '^startup_ui_texture_bands' -V: 2/2 passed (startup_ui_texture_bands_warp, startup_ui_texture_bands_hardware, including all 5 Path 2c checks)
  • ctest --preset release --no-tests=error -R '^startup_ui_texture_bands' -V: 2/2 passed (startup_ui_texture_bands_warp, startup_ui_texture_bands_hardware, including all 5 Path 2c checks)
  • ctest --preset dev --no-tests=error -R '^startup_ui_texture_bands|^startup_list_copy|^startup_xg|^xg_|^startup_small_texture_4k|^startup_stream_draw' --output-on-failure: 32 passed, 6 skipped (xg_bc64_tiling_reference, startup_small_texture_4k_addrlib, xg_swizzle_* — addrlib not configured), 0 failed
  • python -B tests/docs_links_check.py: passed (107 Markdown files, 596 links)

AI-assisted.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228148726 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3141#issuecomment-7228148726). Originally posted by [legacy-code-archaeologist](https://github.com/legacy-code-archaeologist) on 2026-11-27T21:07:00Z. --- @tedin7 Thank you for the detailed review and testing on Windows Server 2025! I found two causes for the failure and addressed all three points: 1. **Root cause of the Windows Server 2025 failure (`D3D12XboxCreateDevice` + `_hardware` adapter selection):** - `main()` previously created the reference `ComPtr<ID3D12Device> desktop` via `D3D12CreateDevice` *before* calling `D3D12XboxCreateDevice`. Because `X2W_D3D12_DEBUG=1` is set in the test environment, `D3D12XboxCreateDevice` (`d3d12_xs_device.cpp`) calls `D3D12GetDebugInterface` -> `EnableDebugLayer()`. On hosts with `d3d12SDKLayers.dll` installed (absent locally and on GH Actions), calling `EnableDebugLayer()` while a live `ID3D12Device` already exists triggers live-device removal on the process-singleton device. `main()` now calls `D3D12XboxCreateDevice` **first**, and only creates `desktop` afterward. - `pick_adapter("hardware")` previously only checked `DXGI_ADAPTER_FLAG_SOFTWARE`, allowing Microsoft Basic Render Driver (`0x1414:0x008c`) to be picked on hosted Server VMs. It now skips `(desc.Flags & DXGI_ADAPTER_FLAG_SOFTWARE) || (desc.VendorId == 0x1414 && desc.DeviceId == 0x008c)` and returns `77` when no physical FL 12_0 adapter is present. 2. **Step + HRESULT diagnostics before every early exit:** - Added `fail_step(step, hr, rc)` and replaced all bare early `return`s in `main()` and `pick_adapter()` with explicit stderr diagnostics naming the failing step and HRESULT (plus `GetLastError()` / `CreatePipelineState` HRESULT inside `publish_translated_pso` and `make_committed`). 3. **Pinning `XGCreateTextureComputer` `MipLevels == 0` layout against desktop `GetCopyableFootprints` (`Path 2c`):** - Added `check_xg_mip0_layout(desktop)` verifying `XG` slot 2 (`computer_layout`) header/plane/per-mip records (`Size`, `Offset`, `SliceSize`, `RowPitch`, `Width`, `Height`, `DepthOrSlices`, alignment) against `desktop->GetCopyableFootprints` and verifying `CopyIntoSubresource` (slot 8) byte placement + out-of-range `E_INVALIDARG` across: - `32x32` RGBA8 2D (`MipLevels=0` -> 6 mips, all 6 subresources `0..5`) - `32x32` RGBA8 2D-Array (`ArraySize=2`, `MipLevels=0` -> 6 mips x 2 slices = 12 subresources, pinning `subresource % mips` and `subresource / mips` + `slice_stride = 0x10000`) - `32x8` RGBA8 2D (`MipLevels=0` -> 6 mips) - `16x1` RGBA8 1D-Array (`ArraySize=4`, `MipLevels=0` -> 5 mips) - `8x4x16` RGBA8 3D (`MipLevels=0` -> 5 mips) **Local verification (Windows 11, MSVC 19.52, Intel HD Graphics 530; note `d3d12SDKLayers.dll` is not installed locally, so re-running on Windows Server 2025 is appreciated):** - `cmake --build --preset dev --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check offscreen_check startup_stream_consumer`: passed - `cmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check`: passed - `ctest --preset dev --no-tests=error -R '^startup_ui_texture_bands' -V`: 2/2 passed (`startup_ui_texture_bands_warp`, `startup_ui_texture_bands_hardware`, including all 5 `Path 2c` checks) - `ctest --preset release --no-tests=error -R '^startup_ui_texture_bands' -V`: 2/2 passed (`startup_ui_texture_bands_warp`, `startup_ui_texture_bands_hardware`, including all 5 `Path 2c` checks) - `ctest --preset dev --no-tests=error -R '^startup_ui_texture_bands|^startup_list_copy|^startup_xg|^xg_|^startup_small_texture_4k|^startup_stream_draw' --output-on-failure`: 32 passed, 6 skipped (`xg_bc64_tiling_reference`, `startup_small_texture_4k_addrlib`, `xg_swizzle_*` — addrlib not configured), 0 failed - `python -B tests/docs_links_check.py`: passed (`107` Markdown files, `596` links) AI-assisted.
R0Y00 commented 2026-11-27 21:17:12 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:17:12Z.


I tested f73816e8 combined locally with #3153 0530cfaf over main cf3df832 (tree d2d6086058dc9fcd96c47b2884b78aa43ac6b7bd). The merge was clean. Built startup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warp and ran ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(startup_sampler_heap_wrapped|startup_xg_bc7_draw|startup_ui_texture_bands|startup_list_copy_texture)_(warp|hardware)$' in Release /O2: 8/8 passed, no skips. The UI suite covered full-chain MipLevels=0, copies into subresources and the source-memory mutation case. The CPU-backed BC7 display fixture still matched all 131,072 pixels on both adapters. The early device-init failure from the predecessor did not reproduce here with the debug layer enabled.

Windows 11 build 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop 32.0.16.1656, SDK/DXC 10.0.26100.0. This run covers the two upload paths together. The host here is Windows 11, so the Windows Server setup from tedin7’s earlier receipt is a separate check.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7228306171 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3141#issuecomment-7228306171). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T21:17:12Z. --- I tested `f73816e8` combined locally with #3153 `0530cfaf` over `main` `cf3df832` (tree `d2d6086058dc9fcd96c47b2884b78aa43ac6b7bd`). The merge was clean. Built `startup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warp` and ran `ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(startup_sampler_heap_wrapped|startup_xg_bc7_draw|startup_ui_texture_bands|startup_list_copy_texture)_(warp|hardware)$'` in Release `/O2`: 8/8 passed, no skips. The UI suite covered full-chain `MipLevels=0`, copies into subresources and the source-memory mutation case. The CPU-backed BC7 display fixture still matched all 131,072 pixels on both adapters. The early device-init failure from the predecessor did not reproduce here with the debug layer enabled. Windows 11 build `26200.9974`, WARP `10.0.26100.9818`, RTX 4060 Laptop `32.0.16.1656`, SDK/DXC `10.0.26100.0`. This run covers the two upload paths together. The host here is Windows 11, so the Windows Server setup from tedin7’s earlier receipt is a separate check.
R0Y00 commented 2026-11-27 21:24:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:24:39Z.

Review: APPROVED


Independently reviewed f73816e8 on main 5b145ca9, which includes #3153 (tree 04d7cb57706cae0af0b549f4fc271a24cd262d9b). Built startup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warp. Ran ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(startup_sampler_heap_wrapped|startup_xg_bc7_draw|startup_ui_texture_bands|startup_list_copy_texture)_(warp|hardware)$'. Debug and Release /O2 each passed 8/8 with no skips. git diff --check HEAD^1 HEAD passed. Hosted Windows, Linux and gfx1013 checks passed.

MipLevels=0 produced the full chain, all measured mips matched the 1,024-pixel reference, and the copied subresource retained the GPU pixels after the source-memory mutation. The wrong-row-pitch control first differed at row 1, byte 256, turning RGBA (30,32,64,255) to (0,0,0,0) before sampling. Both #3153 display draws still matched 131,072 pixels. The new debug-layer initialization order ran on both adapters here. Windows 26200.9974, WARP 10.0.26100.9818, RTX 4060 Laptop driver 32.0.16.1656, SDK/DXC 10.0.26100.0. These are synthetic results. The Windows Server environment and the original executable remain separate observations.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6093463440 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/3141#pullrequestreview-6093463440). Originally posted by [R0Y00](https://github.com/R0Y00) on 2026-11-27T21:24:39Z. **Review:** APPROVED --- Independently reviewed `f73816e8` on `main` `5b145ca9`, which includes #3153 (tree `04d7cb57706cae0af0b549f4fc271a24cd262d9b`). Built `startup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warp`. Ran `ctest --test-dir <build> --no-tests=error -j 1 -V -R '^(startup_sampler_heap_wrapped|startup_xg_bc7_draw|startup_ui_texture_bands|startup_list_copy_texture)_(warp|hardware)$'`. Debug and Release `/O2` each passed 8/8 with no skips. `git diff --check HEAD^1 HEAD` passed. Hosted Windows, Linux and gfx1013 checks passed. `MipLevels=0` produced the full chain, all measured mips matched the 1,024-pixel reference, and the copied subresource retained the GPU pixels after the source-memory mutation. The wrong-row-pitch control first differed at row 1, byte 256, turning RGBA `(30,32,64,255)` to `(0,0,0,0)` before sampling. Both #3153 display draws still matched 131,072 pixels. The new debug-layer initialization order ran on both adapters here. Windows `26200.9974`, WARP `10.0.26100.9818`, RTX 4060 Laptop driver `32.0.16.1656`, SDK/DXC `10.0.26100.0`. These are synthetic results. The Windows Server environment and the original executable remain separate observations.
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!3141
No description provided.