textures: detile opt-in BC7 backing for startup draws #1253
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1260"
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 Jess-Doit on 2026-11-24T05:56:37Z.
Change
Refs #1140. Depends on #1243. The opt-in BC7 4 KiB tiled profile now supports
CopyIntoSubresourcewithX2W_D3D12_RENDER=1when the companion D3D12 stand-in is loaded.Because the desktop texture is larger than the title's when a dimension is not a multiple of 4 (81×69 becomes 84×72), a normalized coordinate addresses a slightly different texel than on the console. Texel loads and the visible pixels compared here are unaffected; sampling near the right or bottom edge of such a texture is not covered.
BC7_UNORMwith unknown layout, default alignment and no resource flags. Render-mode copy without the companion stand-in still returnsE_NOTIMPL.Fixture
startup_xg_bc7_draw_{warp,hardware}draws source-built position-tagged BC7 through the wrapped stream pipeline, with a linear upload and a real XG tiled copy for each size. Each draw is compared to a CPU reference for all 4,096 pixels of the 64×64 surface and all 5,589 visible pixels of the 81×69 surface. The larger case crosses both tile boundaries and uses padded desktop upload rows.For the bypass control, replace the
bc7.detile(...)call inupload_texturewithstd::memcpy(rows, memory, static_cast<std::size_t>(bytes < bc7.size() ? bytes : bc7.size()));. Rebuildstartup_stream_consumerwithcmake --build --preset $preset -j 2 --target startup_stream_consumerand runctest --preset $preset --no-tests=error -R '^startup_xg_bc7_draw_' -V. Both tests failed as expected in Debug and Release. The linear readbacks still matched. For both tiled sizes, the first mismatch on both adapters was pixel(4, 0), RGBA bytes00 06 18 3cinstead of08 00 18 3c.Verification
Tested
5efd401fon copy-branch basec49b4c24(includes main7a4043e4and the sampler-heap changes). Windows 10 22H2 build19045.6456, MSVC x6419.44.35230.0.32.0.15.609410.0.19041.5794Both full builds completed. The counts are from the focused suite after restoring the detiler. The suite covers the BC7 layout and draws, stream requests and draws, sampler-heap tests, startup stubs, XG swizzle controls and GFX10 texture round-trips. On both adapters, the linear and tiled uploads matched the CPU pixels for both sizes. The initial fixture run reported D3D12 warning 820 for clearing a target without an optimized clear value. The fixture now supplies the matching clear value.
Build with a Python environment containing
requirements-dev.txt. Provide the pinned Mesa AddrLib for the optional swizzle comparisons as described indocs/experiments.md.AI-assisted (Codex).
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T06:04:09Z.
Review: COMMENTED
Dual-platform peer review at
5efd401fc9e7f8759c5bcf1c8bfa6a7f949aa2ef:Checks
x2w-rev-venv):git diff --check HEAD~1..HEAD— passedpython -B tests/docs_links_check.py— passed (16 Markdown files, 281 links)python -B tests/bidi_controls_check.py— passed (1053 tracked files)python -B tests/bc7_blocks_check.py— passed (8 passed, 2 skipped)python -B tests/bc7_tiles_check.py— passed (6 passed)python -B -m py_compile tests/startup_stream_draw_check.py tests/startup_xg_bc7_draw_check.py— passedstartup_stream_consumer,d3d12_xs_shim,startup_stub_xg_xsctest --preset dev --no-tests=error -R '^startup_(xg_bc7_|stream_draw_warp|stream_request_warp)': 5/5 passed (startup_xg_bc7_layout,startup_stream_request_warp,startup_stream_draw_warp,startup_xg_bc7_draw_warp,startup_xg_bc7_draw_hardware)ctest --preset release --no-tests=error -R '^startup_(xg_bc7_|stream_draw_warp|stream_request_warp)': 5/5 passed (same 5 tests)Review Notes
Bc7Surfaceandsupports_bc7_4k_sintosrc/startup_stubs/bc7_4k_s.hcleanly shares the GFX10 4 KiB BC7 geometry and detiler betweenxg_xs.cpp,d3d12_xs_device.cpp, andd3d12_draw.inl.upload_textureinsrc/startup_stubs/d3d12_draw.inlvalidates the original console desc, dimensions, format, andSliceFootprintslayout before detiling, and tracksstate.tiled_bc7alongsidehashandgenerationso alternating linear and tiled writes at the same title address cannot hit a stale upload cache entry.tests/startup_xg_bc7_draw_check.pycovers both block-aligned (64x64) and unaligned (81x69) dimensions across bothlinearandtiledlayouts against a pixel-exact CPU reference.reserve_upload_ringinherits thering_bytes / 4(64 MiB) single-allocation cap andupload_texturecallsstd::memseton the write-combined upload ring slice beforebc7.detile; both are fine for the tested fixtures and typical single-mip BC7 surfaces within 64 MiB.