Skip to main content

OpenClMem

Struct OpenClMem 

Source
pub struct OpenClMem { /* private fields */ }
Expand description

cl_mem handle paired with its producing cl_command_queue.

row_pitch is meaningful only for cl_mem BUFFER objects holding image data with non-tight rows; see the documentation on the OpenCl variant for the full contract.

Implementations§

Source§

impl OpenClMem

Source

pub unsafe fn try_from_raw( mem: *mut c_void, queue: *mut c_void, row_pitch: u32, keep_alive: Option<KeepAlive>, ) -> Result<Self, InvalidHandleError>

Wrap a raw cl_mem together with the cl_command_queue that produced it. Borrowing: the handle is stored non-owningly, this type has no Drop, and every obligation below extends to each Clone.

§Safety
  • mem must be a live cl_mem whose OpenCL reference count is at least one.
  • queue must be a live cl_command_queue on a context that owns mem. Consumers enqueue against queue naming mem; an unrelated context makes that an invalid-object call at best and undefined at worst. Null for either is rejected as InvalidHandleError::NullPointer and is not a caller obligation.
  • Refcount: neither clRetainMemObject nor clRetainCommandQueue is called here, and there is no Drop that releases. The caller’s references on both objects must outlive this value and every Clone of it — pass a keep_alive anchor that holds them, or carry the obligation directly when it is None. Releasing either while a clone survives is a use-after-free.
  • row_pitch is meaningful only when mem is a BUFFER object holding image rows that are not tightly packed; it must then be the real row stride in bytes, since consumers index rows by it. Pass 0 for image objects and tightly-packed buffers.
  • Cross-thread: OpenClMem is Send + Sync. OpenCL objects are thread-safe under the 1.2+ spec, but a single cl_command_queue is only safe to enqueue on concurrently because the runtime serialises it — the caller must still not assume ordering between its own enqueues and the consumer’s.
Source

pub fn mem(&self) -> *mut c_void

Source

pub fn queue(&self) -> *mut c_void

Source

pub fn row_pitch(&self) -> u32

Source

pub fn keep_alive(&self) -> Option<&KeepAlive>

Trait Implementations§

Source§

impl Clone for OpenClMem

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OpenClMem

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for OpenClMem

Source§

impl Sync for OpenClMem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> MaybeSend for T
where T: Send + ?Sized,

Source§

impl<T> MaybeSendSync for T
where T: Send + Sync + ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,