Repository navigation
d3d12: fill the readable smaller mips of a title texture whose larger ones are not there yet (RT-TITLE-PARTIAL-MIPS) - #2166
Conversation
…a title texture whose larger ones are not there The XG layout of a 2D texture of one slice stores its mips from the smallest to the largest, so the mips from m on are a prefix of its footprint (mip_chain_bytes). With LEONIDA_TITLE_PARTIAL_MIPS=1 the readability probe returns the readable prefix (texture_memory_readable_bytes), first_mip_within the first mip it holds; when the last slot-70 view starts there or later, those mips are filled and only the T#s of views that start there or later are published. The others stay on the fallback until a later fill has their mips. A texture not filled, or filled in part, whose pages came through a map change is marked stale so the next pass fills it. Off by default: the image still has memory for every mip. LEONIDA_TITLE_PARTIAL_MIPS_MB (2048) bounds the image memory of the textures filled in part. Unset, the behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gt9hwRYcpySx4P4ncQ3wD5
…-mips # Conflicts: # runtime/shims/d3d12_vulkan_device.cpp
|
I checked the opt-in device path on a physical RTX 4090 (Windows 11, NVIDIA 616.64) at I extended the synthetic
6,144/6,144 RGBA samples matched across eight runs: 64 per view × four views × three updates, repeated with partial mips on/off, staged upload/host image copy, and Vulkan validation on/off. Correction after checking the full process logs: all four validation-enabled runs reached the pixel check with zero validation errors, and each logged one device-destruction message afterward (174–185 Vulkan objects still live). The local test returned immediately after readback. I reran all four validation-enabled configurations on the same runtime revision after fixing the local fixture to retire its images, refresh its descriptor-set handle, and finish normal device cleanup. All 3,072 additional RGBA samples matched. All four processes exited 0 and their complete logs contained no validation messages through device destruction. For the staged runs the test device disabled host image copy. For host copy it enabled the supported feature and set This covers pixel readback for a synthetic single-slice 2D texture. Retail visuals and frame timing were outside this test. AI-assisted verification (OpenAI Codex). |
|
Thank you for the check on the RTX 4090. The table matches what the change is meant to do: views of the smaller mips pick up their data as their pages arrive, the larger ones stay on the fallback, and the published descriptors stay valid without being recreated. It also covers the host image copy path, which my own runs (RTX 5080, staged uploads) did not exercise separately. (Reply written with Claude Code.) |
|
Merge test on an 8 GB laptop (profile M), asked by DadaCap. Main ec91d69 was merged without conflict, in one tree together with #2020. AI-assisted (Claude Code, Claude Opus 5.5).
|
Claimed in the coordination issue as: #1608 (comment)
Depends on: nothing. Conflicts textually with #2021 (
TitleImageUpload::write) and #2050 (d3d12_vulkan_device.cpp); whichever lands second rebases. Merges cleanly with #2122.What and why
A slot-70 texture whose pages are not all readable waits on the fallback until every page is, even when the
smaller mips are already there. The XG layout of a 2D texture of one slice stores its mips from the smallest to
the largest, so the mips from
mon are a prefix of its footprint:mip_chain_bytes(layout, m)bytes from the base.With
LEONIDA_TITLE_PARTIAL_MIPS=1(off by default):texture_memory_readable_bytes,title_texture_memory.h);first_mip_withinturns that into the first mip held with every smaller one(
xg_xs_layout.h).path and the staged
TitleImageUploadtake a first mip), and only the descriptor keys of views that start thereor later are published. Keys of views that start above stay on the fallback (
PendingImage::first_mip), so noshader samples a mip that was not filled. A later fill with more mips publishes them; a filled range is never
left half old (
fill_limit).the next pass fills it instead of the round-robin sweep many passes later.
Unset, the behaviour is the one on
main: a texture is readable only when all of it is, and fills start at mip 0.LEONIDA_TITLE_PARTIAL_MIPS_MB(2048) limits the image memory of the textures filled in part: the image still hasmemory for every mip (a
shortcut:comment says when to make it without the missing ones). The census line gains acount of textures filled in part, their image memory and how much of it is filled.
Why off by default: the VRAM cost. In a 420 s game run of this branch with it on, about 3,000 textures were filled in
part at the end (about 7,400 over the run, 11,200 partial fills, about 800 of them later got their larger mips),
holding about 1.5 GB of image memory for about 315 MB of filled mips. That is a fair trade on a 16 GB card, not on an
8 GB one.
README rows for both switches, and a paragraph in
docs/d3d12_vulkan.mdnext to the deferred slot-70 images.Tested
xg_xs_test, new cases: for tiled (64 KiB and 4 KiB blocks, with a mip tail), odd extents, one mip, a chain tooshort for a tail and linear layouts, the first
mip_chain_bytes(t, m)bytes detile every element of mipsm..exactly as the whole texture does; a larger mip needs a longer prefix and mip 0 the whole texture;
first_mip_withinfinds the largest mip a prefix holds; a cube is readable whole or not at all;texture_memory_readable_bytesstops at a guarded first page. The cases do not build without the change (thefunctions are new).
gta6rtand ranxg_xs,d3d12_texture_memory,d3d12_title_va,d3d12_existing_heap,d3d12_descriptor,title_memory_mapandvulkan_title_image_pool(10 CTest entries with their variants): allpass (MSVC, RelWithDebInfo, Ninja). These run with the switch unset; the device path with it set has no unit test.
mainplus this change), retail title, counts only, 420 s each: withLEONIDA_TITLE_PARTIAL_MIPS=1, three runs, no device loss; the figures above are from the third. No run of thisbuild with the switch unset (that path is
main's). The census line needsLEONIDA_FSDRAW_PROBE=1(or any probe that enables it) to be printed.A picture comparison was not made: whether a texture now shows its smaller mips instead of the fallback was not
checked by eye.
GPUs tested: NVIDIA GeForce RTX 5080, driver 621.24, Windows 11 (unit tests and the game observation).
AI-assisted: yes (Claude Code).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code