1
0
Fork 0
forked from wry/wry

vulkan: use sync objects if possible

This commit is contained in:
Julian Orth 2026-03-01 17:25:40 +01:00
parent 2ac3519f2d
commit 3d3132fe39
23 changed files with 535 additions and 86 deletions

View file

@ -18,7 +18,7 @@ use {
DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_TIMELINE, DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE,
DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT, sync_ioc_merge, syncobj_create,
syncobj_destroy, syncobj_eventfd, syncobj_fd_to_handle, syncobj_handle_to_fd,
syncobj_signal, syncobj_transfer,
syncobj_query, syncobj_signal, syncobj_transfer,
},
},
},
@ -329,6 +329,11 @@ impl SyncobjCtx {
}
}
}
pub fn query_last_signaled(&self, syncobj: &Syncobj) -> Result<u64, DrmError> {
let handle = self.get_handle(syncobj)?;
syncobj_query(self.inner.drm.raw(), handle.0).map_err(DrmError::QuerySyncobj)
}
}
impl Drop for SyncobjCtx {

View file

@ -171,7 +171,10 @@ pub fn get_device_name_from_fd2(fd: c::c_int) -> Result<Ustring, OsError> {
pub fn get_nodes(fd: c::c_int) -> Result<AHashMap<NodeType, CString>, OsError> {
let (_, maj, min) = drm_stat(fd)?;
get_drm_nodes_from_dev(maj, min)
}
pub fn get_drm_nodes_from_dev(maj: u64, min: u64) -> Result<AHashMap<NodeType, CString>, OsError> {
let dir = device_dir(maj, min);
let mut dir = uapi::opendir(dir)?;
@ -1334,6 +1337,22 @@ pub fn syncobj_signal(drm: c::c_int, handle: u32, point: u64) -> Result<(), OsEr
Ok(())
}
const DRM_IOCTL_SYNCOBJ_QUERY: u64 = drm_iowr::<drm_syncobj_timeline_array>(0xCB);
pub fn syncobj_query(drm: c::c_int, handle: u32) -> Result<u64, OsError> {
let mut point = 0u64;
let mut res = drm_syncobj_timeline_array {
handles: &handle as *const u32 as u64,
points: &mut point as *mut u64 as u64,
count_handles: 1,
flags: 0,
};
unsafe {
ioctl(drm, DRM_IOCTL_SYNCOBJ_QUERY, &mut res)?;
}
Ok(point)
}
#[repr(C)]
struct drm_syncobj_transfer {
src_handle: u32,