Repository navigation
pvr/g5p: reuse command stream blocks and job syncs, cache imported dma-buf mappings - #47
Merged
Merged
Conversation
…rge syncobj The powervr winsys gains what G5P submit reuse (next commit) needs, all optional winsys ops: - struct pvr_winsys_stamp on the render and compute submit infos: a job that carries one also signals that point of a timeline syncobj, as one more sync op of the same SUBMIT_JOBS ioctl (no extra kernel call). A render puts it on its last job (fragment, else partial render, else geometry). stamp_create/stamp_destroy/stamp_query make and read such a timeline (drmSyncobjQuery: the point up to which it has signalled). - syncs_reset: returns job syncs of the device's type to the state vk_sync_create(..., 0) leaves them in (no fence, no job tag), in one DRM_IOCTL_SYNCOBJ_RESET for all of them. - A null job with waits merged them through a syncobj created and destroyed per job. On G5P it now keeps those: reset four or more together, then reused (pvr_drm_tmp_syncobj_get/put). PVR_G5P_REUSE=0 turns the kept merge syncobj off (pvr_g5p_reuse_option(), read at winsys creation). Other GPUs and pvrsrvkm: unchanged. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
…pool job syncs Each vkQueueSubmit on the A9 created, CPU-mapped and GPU-mapped a 4 KiB BO per command stream block while recording, and unmapped and closed it at the command buffer's reset: 7 kernel calls per block, about 14 blocks per frame in Dolphin's Mario Kart Wii and 58 in fifolog_missing_bridge. Each GPU unmap on the A9 also moves the MMU tag of every loaded VM slot, so the next job of every client starts with its translations dropped. Every job also created and destroyed its syncobjs. Apple (iOS 16 IOGPU.framework) takes command buffer storage from a device-wide pool (IOGPUMetalCommandBufferStoragePoolCreateStorage) and returns it from the completion handler (-[IOGPUMetalCommandBuffer didCompleteWithStartTime:endTime:error:] -> IOGPUMetalCommandBufferStorageDealloc -> StorageReset + StoragePoolReturnStorage): reuse follows GPU completion, never the application's reset. pvr_g5p_reuse.c does the same: - Stamps: each queue owns a timeline syncobj; every render, compute and query job signals its next point within its own submission. A command buffer records, per queue, the last point issued when it was submitted. - Command stream blocks: a primary command buffer's blocks, at its reset or free, go pending with those points; they become free only once one query of the queues' timelines shows every point reached (blocks of a never-submitted buffer are free at once). A recording takes a free block, zeroed so the GPU sees what a new BO holds, or allocates a new one: reuse never waits. Free + pending is capped at 512 blocks; pending ones are kept whatever the count. Secondary command buffers keep the plain free. - Syncs: the queue's job, wait and barrier syncs go to a pool when they were destroyed before and are reset 32 at a time (one ioctl). Event syncs, owned by VkEvent, are unchanged. So a block is never rewritten while a job may read it, even when an application resets a pending command buffer. PVR_G5P_REUSE=0 turns all of it off for a same-boot A/B; PVR_G5P_REUSE_STATS=1 prints the counts at device destruction. Other GPUs (G9P/A10, Rogue): reuse is off, behaviour unchanged. Offline (fakepvr, Dolphin FIFO replays, steady state per frame): Mario Kart Wii 140 -> 44 ioctls, fifolog_missing_bridge 583 -> 100; BO create, map, unmap and close go from 14 and 57.5 per frame to 0. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Zink passes SPIR-V that declares FloatControls2, and spirv_to_nir warned about the unsupported capability for every such shader. spirv_to_nir already translates its execution modes, so accept it. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Physical-device initialization on the A9 and A10 needs only DRM device queries, the fd, the page size and the sync type, but it created a full winsys with its own VM. Make that winsys query-only. The logical device still creates the VM and uses its own winsys for heaps and static memory. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
Each dma-buf import through Zink (e.g. hardware video frames from a fixed VA-API surface pool) creates a VkDeviceMemory via DRM_IOCTL_PRIME_FD_TO_HANDLE and binds it via pvr_bind_memory(). Even though the kernel returns the same GEM handle for the same dma-buf within one DRM file, pvr_bind_memory() always allocated a new GPU VA range and issued DRM_IOCTL_PVR_VM_MAP on bind and DRM_IOCTL_PVR_VM_UNMAP on unbind, invalidating GPU address translations on every frame. Cache one whole-BO GPU VM mapping per imported GEM handle in the powervr DRM winsys (general for all chips): - Add an optional winsys op vma_map_imported() used by pvr_bind_memory() when mem->vk.import_handle_type != 0. - Key the cached whole-BO mapping by GEM handle via drm_bo->import_vma. Each binding gets its own view VMA covering its (offset, size) slice so different offsets/sizes (such as multi-plane NV12) share one mapping without extra VM_MAP ioctls, while keeping distinct VMA pointers for g9p_vmas tracking. - Reference-count active bindings; when the last binding unmaps, keep the mapping (and its BO reference, so the kernel retains the GEM handle) in a bounded LRU (32 entries / 64 MiB) so rotating surface pools hit the cache. - Flush LRU entries on general_heap VA exhaustion, VM_MAP failure, and winsys/device teardown; evicting an entry unmaps its GPU VA, frees its VA space, and releases the BO reference (closing the GEM handle once unused). - Add PVR_IMPORT_CACHE=0 (read at winsys creation) to disable the cache for A/B testing. Assisted-by: LLM Signed-off-by: Berkay Kösebay <brkosebay@users.noreply.github.com>
This was referenced Dec 3, 2026
henrikklee
added a commit
that referenced
this pull request
Dec 4, 2026
pvr/g5p: barrier precision: geometry waits on fragments only on a hazard (on #47)
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.
Cuts the CPU and kernel work around each A9 submission. The GPU work stays the same.
SUBMIT_JOBSioctl, so there is no extra kernel call.VM_MAP/VM_UNMAPper bind. A bounded LRU keeps 32 entries / 64 MiB, and the cache is flushed on VA exhaustion and at teardown.Tested on the iPad 5 (j71t), installed since 2026-12-02 (offscreen glmark2 1536×2048, build/texture/terrain 20 s each, two runs per arm):
PVR_G5P_REUSE=0That is −97 % BO creates and maps per second and +6.7 % glmark2 at the same GPU time per job: the gain is CPU and kernel overhead. The desktop (Labwc, Firefox, the shell) has run on it since then. Offline (Dolphin FIFO replays), steady-state ioctls per frame went from 140 to 44 (Mario Kart Wii) and from 583 to 100.
Built on this head (Vulkan imagination with asserts on, and the Zink GL build); 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: about +7 % glmark2 with reuse on, the same score with
PVR_G5P_REUSE=0, and a few BO creates per second instead of hundreds. A10: block reuse is off on G9P (A10) and its behaviour is unchanged. The query-only physical device and the import cache are enabled there too, untested on our side.