mirror of
https://github.com/tangerineturtle1/NX2navi.git
synced 2026-11-18 06:59:57 -04:00
Add texture compaction behind NX2NAVI_TEX_COMPACT, off by default.
With the setting on, textures no shader sampled for ten seconds are copied on the GPU out of the emptiest allocator blocks into the holes of fuller ones, so the emptied blocks go back to the driver. A pass starts when the free space inside the device-local blocks reaches NX2NAVI_TEX_COMPACT_MIN_MB (one block under VRAM pressure) and the block table has blocks that hold nothing but such textures, with room elsewhere for what moves. It takes at most four textures and NX2NAVI_TEX_COMPACT_FRAME_MB a frame, and none in a frame that loads an area, already made or uploaded textures, or follows a long one. A released texture the size cap would drop is dropped instead of moved. Only a texture whose image holds what the game's memory holds moves: uploaded, never written by the GPU, single sampled, not depth. The entry takes the new image under the texture lock and its address generation moves, so every slot, pool descriptor and memo resolves again. The old image and its views stay until the texture pool has taken every set of its ring and the GPU is past the submissions recorded until then, as a retired texture's do. Each pass logs what it moved and dropped, the blocks and bytes given back, and the time it took. A block emptied of textures that the allocator keeps is left alone for ten minutes, and a pass that gave nothing back doubles the wait. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
@@ -253,6 +253,13 @@ keeps per-core data without locks and relies on that, so the host models it (`ru
|
||||
starts at, and uploads, views and sampler LOD clamps count from there. A texture a shader reads by texel position, or
|
||||
whose size it uses, is made whole (`gfx_shader.c` `reflect_exact`). `auto` picks by the device-local budget.
|
||||
- Occlusion queries never block the CPU; a result that is not ready counts as visible.
|
||||
- Holes in video memory: the allocator takes device memory in blocks and gives a block back only when it is empty,
|
||||
so a long session leaves textures scattered between holes the driver still counts. The log's `mem: holes` line
|
||||
says how much that is and how much could come back (`vk_memory.c` `holes_log`). With `NX2NAVI_TEX_COMPACT=1`
|
||||
(off by default) textures no shader sampled for ten seconds are copied on the GPU out of the emptiest blocks into
|
||||
the holes of fuller ones, a few per frame and only in frames with time to spare; which blocks is decided from a
|
||||
table of what lies in them (`vk_tex_compact.h`), and the old image of a moved texture stays until no descriptor
|
||||
set and no submission can still name it (`vk_texture.c`, "the pass").
|
||||
- Allocation: Vulkan Memory Allocator. Debugging: Vulkan validation layers, per-pass frame dumps (`NX2NAVI_DUMP`,
|
||||
`vk_dump.c`), a sampling profiler (`NX2NAVI_PROFILE`, `tools/prof_report.py`) and a flight recorder
|
||||
(`NX2NAVI_FLIGHT`). RenderDoc cannot capture, because it hides `VK_EXT_external_memory_host` from the application.
|
||||
|
||||
@@ -638,8 +638,8 @@ A change to how the holes in the allocator's blocks are counted or to which bloc
|
||||
(`runtime/vk_tex_compact.h`: `tcp_tally`, `tcp_stats`, `tcp_plan`) passes `python tests ex_compact_check.py`, which
|
||||
builds the header alone: a block with one allocation that stays is never chosen, the block that takes the fewest moved
|
||||
bytes goes first, what moves fits the free bytes outside the chosen blocks, a plan under its smallest gain is no plan,
|
||||
and 400 random tables keep those rules. The part of `runtime/vk_texture.c` that builds the table is not built by it.
|
||||
No GPU, no game files.
|
||||
and 400 random tables keep those rules. The part of `runtime/vk_texture.c` that builds the table and moves the images
|
||||
(`NX2NAVI_TEX_COMPACT`) is not built by it. No GPU, no game files.
|
||||
|
||||
A change to which frames FSR 3.1 frame generation is told are camera cuts (`runtime/vk_fg_reset.h`, `runtime/vk_fg.cpp`
|
||||
`generate` and `vk_fg_frame`) passes `python tests\fg_reset_check.py`, which builds the header alone and checks that each
|
||||
|
||||
Reference in New Issue
Block a user