#[repr(transparent)]pub struct Buf<'a, T, C: Context = Global> { /* private fields */ }
cl1_1
only.Expand description
An immutable slice of a Buffer
Implementations§
Methods from Deref<Target = Buffer<T, C>>§
sourcepub fn slice<R: IntoRange>(&self, range: R) -> Result<Buf<'_, T, C>>where
C: Clone,
pub fn slice<R: IntoRange>(&self, range: R) -> Result<Buf<'_, T, C>>where C: Clone,
Creates a shared slice of this buffer.
sourcepub fn chunks_exact(&self, offset: usize, len: usize) -> ChunksExact<'_, T, C> ⓘwhere
C: Clone,
pub fn chunks_exact(&self, offset: usize, len: usize) -> ChunksExact<'_, T, C> ⓘwhere C: Clone,
Returns an iterator over chunks of size len
of the buffer, starting at offset
.
sourcepub fn as_uninit(&self) -> &Buffer<MaybeUninit<T>, C>
pub fn as_uninit(&self) -> &Buffer<MaybeUninit<T>, C>
Converts &Buffer<T,C>
to &Buffer<MaybeUninit<T>,C>
pub fn try_clone(&self, wait: WaitList<'_>) -> Result<Self>where T: Clone, C: Clone,
pub async fn try_clone_async<'a>(&self, wait: WaitList<'a>) -> Result<Self>where T: Clone, C: Clone,
futures
only.sourcepub fn eq_buffer(&self, other: &Buffer<T, C>) -> bool
pub fn eq_buffer(&self, other: &Buffer<T, C>) -> bool
Checks if the buffer pointer is the same in both buffers.
sourcepub fn get_blocking(&self, idx: usize, wait: WaitList<'_>) -> Result<T>
pub fn get_blocking(&self, idx: usize, wait: WaitList<'_>) -> Result<T>
Reads the contents of the buffer at the specified index, blocking the current thread until the operation has completed.
sourcepub fn get<'scope, 'env>(
&'env self,
scope: &'scope Scope<'scope, 'env, C>,
idx: usize,
wait: WaitList<'_>
) -> Result<GetEvent<'scope, T, C>>where
T: 'static + Send,
pub fn get<'scope, 'env>( &'env self, scope: &'scope Scope<'scope, 'env, C>, idx: usize, wait: WaitList<'_> ) -> Result<GetEvent<'scope, T, C>>where T: 'static + Send,
Reads the contents of the buffer at the specified index, blocking the current thread until the operation has completed.
sourcepub fn read<'scope, 'env, R: IntoRange>(
&'env self,
scope: &'scope Scope<'scope, 'env, C>,
range: R,
wait: WaitList<'_>
) -> Result<ReadEvent<'scope, T, C>>
pub fn read<'scope, 'env, R: IntoRange>( &'env self, scope: &'scope Scope<'scope, 'env, C>, range: R, wait: WaitList<'_> ) -> Result<ReadEvent<'scope, T, C>>
Reads the contents of the buffer.
sourcepub fn read_blocking<R: IntoRange>(
&self,
range: R,
wait: WaitList<'_>
) -> Result<Vec<T>>
pub fn read_blocking<R: IntoRange>( &self, range: R, wait: WaitList<'_> ) -> Result<Vec<T>>
Reads the contents of the buffer, blocking the current thread until the operation has completed.
sourcepub fn read_into<'scope, 'env, O: Into<Option<usize>>>(
&'env self,
s: &'scope Scope<'scope, 'env, C>,
offset: O,
dst: &'env mut [T],
wait: WaitList<'_>
) -> Result<ReadIntoEvent<'scope, T, C>>
pub fn read_into<'scope, 'env, O: Into<Option<usize>>>( &'env self, s: &'scope Scope<'scope, 'env, C>, offset: O, dst: &'env mut [T], wait: WaitList<'_> ) -> Result<ReadIntoEvent<'scope, T, C>>
Reads the contents of the buffer into dst
.
sourcepub fn read_into_blocking(
&self,
offset: impl Into<Option<usize>>,
dst: &mut [T],
wait: WaitList<'_>
) -> Result<()>
pub fn read_into_blocking( &self, offset: impl Into<Option<usize>>, dst: &mut [T], wait: WaitList<'_> ) -> Result<()>
Reads the contents of the buffer into dst
, blocking the current thread until the operation has completed.
sourcepub fn copy_to<'scope, 'env, Src: Into<Option<usize>>, Dst: Into<Option<usize>>, Size: Into<Option<usize>>>(
&'env self,
scope: &'scope Scope<'scope, 'env, C>,
src_offset: Src,
dst: &'env mut Self,
dst_offset: Dst,
size: Size,
wait: WaitList<'_>
) -> Result<CopyEvent<'scope, T, C>>
pub fn copy_to<'scope, 'env, Src: Into<Option<usize>>, Dst: Into<Option<usize>>, Size: Into<Option<usize>>>( &'env self, scope: &'scope Scope<'scope, 'env, C>, src_offset: Src, dst: &'env mut Self, dst_offset: Dst, size: Size, wait: WaitList<'_> ) -> Result<CopyEvent<'scope, T, C>>
Copies the contents from self
to dst
sourcepub fn copy_to_blocking(
&self,
src_offset: impl Into<Option<usize>>,
dst: &mut Self,
dst_offset: impl Into<Option<usize>>,
size: impl Into<Option<usize>>,
wait: WaitList<'_>
) -> Result<()>
pub fn copy_to_blocking( &self, src_offset: impl Into<Option<usize>>, dst: &mut Self, dst_offset: impl Into<Option<usize>>, size: impl Into<Option<usize>>, wait: WaitList<'_> ) -> Result<()>
Copies the contents from self
to dst
, blocking the current thread until the operation has completed.
pub fn map<'scope, 'env, R: IntoRange>( &'env self, s: &'scope Scope<'scope, 'env, C>, range: R, wait: WaitList<'_> ) -> Result<BufferMapEvent<'scope, 'env, T, C>>
pub fn map_blocking<'a, R: IntoRange>( &'a self, range: R, wait: WaitList<'_> ) -> Result<MapGuard<'a, T, C>>
Methods from Deref<Target = RawBuffer>§
sourcepub unsafe fn create_sub_buffer(
&self,
flags: MemAccess,
region: BufferRange
) -> Result<RawBuffer>
pub unsafe fn create_sub_buffer( &self, flags: MemAccess, region: BufferRange ) -> Result<RawBuffer>
Creates a new buffer object (referred to as a sub-buffer object) from an existing buffer object.
pub unsafe fn read_to_ptr( &self, range: BufferRange, dst: *mut c_void, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn read_rect_to_ptr( &self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, dst: *mut c_void, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn write_from_ptr( &mut self, range: BufferRange, src: *const c_void, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn write_rect_from_ptr( &mut self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, src: *const c_void, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn copy_from( &mut self, dst_offset: usize, src: &RawBuffer, src_offset: usize, size: usize, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn fill_raw<T: Copy>( &mut self, v: T, range: BufferRange, wait: WaitList<'_> ) -> Result<RawEvent>
cl1_2
only.pub unsafe fn map_read( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*const c_void, RawEvent)>
pub unsafe fn map_write( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>
pub unsafe fn map_read_write( &self, range: BufferRange, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>
sourcepub unsafe fn read_to_ptr_in(
&self,
range: BufferRange,
dst: *mut c_void,
queue: &RawCommandQueue,
wait: WaitList<'_>
) -> Result<RawEvent>
pub unsafe fn read_to_ptr_in( &self, range: BufferRange, dst: *mut c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
Reads the contents of this
pub unsafe fn read_rect_to_ptr_in( &self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, dst: *mut c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn write_from_ptr_in( &mut self, range: BufferRange, src: *const c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn write_rect_from_ptr_in( &mut self, buffer_origin: [usize; 3], host_origin: [usize; 3], region: [usize; 3], buffer_row_pitch: Option<usize>, buffer_slice_pitch: Option<usize>, host_row_pitch: Option<usize>, host_slice_pitch: Option<usize>, src: *const c_void, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn copy_from_in( &mut self, dst_offset: usize, src: &RawBuffer, src_offset: usize, size: usize, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn copy_from_rect_raw_in( &mut self, dst_origin: [usize; 3], src_origin: [usize; 3], region: [usize; 3], dst_row_pitch: Option<usize>, dst_slice_pitch: Option<usize>, src_row_pitch: Option<usize>, src_slice_pitch: Option<usize>, src: &RawBuffer, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
pub unsafe fn fill_raw_in<T>( &mut self, v: T, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<RawEvent>
cl1_2
only.pub unsafe fn map_read_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*const c_void, RawEvent)>
pub unsafe fn map_write_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>
pub unsafe fn map_read_write_in( &self, range: BufferRange, queue: &RawCommandQueue, wait: WaitList<'_> ) -> Result<(*mut c_void, RawEvent)>
Methods from Deref<Target = RawMemObject>§
pub unsafe fn retain(&self) -> Result<()>
pub fn id(&self) -> cl_mem
pub fn id_ref(&self) -> &cl_mem
pub fn id_ref_mut(&mut self) -> &mut cl_mem
sourcepub fn ty(&self) -> Result<MemObjectType>
pub fn ty(&self) -> Result<MemObjectType>
Returns the memory obejct’s type
sourcepub fn associated_memobject(&self) -> Result<Option<RawMemObject>>
pub fn associated_memobject(&self) -> Result<Option<RawMemObject>>
Return memory object from which memobj is created.
sourcepub fn flags(&self) -> Result<MemFlags>
pub fn flags(&self) -> Result<MemFlags>
Return the flags argument value specified when memobj is created.
sourcepub fn size(&self) -> Result<usize>
pub fn size(&self) -> Result<usize>
Return actual size of the data store associated with memobj in bytes.
sourcepub fn host_ptr(&self) -> Result<Option<NonNull<c_void>>>
pub fn host_ptr(&self) -> Result<Option<NonNull<c_void>>>
If memobj is created with a host_ptr specified, return the host_ptr argument value specified when memobj is created.
sourcepub fn map_count(&self) -> Result<u32>
pub fn map_count(&self) -> Result<u32>
Map count. The map count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for debugging.
sourcepub fn reference_count(&self) -> Result<u32>
pub fn reference_count(&self) -> Result<u32>
Return memobj reference count. The reference count returned should be considered immediately stale. It is unsuitable for general use in applications. This feature is provided for identifying memory leaks.
sourcepub fn context(&self) -> Result<RawContext>
pub fn context(&self) -> Result<RawContext>
Return context specified when memory object is created.
sourcepub fn offset(&self) -> Result<usize>
pub fn offset(&self) -> Result<usize>
Return offset if memobj is a sub-buffer object created using create_sub_buffer. Returns 0 if memobj is not a subbuffer object.
sourcepub fn uses_svm_pointer(&self) -> Result<bool>
Available on crate feature cl2
only.
pub fn uses_svm_pointer(&self) -> Result<bool>
cl2
only.Return true
if memobj is a buffer object that was created with CL_MEM_USE_HOST_PTR or is a sub-buffer object of a buffer object that was created with CL_MEM_USE_HOST_PTR and the host_ptr specified when the buffer object was created is a SVM pointer; otherwise returns false
.
sourcepub fn on_destruct(&self, f: impl 'static + FnOnce() + Send) -> Result<()>
pub fn on_destruct(&self, f: impl 'static + FnOnce() + Send) -> Result<()>
Adds a callback to be executed when the memory object is destructed by OpenCL.