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
impl Context
Sourcepub const fn get(&self) -> cl_context
pub const fn get(&self) -> cl_context
Get the underlying OpenCL cl_context.
Sourcepub 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>
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.
Sourcepub fn from_device(device: &Device) -> Result<Self>
pub fn from_device(device: &Device) -> Result<Self>
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn get_svm_mem_capability(&self) -> cl_device_svm_capabilities
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.
Sourcepub fn get_supported_image_formats(
&self,
flags: cl_mem_flags,
image_type: cl_mem_object_type,
) -> Result<Vec<cl_image_format>>
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.
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>
pub fn devices(&self) -> &[cl_device_id] ⓘ
pub fn default_device(&self) -> cl_device_id
pub fn num_devices(&self) -> cl_uint
pub fn set_destructor_callback( &self, pfn_notify: Option<unsafe extern "C" fn(cl_context, *mut c_void)>, user_data: *mut c_void, ) -> Result<()>
pub fn reference_count(&self) -> Result<cl_uint>
pub fn properties(&self) -> Result<Vec<intptr_t>>
Sourcepub fn get_data(&self, param_name: cl_context_info) -> Result<Vec<u8>>
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.
pub unsafe fn terminate(&self) -> Result<()>
Sourcepub fn create_event_from_gl_sync_khr(&self, sync: cl_GLsync) -> Result<cl_event>
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.
Sourcepub unsafe fn create_event_from_egl_sync_khr(
&self,
sync: CLeglSyncKHR,
display: CLeglDisplayKHR,
) -> Result<cl_event>
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.