vulkan-core: make SyncobjCtx optional
This commit is contained in:
parent
0a84bd47bf
commit
e2d2a2e9b9
6 changed files with 16 additions and 11 deletions
|
|
@ -2037,8 +2037,8 @@ impl VulkanDeviceInf for CopyDeviceInner {
|
|||
self.phy.supports_timeline_opaque_export
|
||||
}
|
||||
|
||||
fn sync_ctx(&self) -> &Rc<SyncobjCtx> {
|
||||
&self.phy.sync_ctx
|
||||
fn sync_ctx(&self) -> Option<&Rc<SyncobjCtx>> {
|
||||
Some(&self.phy.sync_ctx)
|
||||
}
|
||||
|
||||
fn eventfd_cache(&self) -> &Rc<EventfdCache> {
|
||||
|
|
|
|||
|
|
@ -671,8 +671,8 @@ impl VulkanDeviceInf for VulkanDevice {
|
|||
self.supports_timeline_opaque_export
|
||||
}
|
||||
|
||||
fn sync_ctx(&self) -> &Rc<SyncobjCtx> {
|
||||
&self.sync_ctx
|
||||
fn sync_ctx(&self) -> Option<&Rc<SyncobjCtx>> {
|
||||
Some(&self.sync_ctx)
|
||||
}
|
||||
|
||||
fn eventfd_cache(&self) -> &Rc<EventfdCache> {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ pub enum VulkanCoreError {
|
|||
AcquireEventfd(#[source] EventfdError),
|
||||
#[error("Could not create a sync obj eventfd wait")]
|
||||
CreateSyncobjWait(#[source] DrmError),
|
||||
#[error("Device does not have a syncobj ctx")]
|
||||
NoSyncobjCtx,
|
||||
}
|
||||
|
||||
pub struct VulkanCoreInstance {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@ pub trait VulkanDeviceInf: Sized {
|
|||
fn external_fence_fd(&self) -> &external_fence_fd::Device;
|
||||
fn external_semaphore_fd(&self) -> &external_semaphore_fd::Device;
|
||||
fn supports_timeline_opaque_export(&self) -> bool;
|
||||
fn sync_ctx(&self) -> &Rc<SyncobjCtx>;
|
||||
fn sync_ctx(&self) -> Option<&Rc<SyncobjCtx>>;
|
||||
fn eventfd_cache(&self) -> &Rc<EventfdCache>;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,12 +113,11 @@ where
|
|||
.eventfd_cache()
|
||||
.acquire()
|
||||
.map_err(VulkanCoreError::AcquireEventfd)?;
|
||||
device
|
||||
.sync_ctx()
|
||||
tls.sync_ctx
|
||||
.wait_for_point(&eventfd.fd, &tls.syncobj, point, true)
|
||||
.map_err(VulkanCoreError::CreateSyncobjWait)?;
|
||||
let pending = Rc::new(ReservedSyncobjPoint {
|
||||
ctx: device.sync_ctx().clone(),
|
||||
ctx: tls.sync_ctx.clone(),
|
||||
syncobj: tls.syncobj.clone(),
|
||||
point,
|
||||
sync_file: Default::default(),
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use {
|
||||
crate::{
|
||||
utils::{errorfmt::ErrorFmt, numcell::NumCell},
|
||||
video::drm::syncobj::Syncobj,
|
||||
video::drm::syncobj::{Syncobj, SyncobjCtx},
|
||||
vulkan_core::{VulkanCoreError, device::VulkanDeviceInf},
|
||||
},
|
||||
ash::vk::{
|
||||
|
|
@ -20,6 +20,7 @@ where
|
|||
{
|
||||
pub(super) device: Rc<D>,
|
||||
pub(super) semaphore: Semaphore,
|
||||
pub(super) sync_ctx: Rc<SyncobjCtx>,
|
||||
pub(super) syncobj: Rc<Syncobj>,
|
||||
pub(super) next_point: NumCell<u64>,
|
||||
}
|
||||
|
|
@ -55,6 +56,9 @@ where
|
|||
if !self.supports_timeline_opaque_export() {
|
||||
return Err(VulkanCoreError::TimelineExportNotSupported);
|
||||
}
|
||||
let Some(sync_ctx) = self.sync_ctx() else {
|
||||
return Err(VulkanCoreError::NoSyncobjCtx);
|
||||
};
|
||||
let sem = {
|
||||
let mut export_info = ExportSemaphoreCreateInfo::default()
|
||||
.handle_types(ExternalSemaphoreHandleTypeFlags::OPAQUE_FD);
|
||||
|
|
@ -87,8 +91,7 @@ where
|
|||
for _ in 0..2 {
|
||||
let n = next_point.fetch_add(1);
|
||||
signal(n)?;
|
||||
let signaled = self
|
||||
.sync_ctx()
|
||||
let signaled = sync_ctx
|
||||
.query_last_signaled(&syncobj)
|
||||
.map_err(VulkanCoreError::QueryLastSignaled)?;
|
||||
if signaled != n {
|
||||
|
|
@ -99,6 +102,7 @@ where
|
|||
Ok(Rc::new(VulkanTimelineSemaphore {
|
||||
device: self.clone(),
|
||||
semaphore: sem,
|
||||
sync_ctx: sync_ctx.clone(),
|
||||
syncobj: Rc::new(syncobj),
|
||||
next_point,
|
||||
}))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue