Repository navigation
pvr/g5p: wait before a vertex realign copy only for GPU-written sources - #50
Merged
henrikklee merged 3 commits intoDec 4, 2026
Merged
Conversation
… A7 transfers g9p_gpu_written tells the realign copy of an unaligned vertex binding (g5p_realign_binding()) whether it must wait for the jobs before it. On G5P only the storage and texel buffer descriptors set it, so the realign check also tested the buffer's usage flags to stay safe. Set it on every other path where the GPU writes an app buffer on G5P: - transform feedback buffers and counter buffers, as the G9P bind does; - the destination of vkCmdCopyQueryPoolResults, which G5P runs as a compute kernel (pvr_arch_g5p_query.c), not on the CPU; - the destination of the A7's buffer copies, fills, updates and image to buffer copies, which run as compute jobs (pvr_arch_g3_compute.c). By default (PVR_G3_GFX=tri) the A7 draws through upstream's Rogue path; it reaches g5p_cmd_draw() and the realign copy when PVR_G3_GFX names another path (e.g. ta). The A8/A9 transfers run on the CPU at submission, in queue order, after waiting for every earlier job, so they need no flag. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
g5p_realign_binding() treated a source as GPU-written when its buffer had storage, storage texel or transform feedback usage. Zink creates every buffer with VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, so every realigned binding under Zink counted as GPU-written, even CPU-filled vertex and instance data. The submission of each such render then waited on the CPU for the GPU queue to drain (pvr_arch_queue.c, "wait realign"). Firefox's WebRender on YouTube's home page did this about 18 times per frame. Every path where the G5P GPU writes an app buffer now sets g9p_gpu_written, so test that flag alone, as G9P does. Under G9P_WAITLOG, also log each realigned binding: why it is copied (unaligned address or stride, or a fetch overread past the mapping), its address, stride, size and whether the copy waits. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
…ssion The realign copy of an unaligned vertex binding runs on the CPU when its job is submitted, and waits for the jobs before it only when the source buffer may have been written by the GPU (g9p_gpu_written). The flag was sampled when the draw was recorded. A buffer first bound for GPU writes (storage descriptor, transform feedback, ...) after that, in a command buffer submitted before the draw's, set the flag too late: the copy skipped the wait and could read the buffer before the writer finished. G5P's former usage-flag test covered this case; G9P never did. Keep the source buffer in struct g9p_realign and test its flag again in g9p_realign_needs_wait(), on G9P and G5P. The pointer is valid there: destroying a buffer a command buffer uses makes that command buffer invalid, an invalid command buffer cannot be submitted, and a pending one keeps its buffers alive until it completes. The realign copy already reads the buffer's memory at the same point. Known limits, unchanged: - memory aliasing: another VkBuffer or a linear image bound to the same memory as a GPU-written buffer does not set this buffer's flag; - a secondary command buffer copies its realigned bindings when it is recorded, without waiting for any job. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the A9, a draw with an unaligned vertex binding gets a CPU realign copy at submission. Before the copy, the submission waited for the GPU queue to drain whenever the source buffer had storage, storage-texel or transform feedback usage. Zink creates every buffer with
STORAGE_BUFFERusage, so every realigned binding under Zink counted as GPU-written, even CPU-filled vertex data. Firefox's WebRender on YouTube's home page drained the queue 17.7 times per frame, 35 ms of waiting per frame.g9p_gpu_written: transform feedback and counter buffers,vkCmdCopyQueryPoolResultsdestinations (a compute kernel on G5P), and the A7's compute-run transfers.G9P_WAITLOGalso logs each realigned binding and whether it waits.g9p_realign_needs_wait().Tested on the iPad 5 (j71t) with this exact series, installed since 2026-12-03. Firefox scroll, before → after:
The after column was measured on the newer kernel too, so part of the fps gain may come from it; the drain count is this series alone. Built on this head (Vulkan imagination with asserts on); the G5P meson host tests pass, 9/9.
How to test
On a stock Orchard install with Mesa built from this branch:
Expected on the iPad 5: no realign queue drains while scrolling, and higher scroll fps on heavy pages. A10: the submit-time re-read is in the shared G9P realign code, so it is enabled on the A10 and closes the same late-flag case there. Untested on our side.