runtime: trace UI texture row-pitch bands and fix XG mip-0 and CopyTextureRegion tracking #3141
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3141"
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 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:
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, WARP10.0.26100.33648("Microsoft Basic Render Driver"), dev and release.The new regression test fails here in both presets.
startup_ui_texture_bands_warpandstartup_ui_texture_bands_hardwareboth fail after 0.05-0.14 s. Their last output is the stand-in'sD3D12XboxCreateDevice adapter=... riid=189819f1-... ->line, and noFAIL <case>line follows. On this host the_hardwarerun also lands on the Basic Render Driver.main()return a bare code with no message (return 5right afterD3D12XboxCreateDevice, 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.startup_list_copy_*andstartup_list_copy_texture_*, allstartup_xg_*tiling and BC tests, andstartup_stream_draw_*. So the stand-in itself starts there.Behaviour changes worth a second look:
full_mips()changes whatMipLevels == 0means incomputer_layoutandcomputer_copy_into: the full chain, where it used to be one mip. That matches desktop D3D12. But it changes the layout and thesubresource % mipssplit for every XG texture created withMipLevels == 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.full_mipscode itself reads correctly. 1D ignores Height, 3D includes depth, array sizes are not counted, and the result is clamped tomax_mips.mark_gpu_writtenafterCopyTextureRegion. It now marks subresource destinations; placed-footprint destinations are not marked. Moving thelist_copy_texture.inlinclude afterlist_copy.inlis 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-migrationbranch 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_consumerctest --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 testsgit diff origin/main...pull/3141/head(read)AI-assisted; commands listed were executed locally.
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:
Root cause of the Windows Server 2025 failure (
D3D12XboxCreateDevice+_hardwareadapter selection):main()previously created the referenceComPtr<ID3D12Device> desktopviaD3D12CreateDevicebefore callingD3D12XboxCreateDevice. BecauseX2W_D3D12_DEBUG=1is set in the test environment,D3D12XboxCreateDevice(d3d12_xs_device.cpp) callsD3D12GetDebugInterface->EnableDebugLayer(). On hosts withd3d12SDKLayers.dllinstalled (absent locally and on GH Actions), callingEnableDebugLayer()while a liveID3D12Devicealready exists triggers live-device removal on the process-singleton device.main()now callsD3D12XboxCreateDevicefirst, and only createsdesktopafterward.pick_adapter("hardware")previously only checkedDXGI_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 returns77when no physical FL 12_0 adapter is present.Step + HRESULT diagnostics before every early exit:
fail_step(step, hr, rc)and replaced all bare earlyreturns inmain()andpick_adapter()with explicit stderr diagnostics naming the failing step and HRESULT (plusGetLastError()/CreatePipelineStateHRESULT insidepublish_translated_psoandmake_committed).Pinning
XGCreateTextureComputerMipLevels == 0layout against desktopGetCopyableFootprints(Path 2c):check_xg_mip0_layout(desktop)verifyingXGslot 2 (computer_layout) header/plane/per-mip records (Size,Offset,SliceSize,RowPitch,Width,Height,DepthOrSlices, alignment) againstdesktop->GetCopyableFootprintsand verifyingCopyIntoSubresource(slot 8) byte placement + out-of-rangeE_INVALIDARGacross:32x32RGBA8 2D (MipLevels=0-> 6 mips, all 6 subresources0..5)32x32RGBA8 2D-Array (ArraySize=2,MipLevels=0-> 6 mips x 2 slices = 12 subresources, pinningsubresource % mipsandsubresource / mips+slice_stride = 0x10000)32x8RGBA8 2D (MipLevels=0-> 6 mips)16x1RGBA8 1D-Array (ArraySize=4,MipLevels=0-> 5 mips)8x4x16RGBA8 3D (MipLevels=0-> 5 mips)Local verification (Windows 11, MSVC 19.52, Intel HD Graphics 530; note
d3d12SDKLayers.dllis 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: passedcmake --build --preset release --target d3d12_xs_device_obj d3d12_xs_shim startup_stub_xg_xs startup_ui_texture_bands_check: passedctest --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 5Path 2cchecks)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 5Path 2cchecks)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 failedpython -B tests/docs_links_check.py: passed (107Markdown files,596links)AI-assisted.
Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:17:12Z.
I tested
f73816e8combined locally with #31530530cfafovermaincf3df832(treed2d6086058dc9fcd96c47b2884b78aa43ac6b7bd). The merge was clean. Builtstartup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warpand ranctest --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-chainMipLevels=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, WARP10.0.26100.9818, RTX 4060 Laptop32.0.16.1656, SDK/DXC10.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.Imported from R0Y00/Xbox2Windows. Originally posted by R0Y00 on 2026-11-27T21:24:39Z.
Review: APPROVED
Independently reviewed
f73816e8onmain5b145ca9, which includes #3153 (tree04d7cb57706cae0af0b549f4fc271a24cd262d9b). Builtstartup_stream_consumer startup_ui_texture_bands_check startup_list_copy_texture_warp. Ranctest --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/O2each passed 8/8 with no skips.git diff --check HEAD^1 HEADpassed. Hosted Windows, Linux and gfx1013 checks passed.MipLevels=0produced 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. Windows26200.9974, WARP10.0.26100.9818, RTX 4060 Laptop driver32.0.16.1656, SDK/DXC10.0.26100.0. These are synthetic results. The Windows Server environment and the original executable remain separate observations.