ScarletNX / ScarletNX documentation / Regression inventory for the buffer cache rewrite · ← previous · next →
Memory limits and the trim
M1. A frame with no present ends when it wrote VK_FRAME_RING_CAPS allocations to its rings.
- Without the rule: the chunks and big buffers of a frame come back only with its slot. A game's load that drew
with no present for 8 s kept every ring that it made. GPU memory went from 270 to 1062 MiB, and a phone's system
ended the app at its 4 GiB limit.
- Comment:
cmd.c, above frame_rings (the code is frame_check).
- Check:
check_rings_without_present in tests/vulkan_headless.c.
M2. The bands of a copy that is too big for one allocation also run the frame check.
- Without the rule: nothing is set up between two bands, so no draw ended the frame. The upload of the eight levels
of an 8192x8192 RGBA8 texture wrote 1365 MiB to the rings of one frame.
- Comment:
cmd.c, above frame_rings.
- Check:
check_dma_bands_frames in tests/vulkan_headless.c.
M3. On a GPU that shares the memory of the system, a frame ends at an eighth of the budget in its rings.
- Without the rule: the rings are memory that the caches budget there. The limit is never less than two chunks, and
the code asks for the budget only past those two.
- Comment:
cmd.c, above frame_ring_cap.
- Check:
check_rings_budget_share in tests/vulkan_headless.c, and the ctest vk_uma_budget.
M4. The frame check does not end a fresh frame.
- Without the rule: a fresh frame recorded nothing, and its counts are still those of its last use. An end would
only move on to the slot whose work was just submitted, and wait for it.
- Comment:
cmd.c, frame_check.
- Check:
check_fresh_frame_kept in tests/vulkan_headless.c.
M5. A frame with many submissions, descriptor pools or descriptor tables ends at the start of a draw.
- Without the rule: a loading screen with no present never hands its pools and rings back. The limit on submissions
leaves room for the submits of W3. A frame that reaches it records the rest in the other slot.
- Comment:
cmd.c, above frame_rings.
- Check:
check_descriptor_room in tests/vulkan_headless.c.
M6. A source of the copy engine past a sixty-fourth of the budget does not take a buffer of its own at once.
- Without the rule: the upload of a texture reads its source one time. The levels of an 8192x8192 RGBA8 texture
took 760 MiB of own buffers that nothing read again, where a phone had 1 GB available. Such a source takes a
buffer when it stays the same, as each other range does.
- Comment:
buffer.c, buf_get, at at_once, and copy_src_at_once.
- Check:
check_dma_source_kept_when_stable in tests/vulkan_headless.c.
M7. The readback buffer grows to the biggest readback and shrinks again after many small ones.
- Without the rule: the comment gives no failure. A readback past the allocation cap is read back in parts.
- Comment:
cmd.c, vk_readback_buffer.
- Check:
check_flush_parts in tests/vulkan_headless.c covers a readback in parts. No test covers the shrink.
M8. The freed buffers of owners go to a pool of at most 512 entries.
- Without the rule: each published storage image made one buffer with an allocation of its own, about 24 a frame
in an Ounce game's race. A publish now takes the nearest freed buffer of at least its size.
- Comment:
owned.c, above OWN_POOL_MAX.
- Check: no test covers the pool.
M9. A write log that is free for 600 presents goes.
- Without the rule: the pool kept what the dispatches in flight took at their peak. One game peaked at 290 MB of
host memory for them while it loaded.
- Comment:
writelog.c, above WLOG_IDLE (the code is vk_wlog_trim).
- Check: no test covers it.
vk_wlog_stats gives the bytes.
M10. The room of the mirror harvest follows what the last submits wrote.
- Without the rule: every page of room takes 4.5 KiB of the readback ring at each submit that wrote a page. Kept at
the most that it ever was, one game's harvests took 2.6 GB of the ring every 10 s for a few pages each. A page
past the room takes a pass of its own that waits for the GPU, and the room grows at once.
- Comment:
mirror.c, above MIR_ROOM_MIN.
- Check:
check_mirror in tests/vulkan_mirror.inc, the case of more pages than the room. vk_mirror_stats
gives the room.
M11. A device whose maxBufferSize is below the address space makes the mirror only with the setting, and never
under the validation layer.
- Without the rule: a buffer past the limit is invalid, though RADV makes it and runs it sparse. With no mirror the
results land through the CPU. The report of the validation layer would be above the errors that it must show.
- Comment:
mirror.c, vk_mirror_on.
- Check: no test covers it.
M12. A surface whose pixels can be had again goes back from the aged list to the first list.
- Without the rule: an eviction that takes only lossless surfaces would not find it, and the idle eviction would
keep it for five minutes.
- Comment:
surface.c, above vk_surf_relist.
- Check: no test covers it.
M13. An evicted render target is not written to guest memory.
- Without the rule: memory is shared by targets that the GPU drew over one another, and by textures and buffers
that copied from them. The renderer does not know them all. A write of an evicted target's pixels, which a game's
Mii icons wanted, put older pixels over newer ones in another target. The result was a black block over the
player character, and red and green blocks over its textures. A surface with a storage image result still to land
is passed over.
- Comment:
surface.c, surf_reclaim.
- Check: no test covers it.
M14. A target that memory does not hold goes only under budget pressure when nothing lossless is left, or after
minutes with no use.
- Without the rule: its pixels are lost. A target that holds a draw which a later texture at its address would take
goes only under budget pressure. Age does not make guest memory the truth, because a generated texture can be
sampled first several frames after its draw.
- Comment:
surface.c, surf_reclaim, above keeps_drawn, above lossless, and vk_rt_drawn_in.
- Check: no test covers the lossy steps.
M15. A target that later targets drew all over goes first, with no loss.
- Without the rule: a game with dynamic resolution makes its scene targets again at another size each frame over
the same memory. Each old one held a draw that memory never got, so it was kept as precious. A few thousand took
the budget from the targets that are. One game's ink maps, drawn one time at the start of a level, went under
that pressure with a lowered budget, and its walls took no ink.
- Comment:
surface.c, above rt_superseded.
- Check: no test covers it.
M16. The trim frees the working set only to stay half a head under the budget, and only what is unused for
eight presents.
- A head is a sixteenth of the budget, 128 MiB at least and 256 MiB at most (
trim_head). The trim starts a head
under the budget. What is unused for a second goes down to two heads under it. Lossy surfaces go only within a
head and within half a head of it.
- Without the rule: a trim of the working set to 80% made one game load hundreds of textures and targets again
every 600 presents under a lowered budget. With two presents the trim took textures that a game uses every few
frames. Of 3,000 that it evicted in one game's menus, 2,358 were unused for three presents, and each came back at
once with a BC7 encode.
- The marks were shares of the budget before: a start at 90% and a stop at 80%. Each trim then emptied a tenth of
the GPU's memory. In one game's race, with the budget set to 4200 MB, the fixed head and M16a together took the
textures made again from 3.4 to 2.5 for each present (three runs of each, 300 s).
- Comment:
surface.c, vk_mem_trim and trim_head.
- Check:
check_trim_working_set in tests/vulkan_trim.inc.
M16a. A texture whose texture object the game ended goes before any texture that the game still has.
- The front end counts the live texture objects at each address (
gpu/guest_textures.h). When the last object at
an address ends, the cache puts the textures at that address on a list (ended_collect).
- A trim takes the textures of the list first, when memory can give their pixels again and two presents passed.
- While four fifths of the budget are in use, such a texture also goes two seconds and 30 presents after the end
of its object (
vk_surf_ended_frame). With memory to spare it stays until it ages out. One game ends textures
and makes them again at the same address some seconds later.
- A texture at whose address the game made an object again leaves the list.
- Comment:
surface.c, ended_reclaim and vk_surf_ended_frame.
- Check:
check_trim_ended in tests/vulkan_trim.inc, and tests/guest_textures.c for the list of ended addresses.
M17. A forced trim runs at most one time in a present.
- Without the rule: what a trim frees is released when the frame is done. A second trim in the same present would
find the same shortfall and take more.
- Comment:
surface.c, vk_mem_trim.
- Check: no test covers it.
M18. An image bigger than the whole heap is never made, and an image as big as one that failed is not tried
again in the present.
- Without the rule: a garbage size in a header emptied the caches for nothing. After a failure, what was freed is
released only when the frame is done, so the same try fails again.
- Comment:
surface.c, vk_cache_image_create.
- Check: no test covers it.
M19. A scaled target past the allocation cap gets room under the budget.
- Without the rule: a 4x scale of 4K is 506 MiB in RGBA8, and the create fails. The caller holds only surfaces that
it used in this present, and those stay.
- Comment:
surface.c, surf_create_.
- Check: no test covers it.
M20. A trim that finds the images short of memory suggests astc_textures=2 in the log, one time in a run.
- Without the rule: a game on a GPU that samples BCn and not ASTC stays slow by eviction, and the log does not say
why. The comment defines "short".
- Comment:
surface.c, above astc_bc_suggest.
- Check: no test covers the message.
← previous · next →