ScarletNX / ScarletNX documentation / Regression inventory for the buffer cache rewrite · ← previous · next →
Results that the GPU writes (2)
- Without the rule: the copies wrote the bytes of a range two times on the CPU before its draw and compared all of
them after it, even when the CPU never read them. The rule needs a host with traps, a range of whole pages in one
run of guest memory, no unified memory, and a range that the CPU did not make land in the last 1200 presents.
- Comment:
buffer.c, above KEEP_CPU_PRESENTS (the code is keep_new).
- Check:
check_storage_buffer_keep in tests/vulkan_storage_buffer_keep.inc.
R27. A kept result is written again in place only while its owner still holds the whole range.
- Without the rule: a CPU touch lands the owner and lets go of it. A draw that writes it again would write bytes
that nothing lands.
- Comment:
buffer.c, above keep_intact.
- Check:
check_storage_buffer_keep, the case of a CPU read before the fence.
R28. On unified memory, a logged result that cannot be written in place is written back on the GPU after its
dispatch.
- Without the rule: such a result waited in staging for the CPU to land it. One game binds 16 MiB windows of a
tensor pool, and the last reaches 185 KB into the GPU-owned span of a movie frame. The next dispatch could not
tell if the CPU wrote the window, so it landed it with a
vk_finish, 72 ms each time, about two times a frame.
- Comment:
buffer.c, above the BACK_IMPORT enum (the code is back_record).
- Check:
check_uma_logged_back in tests/vulkan_uma_imports.inc.
R29. On unified memory, a shader writes guest memory in place, but not over bytes that the GPU holds in another
place.
- Without the rule: owned bytes, a compute or storage image result and a queued release must land first. A write in
place would be under them.
- Comment:
buffer.c, copy_writable.
- Check:
check_uma_writes and check_uma_feedback in tests/vulkan_uma_imports.inc.
R30. The staging of a write-only logged binding is filled with zeros by the GPU.
- Without the rule: the stores are partial. The GPU reads the cache line around a store, and uninitialized ring
memory there can hang the GPU. A
memset by the CPU of up to 16 MiB a binding was a twentieth of one game's GPU
thread.
- Comment:
buffer.c, copy_writable.
- Check: no test covers it.
R31. All the bindings of a draw that aliases a writable page index one page atlas.
- Without the rule: a write through one GPU address must reach the same word through the other, also with fragmented
mappings. The alias question is answered from the page ranges first. The sorted page list for every draw with
storage was a twentieth of the GPU thread in one game.
- Comment:
buffer.c, above vk_buf_draw_prepare and above draw_may_alias.
- Check:
check_draw_storage_stages in tests/vulkan_draw_storage_stages.inc.
- With unified memory (unless
uma_copies=2), the group binds in place instead: each binding at its
own offset in the one region that holds them all, with no map and no output (alias_in_place). The shader declares
its global buffers Aliased when it has two or more. A group that one binding keeps out of place goes to the atlas,
and the writes in place it bound are undone. Nothing in that branch waits. Checks: check_uma_alias_* in
tests/vulkan_uma_imports.inc, check_alias_shader and check_uma_alias_order in tests/vulkan_nvn_storage.inc.
R32. A range that one owner holds whole binds where the owner is.
- Without the rule: the range was copied, and each such draw ended the rendering pass, about 22 of the 380 of a
frame in one game. Before that, draws over the results of the GPU engines landed them, a wait for the GPU each.
A range with owned parts is copied into the device ring. It is not hashed and gets no buffer of its own, because
the CPU copy of the owned bytes is stale.
- Comment:
buffer.c, above buf_get_owned.
- Check:
check_pass_breaks in tests/vulkan_pass_breaks.inc, and check_dma_owners in tests/vulkan_headless.c.
R33. A read over program writes that the mirror holds reads them in the mirror.
- Without the rule: a landing took a submit and a wait for the GPU, 150 a second in one game's menus. At an offset
that the use cannot bind, the GPU copies the bytes from the mirror into device memory. Bytes that the mirror owns
are read there too. Read in another place, the CPU bytes between them were copied again for every draw, 16 MiB a
binding, about half of one game's GPU thread.
- Comment:
buffer.c, buf_get.
- Check:
check_mirror in tests/vulkan_mirror.inc, the case of constants over a pending program write.
R34. A result that covers a range only in part lands before the cached copy is used.
- Without the rule: the cache would use its copy without the bytes of the result.
- Comment:
buffer.c, buf_get, and compute.c, vk_compute_gpu_src.
- Check: no test names the partial case for the buffer cache.
R35. A write-back of a render target keeps the pages that the CPU wrote after the draws of the target.
- Without the rule: a game uses the memory of a target again when its sync wait says that the GPU is done. One game
records command lists where a target was. A GPU write beside the target wrote it back over the records of a queued
job. The cost of the page rule is that a page written between two draws loses the pixels of the later draw.
- Comment:
surface.c, above CPU_RUNS.
- Check:
check_wt_hot_page and check_wt_hot_same_frame in tests/vulkan_write_tracking.inc.
R36. The CPU runs of a write-back count from the moment when the image last matched memory.
- Without the rule: the draw baseline alone missed a target that a copy changed after a load, with no draw.
- Comment:
surface.c, above run_newer (the code is cpu_newer).
- Check:
check_wt_hot_rt_overlap in tests/vulkan_write_tracking.inc covers the baselines of two targets.
R37. A write-back takes a new baseline after it, and tells the tracker which pages it wrote.
- Without the rule: the writes of the write-back counted as CPU writes. Where pages were kept for the CPU, the image
is not memory there, so the target takes no baseline and loads from memory at its next use.
- Comment:
surface.c, flush_rebase and run_landed.
- Check:
check_wt_hot_page in tests/vulkan_write_tracking.inc.
R38. Before a target lands, the older pending targets over its bytes land first, and newer ones stay on top.
- Without the rule: memory that was freed and given to a new target still has the pixels of the old target pending.
The bytes must land in the order in which the GPU of the console wrote them.
- Comment:
surface.c, rt_pending_over and rt_flush_older.
- Check:
check_rt_overlap in tests/vulkan_headless.c.
R39. A landing under a newer target, also one at another GPU address of the same memory, is not a write for that
target.
- Without the rule: one game maps one physical pool through several virtual pools. A shadow map that landed late
left the newer target with the look of a written one. Its next use loaded the old bytes over its pixels, and a
whole frame of a cutscene showed pieces of old frames.
- Comment:
surface.c, above rt_newer_over.
- Check:
check_alias_newer_target in tests/vulkan_headless.c.
R40. Before a producer publishes an owner over memory, every older image over that memory lands.
- Without the rule: a later read of part of an old image can write its old pixels over the result of the producer.
- Comment:
surface.c, vk_rt_before_write_cpu.
- Check:
check_alias_newer_target covers the order for a compute result. No test names the function.
R41. The result of a storage image is published over its guest bytes and waits for nothing.
- Without the rule: each write waited for the GPU. A 3D volume that a game writes two times a frame and only
samples took a wait each time, a fifth of the run.
- Comment:
surface.c, above surf_publishable (the code is vk_surf_publish).
- Check:
check_storage_image_keep in tests/vulkan_storage_image_keep.inc.
R42. A publish stamps only the bytes of the layers of the image itself.
- Without the rule: the bytes between the layers keep their owners, but they were stamped written. One game writes
each level of its reflection cubes through a view whose layers are a whole mip chain apart. Every view and every
cube loaded all its memory again each frame, 30 uploads and 12 MB.
- Comment:
surface.c, above publish_own.
- Check: no test covers it.
R43. The pending targets inside a published span are retired, and are not flushed again.
- Without the rule: the publish flushed each one again, a wait for the GPU and a readback. One game draws four
32x32 targets of 256 KB and writes them with a compute program every frame. That was four waits and four landings
a frame.
- Comment:
surface.c, above rt_retire_over.
- Check: no test covers it.
R44. The span of a storage image that a draw writes is GPU owned from the bind on.
- Without the rule: the write-back read all the bytes on the CPU before the draw and copied the image back after
it. The conditions are those of R26. A span that the CPU touches every frame would trap and wait for the GPU each
time.
- Comment:
surface.c, above KEEP_CPU_PRESENTS (the code is vk_surf_keep_begin).
- Check:
check_storage_image_keep in tests/vulkan_storage_image_keep.inc.
R45. A release publishes the pitch-linear color targets drawn since the last release, and watches the
block-linear ones.
- Without the rule: the CPU cannot ask for the pixels. One game draws its ambient light into seven 8x8 RGBA32F
targets and reads them after a fence. It lit its scenes with the old bytes, values up to 1e31. Another game draws
the thumbnail of its save into a 320x180 block-linear target and reads the texels with no call to the GPU. A
publish of every block-linear target would copy tens of megabytes a frame, so those are watched.
- Comment:
surface.c, above DrawnList.
- Check:
check_rt_watch in tests/vulkan_headless.c.
R46. A target whose load failed has undefined contents and is never written back.
- Without the rule: the image holds old pixels or some bands of the new ones, and a write-back puts them over
memory.
- Comment:
surface.c, rt_reload.
- Check: no test covers a failed load.
R47. A dispatch reads a read-only input through the buffer cache.
- Without the rule: the inputs were copied whole at every dispatch. That was nearly all of one game's GPU thread,
whose passes read four buffers for each one that they write.
- Comment:
compute.c, res_bind.
- Check:
check_stream_epoch in tests/vulkan_headless.c covers the strict lookup. No test counts the copies of a
dispatch.
R48. A dispatch that writes an owner in place stamps the owner with its submission.
- Without the rule: no publish follows such a write. A landing of the range must wait for the submission that
records the write, also on a compute queue of its own.
- Comment:
compute.c, res_wrote, and owned.c, vk_own_res_wrote.
- Check:
check_owned_in_place_write in tests/vulkan_owned_readback.inc.
R49. A read-only input inside a pending result of the same batch is read from the arena after a barrier.
- Without the rule: the result landed first. Skinning in several passes reads what the pass before wrote.
- Comment:
compute.c, vk_dispatch.
- Check: no test covers it.
R50. Each dispatch that marks its stores binds the write log.
- Without the rule: the atomic OR of the stores reads a descriptor that was never written, an Xid 13 on NVIDIA.
- Comment:
compute.c, vk_dispatch.
- Check:
check_mirror_fold in tests/vulkan_mirror.inc binds a log. No test runs a dispatch with no log bound.
R51. A buffer that is written and not logged still gets its input copied in.
← previous · next →