#[allow(unused)]
pub(crate) use self::pipeline::{PipelineStageAccess, PipelineStageAccessFlags};
pub use self::{
future::{now, GpuFuture},
pipeline::{
AccessFlags, BufferMemoryBarrier, DependencyFlags, DependencyInfo, ImageMemoryBarrier,
MemoryBarrier, PipelineStage, PipelineStages, QueueFamilyOwnershipTransfer,
},
};
use crate::{device::Queue, VulkanError};
use std::{
error::Error,
fmt::{Display, Formatter},
sync::Arc,
};
pub mod event;
pub mod fence;
pub mod future;
mod pipeline;
pub mod semaphore;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum SharingMode {
Exclusive,
Concurrent(Vec<u32>), }
impl<'a> From<&'a Arc<Queue>> for SharingMode {
#[inline]
fn from(_queue: &'a Arc<Queue>) -> SharingMode {
SharingMode::Exclusive
}
}
impl<'a> From<&'a [&'a Arc<Queue>]> for SharingMode {
#[inline]
fn from(queues: &'a [&'a Arc<Queue>]) -> SharingMode {
SharingMode::Concurrent(
queues
.iter()
.map(|queue| queue.queue_family_index())
.collect(),
)
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum Sharing<I>
where
I: IntoIterator<Item = u32>,
{
Exclusive,
Concurrent(I),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum CurrentAccess {
CpuExclusive,
GpuExclusive { gpu_reads: usize, gpu_writes: usize },
Shared { cpu_reads: usize, gpu_reads: usize },
}
#[derive(Clone, Debug)]
pub enum HostAccessError {
AccessConflict(AccessConflict),
Invalidate(VulkanError),
NotHostMapped,
OutOfMappedRange,
}
impl Error for HostAccessError {
fn source(&self) -> Option<&(dyn Error + 'static)> {
match self {
Self::AccessConflict(err) => Some(err),
Self::Invalidate(err) => Some(err),
_ => None,
}
}
}
impl Display for HostAccessError {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
Self::AccessConflict(_) => {
write!(f, "the resource is already in use in a conflicting way")
}
HostAccessError::Invalidate(_) => write!(f, "invalidating the device memory failed"),
HostAccessError::NotHostMapped => {
write!(f, "the device memory is not current host-mapped")
}
HostAccessError::OutOfMappedRange => write!(
f,
"the requested range is not within the currently mapped range of device memory",
),
}
}
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum AccessConflict {
HostRead,
HostWrite,
DeviceRead,
DeviceWrite,
}
impl Error for AccessConflict {}
impl Display for AccessConflict {
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> {
match self {
AccessConflict::HostRead => write!(
f,
"the resource is already locked for reading by the host (CPU)"
),
AccessConflict::HostWrite => write!(
f,
"the resource is already locked for writing by the host (CPU)"
),
AccessConflict::DeviceRead => write!(
f,
"the resource is already locked for reading by the device (GPU)"
),
AccessConflict::DeviceWrite => write!(
f,
"the resource is already locked for writing by the device (GPU)"
),
}
}
}