From 86680e0cc8ae657ab625fe4abc6be4efadb90f1a Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Wed, 1 Oct 2025 23:37:04 +0200 Subject: [PATCH] dmabuf: optimize sync-file export/import --- src/gfx_apis/vulkan/renderer.rs | 3 +++ src/video/dmabuf.rs | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/src/gfx_apis/vulkan/renderer.rs b/src/gfx_apis/vulkan/renderer.rs index ea3bfdd9..cd0cf29d 100644 --- a/src/gfx_apis/vulkan/renderer.rs +++ b/src/gfx_apis/vulkan/renderer.rs @@ -1649,6 +1649,9 @@ impl VulkanRenderer { let fd = dma_buf_export_sync_file(&plane.fd, flag) .map_err(VulkanError::IoctlExportSyncFile)?; import_sync_file(fd)?; + if buf.template.dmabuf.is_one_file() { + break; + } } } AcquireSync::SyncFile { sync_file } => { diff --git a/src/video/dmabuf.rs b/src/video/dmabuf.rs index 1e6482ee..e19def66 100644 --- a/src/video/dmabuf.rs +++ b/src/video/dmabuf.rs @@ -60,6 +60,10 @@ impl DmaBuf { }) } + pub fn is_one_file(&self) -> bool { + !self.is_disjoint() + } + pub fn udmabuf_size(&self) -> Option { if self.planes.len() != 1 { return None; @@ -103,6 +107,9 @@ impl DmaBuf { pub fn import_sync_file(&self, flags: u32, sync_file: &OwnedFd) -> Result<(), OsError> { for plane in &self.planes { dma_buf_import_sync_file(&plane.fd, flags, sync_file)?; + if self.is_one_file() { + break; + } } Ok(()) }