Skip to main content

PboOps

Trait PboOps 

Source
pub unsafe trait PboOps: Send + Sync {
    // Required methods
    fn map_buffer(&self, buffer_id: u32, size: usize) -> Result<PboMapping>;
    fn unmap_buffer(&self, buffer_id: u32) -> Result<()>;
    fn delete_buffer(&self, buffer_id: u32);
}
Expand description

Trait for PBO GL operations, implemented by the image crate.

All methods are blocking — they send commands to the GL thread and wait for completion. Implementations must ensure GL context is current on the thread that executes the actual GL calls.

§Safety

Implementations must ensure:

  • map_buffer returns a valid, aligned pointer to size bytes of CPU-accessible memory that remains valid until unmap_buffer is called.
  • unmap_buffer invalidates the pointer and releases the mapping.
  • delete_buffer frees the GL buffer resources.

Required Methods§

Source

fn map_buffer(&self, buffer_id: u32, size: usize) -> Result<PboMapping>

Map the PBO for CPU read/write access. The returned PboMapping is valid until unmap_buffer is called.

A returned PboMapping::size below size is treated as a FAILED map, not a partial one: PboHandle::acquire_map refuses it and unmaps the buffer. Callers of the resulting pin size their host slice from the tensor’s own allocation, so there is nowhere for a shorter mapping to be recorded. Report the shortfall as an Err rather than a short success if the implementation can tell.

Source

fn unmap_buffer(&self, buffer_id: u32) -> Result<()>

Unmap a previously mapped PBO. Must be called before GL operations on this buffer (GLES 3.0 requirement).

Source

fn delete_buffer(&self, buffer_id: u32)

Delete the PBO. Fire-and-forget — no reply needed. Called from PboTensor’s Drop impl.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§