Struct Context

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

An OpenCL context object. Implements the Drop trait to call release_context when the object is dropped.

Implementations§

Source§

impl Context

Source

pub const fn get(&self) -> cl_context

Get the underlying OpenCL cl_context.

Source

pub fn from_devices( devices: &[cl_device_id], properties: &[cl_context_properties], pfn_notify: Option<unsafe extern "C" fn(*const c_char, *const c_void, size_t, *mut c_void)>, user_data: *mut c_void, ) -> Result<Self>

Create a Context from a slice of cl_device_ids.

  • devices - a slice of cl_device_ids for an OpenCL Platform.
  • properties - a null terminated list of cl_context_properties, see Context Properties.
  • pfn_notify - an optional callback function that can be registered by the application.
  • user_data - passed as the user_data argument when pfn_notify is called.

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

Source

pub fn from_device(device: &Device) -> Result<Self>

Create a Context from a Device.

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

Source

pub fn from_sub_devices( sub_devices: &[SubDevice], properties: &[cl_context_properties], pfn_notify: Option<unsafe extern "C" fn(*const c_char, *const c_void, size_t, *mut c_void)>, user_data: *mut c_void, ) -> Result<Self>

Create a Context from a slice of SubDevices.

  • devices - a slice of SubDevices for an OpenCL Platform.
  • properties - a null terminated list of cl_context_properties, see Context Properties.
  • pfn_notify - an optional callback function that can be registered by the application.
  • user_data - passed as the user_data argument when pfn_notify is called.

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

Source

pub fn from_device_type( device_type: cl_device_type, properties: &[cl_context_properties], pfn_notify: Option<unsafe extern "C" fn(*const c_char, *const c_void, size_t, *mut c_void)>, user_data: *mut c_void, ) -> Result<Self>

Create a Context from a cl_device_type.

  • device_type - the cl_device_type to create a Context for.
  • properties - a null terminated list of cl_context_properties, see Context Properties.
  • pfn_notify - an optional callback function that can be registered by the application.
  • user_data - passed as the user_data argument when pfn_notify is called.

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

Source

pub fn get_svm_mem_capability(&self) -> cl_device_svm_capabilities

Get the common Shared Virtual Memory (SVM) capabilities of the devices in the Context.

Source

pub fn get_supported_image_formats( &self, flags: cl_mem_flags, image_type: cl_mem_object_type, ) -> Result<Vec<cl_image_format>>

Get the list of image formats supported by the Context for an image type, and allocation information.

Calls clGetSupportedImageFormats to get the desired information about the context.

  • flags - a bit-field used to specify allocation and usage information about the image memory object being created, see: Memory Flags.
  • image_type - describes the image type.

returns a Result containing the desired information in an InfoType enum or the error code from the OpenCL C API function.

Source

pub unsafe fn import_memory_arm( &self, flags: cl_mem_flags, properties: *const cl_import_properties_arm, memory: *mut c_void, size: size_t, ) -> Result<cl_mem>

Source

pub fn devices(&self) -> &[cl_device_id]

Source

pub fn default_device(&self) -> cl_device_id

Source

pub fn num_devices(&self) -> cl_uint

Source

pub fn set_destructor_callback( &self, pfn_notify: Option<unsafe extern "C" fn(cl_context, *mut c_void)>, user_data: *mut c_void, ) -> Result<()>

Source

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

Source

pub fn properties(&self) -> Result<Vec<intptr_t>>

Source

pub fn get_data(&self, param_name: cl_context_info) -> Result<Vec<u8>>

Get data about an OpenCL context. Calls clGetContextInfo to get the desired data about the context.

Source

pub unsafe fn terminate(&self) -> Result<()>

Source

pub fn create_event_from_gl_sync_khr(&self, sync: cl_GLsync) -> Result<cl_event>

Create a cl_event linked to an OpenGL sync object.
Requires the cl_khr_gl_event extension

  • sync - the sync object in the GL share group associated with context.

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

Source

pub unsafe fn create_event_from_egl_sync_khr( &self, sync: CLeglSyncKHR, display: CLeglDisplayKHR, ) -> Result<cl_event>

Create an event object linked to an EGL fence sync object.
Requires the cl_khr_egl_event extension

  • sync - the handle to an EGLSync object.
  • display - the handle to an EGLDisplay.

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

Source

pub fn create_semaphore_with_properties_khr( &self, sema_props: *const cl_semaphore_properties_khr, ) -> Result<cl_mem>

Source

pub fn get_supported_dx9_media_surface_formats_intel( &self, flags: cl_mem_flags, image_type: cl_mem_object_type, plane: cl_uint, ) -> Result<Vec<cl_uint>>

Source

pub fn get_supported_d3d10_texture_formats_intel( &self, flags: cl_mem_flags, image_type: cl_mem_object_type, ) -> Result<Vec<cl_uint>>

Source

pub fn get_supported_d3d11_texture_formats_intel( &self, flags: cl_mem_flags, image_type: cl_mem_object_type, plane: cl_uint, ) -> Result<Vec<cl_uint>>

Trait Implementations§

Source§

impl Debug for Context

Source§

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

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

impl Drop for Context

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<Context> for cl_context

Source§

fn from(value: Context) -> Self

Converts to this type from the input type.
Source§

impl Send for Context

Source§

impl Sync for Context

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<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.