ScarletNX / ScarletNX documentation / Regression inventory for the buffer cache rewrite · ← previous · next →
Waits for the GPU
W1. The setup of a draw or a dispatch does not submit and does not wait for the GPU.
- Without the rule: a wait lands results into guest memory that the setup possibly read before. When the submission
number changed during the setup, the setup starts again. The frame check runs before the setup for this reason. A
hash of a target reads the backing memory directly, because
gmem_read could submit a draw in the middle of a
setup.
- Comment:
cmd.c, above frame_rings and above vk_submit_upload_wait. compute.c, vk_dispatch. surface.c,
above rt_mem_hash.
- Check:
check_descriptor_room in tests/vulkan_headless.c.
W2. A read of guest memory under results waits only for the newest submit that holds one of them.
- Without the rule: the comment gives no failure. With the rule the GPU goes on with what came after. Only a
result in the commands that are being recorded makes the read finish them all.
- Comment:
buffer.c, mem_need_reason.
- Check:
check_landing_wait in tests/vulkan_lock_waits.inc covers a wait for one submission.
W3. What is recorded goes to the GPU when it holds a millisecond of the work of the GPU thread.
- Without the rule: submissions came only when something needed results. In one game the GPU sat idle through the
first 12 ms of the 21 ms of a frame, then got all of it at the end and finished 6 ms after the GPU thread. The
game ran at 34.7 fps, and at 40.3 with the rule. Limits of 2 ms and 0.5 ms were both slower. Earlier submissions
also land their results sooner, so fewer results are pending at a lookup.
- Comment:
cmd.c, above frame_rings (the limit is the vk_submit_every setting, a count of draws, dispatches and
copy bands since the last submission, the code is frame_check). It replaced a limit of a millisecond of
recording (SUBMIT_EVERY_NS).
- Check:
check_pass_breaks has a case that depends on this submit. No test holds the limit.
W4. Each submit lands the results of the submissions that the GPU finished.
- Without the rule: a later release found them pending.
- Comment:
cmd.c, submit.
- Check:
tests/vulkan_release.c runs releases against completed submissions.
W5. A wait for work that is already done is not counted as a stall.
- Without the rule: the wait statistics blame waits that cost nothing.
- Comment:
cmd.c, timeline_wait.
- Check: no test covers it.
check_stats_gpu_time covers other statistics.
W6. A wait for the GPU runs in slices of a second, and the run ends when the GPU is stuck for 15 s (120 s where the
GPU is the CPU).
- Without the rule: a stopped GPU signals nothing, and the driver did not report a lost device. The frontend and the
release thread waited for good, and one game's window froze with no message. The clock of the wait runs only while
the queue holds work that the GPU did not do. In one race on a loaded host a thread waited past 15 s for a
pipeline with the GPU idle, and the run ended as "GPU stopped" with nothing for the GPU to do. A lost device also
ends the run, because the next Vulkan call would crash in the driver and the log would blame the game. lavapipe
compiles a program at its first dispatch, inside the submission: on a loaded CI runner the BC7 encoder's first one
finished nothing for 15 s, and the run ended as "GPU stopped" while LLVM still compiled.
- Comment:
cmd.c, above VK_GPU_STUCK_NS and VK_CPU_STUCK_NS, and vk_wait_semaphore.
- Check:
astc_vulkan_encode_dot on lavapipe on a slow host. No test covers a GPU that stops.
W7. Each vk_finish is counted by its call site, with its time.
- Without the rule: one game made nine a frame, each a round trip with the GPU idle after it, and nothing showed
where they came from.
- Comment:
cmd.c, above FINISH_SITES.
- Check:
vk_finishes_log. Several checks of vulkan_headless read the finish count.
W8. A draw that aliases a writable page copies the pending results into its atlas on the GPU.
- Without the rule: the draw waited for earlier results to land in guest memory. One game drew about four such
draws a frame, each a landing of everything with a
vk_finish. A result whose original bytes the guest wrote
since still lands first, and the draw starts its setup again.
- Comment:
buffer.c, above out_near_atlas (the code is atlas_fill).
- Check:
check_draw_storage_stages in tests/vulkan_draw_storage_stages.inc.
W9. A draw reads its bytes past the samples-passed reports that are queued over them.
- Without the rule: a read of the bytes as they are waited for the GPU to run everything recorded up to the reports.
The GPU writes the counts where the bytes go.
- Comment:
buffer.c, above draw_bytes.
- Check:
pb_samples_case in tests/vulkan_pass_breaks.inc draws with queued reports. It is not confirmed that
the case reads draw bytes under a report.
W10. The reads of the mirror take one barrier after the program writes, not one for each binding.
- Without the rule: a barrier for each binding ended the rendering pass at nearly every draw. One game's race had
about 470 passes a frame, and the GPU drained at each, 30 ms a frame. In
mirror.c a binding that recorded no
copy also takes no barrier. With one for each, two thirds of the passes of one game's run on another GPU ended
there.
- Comment:
buffer.c, buf_get, at barrier_gen, and mirror.c, vk_mirror_slice.
- Check: no test counts the passes of mirror reads.
check_pass_breaks counts passes for other copies.
W11. A compute batch is submitted when something needs it and lands when something needs its results.
- Without the rule: each batch landed at its submit with a fence wait, 4 waits a frame in one game.
- Comment:
compute.c, above CsBatch.
- Check: no test counts the waits.
W12. A constant buffer under a pending in-place write is copied for the dispatch on the GPU, after the write.
- Without the rule: the CPU read waited for the submit. One game's dispatches bound 256 bytes of such constants one
time a frame. The wait held the GPU thread for about 18 ms of each frame with the GPU idle behind it. The CPU
still reads the words that a translation depends on.
- Comment:
compute.c, above g_cb_later.
- Check:
check_uma_dispatch_constants in tests/vulkan_uma_imports.inc.
W13. A dispatch on the graphics queue binds as a draw does, and its results stay pending.
- Without the rule: each one landed at once with a
vk_finish, about 9 a frame in one game.
- Comment:
compute.c, vk_dispatch, at deferred.
- Check:
check_uma_dispatch covers a dispatch on the graphics queue. No test counts the finishes.
W14. A dispatch of storage buffers alone keeps them on the GPU where the host traps guest memory.
- Without the rule: on the compute queue each result landed at the next dispatch that read it. One game's passes
update the same buffers dispatch after dispatch. It waited for the GPU at nearly every one and ran at about 14
frames a second on any machine.
- Comment:
compute.c, vk_dispatch, at resident, and above res_bind.
- Check:
check_owned_in_place_write in tests/vulkan_owned_readback.inc.
W15. A range that the CPU made land in the last 1200 presents is not kept on the GPU.
- Without the rule: each CPU read of a kept range trapped and waited for the GPU. One game reads its compute results
every frame. It had 34,000 landings in two minutes, and its frame rate fell from 54 to 39. The same limit serves
the writable bindings of draws and the storage images.
- Comment:
compute.c, vk_dispatch, and above CS_CPU_READ_PRESENTS. owned.c, above cpu_read_note.
buffer.c and surface.c, at KEEP_CPU_PRESENTS.
- Check:
check_storage_buffer_keep in tests/vulkan_storage_buffer_keep.inc, the case of a range that the CPU
wrote lately.
W16. A dispatch whose storage buffer is under a pending result of a draw runs on the graphics queue.
- Without the rule: the compute queue waited for the result to land, three times a frame in one game.
- Comment:
compute.c, vk_dispatch.
- Check: no test covers it.
W17. A deferred dispatch is submitted at once, but a dispatch in the mirror is not.
- Without the rule: a reader of the results waited for the draws recorded after the dispatch. One game writes
command lists with a dispatch and fetches them a little later, one time a frame. In the mirror the results land
only where the CPU first touches them. Submitted each, one game's Ounce programs made about 300 submissions a
present, each with a harvest, and the GPU idled between them.
- Comment:
compute.c, vk_dispatch.
- Check: no test counts the submissions.
W18. Where the device has a compute queue of its own, a landing copies there and waits only for the writer's
submission.
- Without the rule: the copy waited behind every submission queued after the writer. One game's landings waited 30
to 130 ms.
- Comment:
owned.c, above land_apart.
- Check:
check_owned_in_place_write in tests/vulkan_owned_readback.inc.
W19. A landing never waits for a submission value past the last submission.
- Without the rule: an owner with no stamp, or one stamped while nothing was recorded, gave a value that is never
signaled. The wait never ended.
- Comment:
owned.c, own_land.
- Check: no test covers it.
W20. The pending counts of mirror pages stay right when two written ranges overlap.
- Without the rule: the pages of two buffers that overlap stayed pending for good, and each CPU read of them waited
for the GPU. The joined ranges take their count before the written ranges lose theirs.
- Comment:
mirror.c, vk_mirror_harvest.
- Check:
check_mirror_fold covers two buffers of one dispatch. No test reads the count after the batch.
W21. A mirror page that the CPU touched lately comes back with its bytes at each submit.
- Without the rule: the page was published again at each submit and landed at each CPU touch. One game's CPU writes
pages beside the results of its programs each frame. That was about 180 landings a second, each a copy and a wait
for the GPU on the thread that touched the page.
- Comment:
mirror.c, vk_mirror_harvest, and above MIR_HOT_PRESENTS.
- Check:
check_mirror in tests/vulkan_mirror.inc, the case of a page touched lately.
W22. The mirror pages that the CPU did not touch stay GPU owned and do not land at each submit.
- Without the rule: a landing of each written page at every submit took most of the GPU thread in one game's menus,
for pages that the CPU mostly never read.
- Comment:
mirror.c, above own_entries.
- Check:
check_mirror in tests/vulkan_mirror.inc, the case of a page that is not landed.
W23. The run ends of a mirror page mask are found a word at a time.
- Without the rule: found a bit at a time, the runs of the 24,000 pages that one game's upscaler writes in a frame
took about 30 ms of the 51 ms of their landing. A GPU with no memory traps lands every page.
- Comment:
mirror.c, above run_end.
- Check: no test covers the cost.
W24. A dispatch that is not kept on the GPU runs on the graphics queue where it reads GPU-owned or watched pages.
- Without the rule: on the compute queue its read into the arena copied the bytes on the thread that records the draws,
and landed first what the GPU owned. One game's dispatches put about 21 MB a present there. The rule is not for a
dispatch that stays resident: the output of the second of a chain of two came back through a staged result.
- Comment:
compute.c, vk_dispatch, above vk_buf_owned.
- Check:
check_compute_owned_input and check_compute_owned_chain in tests/vulkan_compute_owned_input.inc.
W25. A read over pending mirror pages waits for the submission that wrote them, with vk_lock let go.
← previous · next →