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.
Returns Error::InvalidShape if that shape footprint overflows
usize — refused rather than wrapped to a small byte count an
undersized size would then satisfy.
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”.
Source§impl<T> PboTensor<T>
impl<T> PboTensor<T>
Sourcepub fn into_client_parts(self) -> Result<PboClientParts>
pub fn into_client_parts(self) -> Result<PboClientParts>
Decompose this tensor into the parts a C entry point takes.
The shape is carried through as-is and is not required to fill
the allocation: size is the GL buffer’s full byte count and may
exceed the shape’s product by design (a 64-byte-aligned row stride
is the usual reason). Only the origin is constrained.
§Errors
Error::InvalidOperation for a sub-view (view_offset != 0).
A sub-view’s window is not expressible in ef_tensor_wrap_pbo’s
argument list, and a wrap that silently dropped it would land the
far side at the parent’s origin — issue #162 in reverse. Views are
taken on the far side (Tensor::view) once the buffer is wrapped,
so nothing needs this.
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()).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)). Read moreSource§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. Fails with Error::CpuAccessDenied on a Write- or
None-declared tensor.Source§fn map_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
write_access. Fails with
Error::CpuAccessDenied on a Read- or None-declared tensor.Source§fn map_mut<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map_mut<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
map with the
intent spelled out); refused on the same declarations.Source§fn cpu_access(&self) -> CpuAccess
fn cpu_access(&self) -> CpuAccess
CpuAccess). A bare
backing carries no declaration of its own and reports ReadWrite.Source§fn view_origin(&self) -> Option<ViewOrigin>
fn view_origin(&self) -> Option<ViewOrigin>
ViewOrigin); a bare backing reports None.Source§fn is_view(&self) -> bool
fn is_view(&self) -> bool
Tensor::is_view); a bare backing reports false.Source§fn write_access(&self) -> CpuAccess
fn write_access(&self) -> CpuAccess
Source§fn map_for_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map_for_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
write_access’s direction. Read moreSource§fn map_for_partial_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
fn map_for_partial_write<'a>(&self) -> Result<HostView<'a, T>>where
T: 'a,
ReadWrite, see write_access. Read moreAuto 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