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 fn from_devices(
devices: &[*mut c_void],
properties: &[isize],
pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>,
user_data: *mut c_void,
) -> Result<Context, ClError>
pub fn from_devices( devices: &[*mut c_void], properties: &[isize], pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>, user_data: *mut c_void, ) -> Result<Context, ClError>
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_sub_devices(
sub_devices: &[SubDevice],
properties: &[isize],
pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>,
user_data: *mut c_void,
) -> Result<Context, ClError>
pub fn from_sub_devices( sub_devices: &[SubDevice], properties: &[isize], pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>, user_data: *mut c_void, ) -> Result<Context, ClError>
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: u64,
properties: &[isize],
pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>,
user_data: *mut c_void,
) -> Result<Context, ClError>
pub fn from_device_type( device_type: u64, properties: &[isize], pfn_notify: Option<unsafe extern "C" fn(*const i8, *const c_void, usize, *mut c_void)>, user_data: *mut c_void, ) -> Result<Context, ClError>
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) -> u64
pub fn get_svm_mem_capability(&self) -> u64
Get the common Shared Virtual Memory (SVM) capabilities of the devices in the Context.
Sourcepub fn get_supported_image_formats(
&self,
flags: u64,
image_type: u32,
) -> Result<Vec<cl_image_format>, ClError>
pub fn get_supported_image_formats( &self, flags: u64, image_type: u32, ) -> Result<Vec<cl_image_format>, ClError>
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: u64, properties: *const isize, memory: *mut c_void, size: usize, ) -> Result<*mut c_void, ClError>
pub fn devices(&self) -> &[*mut c_void]
pub fn default_device(&self) -> *mut c_void
pub fn num_devices(&self) -> u32
pub fn set_destructor_callback( &self, pfn_notify: Option<unsafe extern "C" fn(*mut c_void, *mut c_void)>, user_data: *mut c_void, ) -> Result<(), ClError>
pub fn reference_count(&self) -> Result<u32, ClError>
pub fn properties(&self) -> Result<Vec<isize>, ClError>
Sourcepub fn get_data(&self, param_name: u32) -> Result<Vec<u8>, ClError>
pub fn get_data(&self, param_name: u32) -> Result<Vec<u8>, ClError>
Get data about an OpenCL context. Calls clGetContextInfo to get the desired data about the context.
pub unsafe fn terminate(&self) -> Result<(), ClError>
Sourcepub fn create_event_from_gl_sync_khr(
&self,
sync: *mut c_void,
) -> Result<*mut c_void, ClError>
pub fn create_event_from_gl_sync_khr( &self, sync: *mut c_void, ) -> Result<*mut c_void, ClError>
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: *mut c_void,
display: *mut c_void,
) -> Result<*mut c_void, ClError>
pub unsafe fn create_event_from_egl_sync_khr( &self, sync: *mut c_void, display: *mut c_void, ) -> Result<*mut c_void, ClError>
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.