Struct Buffer

Source
pub struct Buffer<T> { /* private fields */ }
Expand description

An OpenCL buffer.

Implements the Drop trait to call release_mem_object when the object is dropped.

Implementations§

Source§

impl<T> Buffer<T>

Source

pub const fn new(buffer: cl_mem) -> Self

Source

pub unsafe fn create( context: &Context, flags: cl_mem_flags, count: size_t, host_ptr: *mut c_void, ) -> Result<Self>

Create a Buffer for a context.

  • context - a valid OpenCL context.
  • flags - a bit-field used to specify allocation and usage information about the image memory object being created, see: Memory Flags.
  • count - the number of T objects to be allocated.
  • host_ptr - a pointer to the buffer data that may already be allocated by the application.

returns a Result containing the new OpenCL buffer object or the error code from the OpenCL C API function.

Source

pub unsafe fn create_with_properties( context: &Context, properties: *const cl_mem_properties, flags: cl_mem_flags, count: size_t, host_ptr: *mut c_void, ) -> Result<Self>

Create an OpenCL buffer object for a context.

CL_VERSION_3_0

  • context - a valid OpenCL context.
  • properties - an optional null terminated list of properties.
  • flags - a bit-field used to specify allocation and usage information about the image memory object being created, see: Memory Flags.
  • count - the number of T objects to be allocated.
  • host_ptr - a pointer to the buffer data that may already be allocated by the application.

returns a Result containing the new OpenCL buffer object or the error code from the OpenCL C API function.

Source

pub unsafe fn create_from_gl_buffer( context: &Context, flags: cl_mem_flags, bufobj: cl_GLuint, ) -> Result<Self>

Create an OpenCL buffer object for a context from an OpenGL buffer.

  • context - a valid OpenCL context created from an OpenGL context.
  • flags - a bit-field used to specify allocation and usage information about the image memory object being created, see: Memory Flags.
  • bufobj - the OpenGL buffer.

returns a Result containing the new OpenCL buffer object or the error code from the OpenCL C API function.

Source

pub unsafe fn create_with_properties_intel( context: &Context, properties: *const cl_mem_properties_intel, flags: cl_mem_flags, count: size_t, host_ptr: *mut c_void, ) -> Result<Self>

Source

pub unsafe fn create_sub_buffer( &self, flags: cl_mem_flags, origin: usize, count: usize, ) -> Result<Self>

Create an new OpenCL buffer object from an existing buffer object.

See: SubBuffer Attributes.

  • flags - a bit-field used to specify allocation and usage information about the sub-buffer memory object being created, see: Memory Flags.
  • origin - the offset in number of objects of type T.
  • count - the size of the sub-buffer in number of objects of type T.

returns a Result containing the new OpenCL buffer object or the error code from the OpenCL C API function.

Trait Implementations§

Source§

impl<T> ClMem for Buffer<T>

Source§

fn get(&self) -> cl_mem

Source§

fn get_mut(&mut self) -> cl_mem

Source§

fn mem_type(&self) -> Result<cl_mem_object_type>

Source§

fn flags(&self) -> Result<cl_mem_flags>

Source§

fn size(&self) -> Result<size_t>

Source§

fn host_ptr(&self) -> Result<intptr_t>

Source§

fn map_count(&self) -> Result<cl_uint>

Source§

fn reference_count(&self) -> Result<cl_uint>

Source§

fn context(&self) -> Result<cl_context>

Source§

fn associated_memobject(&self) -> Result<cl_mem>

Source§

fn offset(&self) -> Result<size_t>

Source§

fn uses_svm_pointer(&self) -> Result<cl_uint>

Source§

fn properties(&self) -> Result<Vec<cl_ulong>>

CL_VERSION_3_0
Source§

fn get_mem_data(&self, param_name: cl_mem_info) -> Result<Vec<u8>>

Get memory data about an OpenCL memory object. Calls clGetMemObjectInfo to get the desired data about the memory object.
Source§

fn gl_object_info(&self) -> Result<(cl_GLuint, cl_GLuint)>

Query an OpenGL object used to create an OpenCL memory object. Read more
Source§

impl<T: Debug> Debug for Buffer<T>

Source§

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

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

impl<T> Drop for Buffer<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> From<Buffer<T>> for cl_mem

Source§

fn from(value: Buffer<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Send> Send for Buffer<T>

Source§

impl<T: Sync> Sync for Buffer<T>

Auto Trait Implementations§

§

impl<T> Freeze for Buffer<T>

§

impl<T> RefUnwindSafe for Buffer<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Buffer<T>
where T: Unpin,

§

impl<T> UnwindSafe for Buffer<T>
where T: UnwindSafe,

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.