Skip to content

vulkan: use sync objects if possible#769

Merged
mahkoh merged 5 commits intomasterfrom
jorth/fence
Mar 2, 2026
Merged

vulkan: use sync objects if possible#769
mahkoh merged 5 commits intomasterfrom
jorth/fence

Conversation

@mahkoh
Copy link
Owner

@mahkoh mahkoh commented Mar 2, 2026

No description provided.

Copilot AI review requested due to automatic review settings March 2, 2026 17:12
github-actions[bot]
github-actions bot previously approved these changes Mar 2, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Vulkan explicit-sync path to prefer DRM syncobj-backed timeline semaphores when supported, falling back to fences/sync files otherwise, and threads a shared eventfd cache through the rendering/copy stack to efficiently wait on syncobj points.

Changes:

  • Add a vulkan_core sync layer (VulkanTimelineSemaphore, VulkanSync) that can export either a fence-based sync file or a syncobj point.
  • Introduce gfx_api::FdSync to unify “sync file vs syncobj point” handling across Vulkan/GL/Metal/backends and buffer reservation plumbing.
  • Add EventfdCache and pass it through compositor/portal/screenshot/copy-device paths to support syncobj-point waiting via eventfds.

Reviewed changes

Copilot reviewed 37 out of 37 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/vulkan_core/timeline_semaphore.rs Creates/export-checks a timeline semaphore and maps it to a DRM syncobj.
src/vulkan_core/sync.rs Adds VulkanSync abstraction (fence vs timeline semaphore) and sync creation for queue submissions.
src/vulkan_core/fence.rs Refactors fence into generic VulkanFence<D> using VulkanDeviceInf.
src/vulkan_core/device.rs Introduces VulkanDeviceInf trait to unify device access for core sync primitives.
src/vulkan_core.rs Adds core error variants and feature probing for timeline semaphore export support.
src/video/drm/sys.rs Adds timeline handle-to-fd flag, query ioctl wrapper, and extends handle-to-fd API with point.
src/video/drm/syncobj.rs Adds syncobj id, query-last-signaled, and blocking export path for sync files from syncobj points.
src/video/drm.rs Re-exports get_drm_nodes_from_dev and extends DrmError for syncobj query/export.
src/utils/stack.rs Adds Stack::len() (used by eventfd cache tests).
src/state.rs Wires EventfdCache through state and changes render sync type to FdSync.
src/portal/ptl_display.rs Passes EventfdCache into gfx context creation.
src/portal.rs Adds EventfdCache to portal state initialization.
src/main.rs Adds new eventfd_cache module.
src/it/test_client.rs Updates screenshot path to supply EventfdCache to buffer readback.
src/ifs/wl_surface.rs Switches buffer reservation sync tracking to FdSync and sync-file extraction when needed.
src/ifs/ext_image_copy/ext_image_copy_capture_frame_v1.rs Updates capture-frame callback signatures to return FdSync.
src/gfx_apis/vulkan/transfer.rs Uses VulkanDeviceSyncExt to signal either syncobj or fence and waits via FdSync.
src/gfx_apis/vulkan/shm_image.rs Updates async upload/download sync plumbing to use VulkanSync/FdSync.
src/gfx_apis/vulkan/renderer.rs Introduces per-render/transfer timeline semaphores and switches release signaling to VulkanSync/FdSync.
src/gfx_apis/vulkan/image.rs Updates framebuffer render return type to FdSync.
src/gfx_apis/vulkan/device.rs Implements VulkanDeviceInf, wires EventfdCache, and computes timeline-export support.
src/gfx_apis/vulkan.rs Threads EventfdCache into Vulkan context/allocator creation and defines core sync aliases.
src/gfx_apis/gl/renderer/framebuffer.rs Updates GL rendering to return FdSync.
src/gfx_apis/gl.rs Wraps produced sync files into FdSync and uses AcquireSync::get_sync_file() for imports.
src/gfx_apis.rs Threads EventfdCache into gfx context creation dispatch.
src/gfx_api.rs Introduces FdSync, ReservedSyncobjPoint, updates AcquireSync and BufferResv API.
src/eventfd_cache/tests.rs Adds tests for eventfd cache recycling behavior.
src/eventfd_cache.rs Adds EventfdCache and Eventfd for async waits and recycling.
src/cursor_user.rs Updates cursor swap-buffer sync type to FdSync.
src/copy_device.rs Updates copy device to use VulkanSync/timeline semaphore when possible and adopt FdSync.
src/compositor.rs Initializes and stores EventfdCache, passes it to gfx/copy device setup.
src/cli/screenshot.rs Creates an EventfdCache for screenshot allocator path and passes it into Vulkan allocator creation.
src/backends/metal/video.rs Updates cursor sync tracking to FdSync.
src/backends/metal/transaction.rs Replaces per-syncfile poll loop with FdSync::signaled_blocking.
src/backends/metal/present.rs Uses FdSync for cursor and framebuffer wait paths.
src/backends/metal/allocator.rs Updates render/copy sync plumbing to FdSync and uses AcquireSync::from_fd_sync.
src/backend.rs Updates HardwareCursorUpdate::swap_buffer to take FdSync.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mahkoh mahkoh merged commit 8e51c71 into master Mar 2, 2026
8 checks passed
@mahkoh mahkoh deleted the jorth/fence branch March 2, 2026 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants