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