pub struct PboTensor<T>{
pub name: String,
pub shape: Vec<usize>,
/* private fields */
}Expand description
A tensor backed by an OpenGL Pixel Buffer Object.
Fields§
§name: String§shape: Vec<usize>Implementations§
Source§impl<T> PboTensor<T>
impl<T> PboTensor<T>
Sourcepub fn from_pbo(
buffer_id: u32,
size: usize,
shape: &[usize],
name: Option<&str>,
ops: Arc<dyn PboOps>,
) -> Result<Self>
pub fn from_pbo( buffer_id: u32, size: usize, shape: &[usize], name: Option<&str>, ops: Arc<dyn PboOps>, ) -> Result<Self>
Create a new PBO tensor from an already-allocated GL buffer.
Called by the image crate after creating the PBO on the GL thread.
Users should not call this directly — use ImageProcessor::create_image().
§Errors
Returns Error::ShapeMismatch if size does not equal
shape.iter().product::<usize>() * std::mem::size_of::<T>().
Returns Error::InvalidSize if size is zero.
Sourcepub fn is_mapped(&self) -> bool
pub fn is_mapped(&self) -> bool
Returns true unless the PBO is fully unmapped.
That covers an exclusive map, one or more read-only holders, AND a
map or unmap another thread currently has in flight — during those
windows the GL buffer is (or is about to be) mapped, and no other
mapping may begin, so reporting false would be misleading. Use it
as “is this buffer free for GL operations?”, not as “does a CPU
pointer exist right now”.
Trait Implementations§
impl<T> Send for PboTensor<T>
impl<T> Sync for PboTensor<T>
Source§impl<T> TensorTrait<T> for PboTensor<T>
impl<T> TensorTrait<T> for PboTensor<T>
Source§fn set_logical_shape(&mut self, shape: &[usize]) -> Result<()>
fn set_logical_shape(&mut self, shape: &[usize]) -> Result<()>
Capacity-based reconfigure (mirrors Mem/Shm/DMA/IOSurface): allow any
shape whose byte size fits the PBO allocation, so an oversized reusable
pool can be configure_imaged to a smaller image. Without this PBO fell
back to the strict-reshape default and rejected pool reuse.
Source§fn view(&self, offset_bytes: usize, shape: &[usize]) -> Result<Self>
fn view(&self, offset_bytes: usize, shape: &[usize]) -> Result<Self>
Zero-copy sub-region view sharing this PBO’s GL buffer (via the
Arc<PboHandle>) and BufferIdentity, positioned at offset_bytes
from this tensor’s own window with logical shape. The GL backend keys
the import on the shared identity and addresses the window via
glViewport / the staged copy; a CPU map adds view_offset to the
mapped base. Mirrors DmaTensor::view.
§Errors
Error::InvalidOperationifoffset_bytesis mis-aligned forT.Error::InsufficientCapacityif the window exceeds the allocation.
Source§fn new(_shape: &[usize], _name: Option<&str>) -> Result<Self>
fn new(_shape: &[usize], _name: Option<&str>) -> Result<Self>
Source§fn from_fd(_fd: OwnedFd, _shape: &[usize], _name: Option<&str>) -> Result<Self>
fn from_fd(_fd: OwnedFd, _shape: &[usize], _name: Option<&str>) -> Result<Self>
Source§fn memory(&self) -> TensorMemory
fn memory(&self) -> TensorMemory
Source§fn reshape(&mut self, shape: &[usize]) -> Result<()>
fn reshape(&mut self, shape: &[usize]) -> Result<()>
Source§fn capacity_bytes(&self) -> usize
fn capacity_bytes(&self) -> usize
size()).
Defaults to the logical size for storages without spare capacity.Source§fn map_with<'a>(&self, access: CpuAccess) -> Result<HostView<'a, T>>where
T: 'a,
fn map_with<'a>(&self, access: CpuAccess) -> Result<HostView<'a, T>>where
T: 'a,
Source§fn buffer_identity(&self) -> &BufferIdentity
fn buffer_identity(&self) -> &BufferIdentity
Source§fn map<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
map_with(CpuAccess::ReadWrite) — the historical map()
behavior).Source§fn map_read<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map_read<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
as_mut_slice; on macOS this takes the read-only IOSurface lock
(skips the unlock flush), on Linux the dma-buf read-direction
sync.Auto Trait Implementations§
impl<T> !RefUnwindSafe for PboTensor<T>
impl<T> !UnwindSafe for PboTensor<T>
impl<T> Freeze for PboTensor<T>where
PhantomData<T>: Freeze,
impl<T> Unpin for PboTensor<T>where
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for PboTensor<T>where
PhantomData<T>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more