NAME¶clCreateContextFromType - Create an OpenCL context from a device type that identifies the specific device(s) to use.
cl_context clCreateContextFromType(const cl_context_properties *properties, cl_device_type device_type, void (CL_CALLBACK *pfn_notify) (const char *errinfo, const void *private_info, size_t cb, void *user_data), void *user_data, cl_int *errcode_ret);
If the cl_khr_gl_sharing(3clc) extension is supported, properties points to an attribute list whose format and valid contents are identical to the properties argument of clCreateContext(3clc) which is: properties specifies a list of context property names and their corresponding values. Each property name is immediately followed by the corresponding desired value. The list is terminated with 0. The list of supported properties is described in the table below. properties can be NULL in which case the platform that is selected is implementation-defined.
|cl_context_properties enum||Property value||Description|
|CL_CONTEXT_PLATFORM||cl_platform_id||Specifies the platform to use.|
|CL_CONTEXT_INTEROP_USER_SYNC||cl_bool||Specifies whether the user is responsible for synchronization between OpenCL and other APIs. Please refer to the specific sections in the OpenCL 1.2 extension specification that describe sharing with other APIs for restrictions on using this flag. If CL_CONTEXT_INTEROP_USER_SYNC is not specified, a default of CL_FALSE is assumed.|
|CL_CONTEXT_D3D10_DEVICE_KHR||ID3D10Device *||Specifies the ID3D10Device * to use for Direct3D 10 interoperability. The default value is NULL (applies if the extension cl_khr_d3d10_sharing(3clc) is supported)|
|CL_CONTEXT_ADAPTER_D3D9_KHR||IDirect3DDevice9 *||Specifies an IDirect3DDevice9 to use for D3D9 intero (applies if the cl_khr_dx9_media_sharing(3clc) extension is supported)|
|CL_CONTEXT_ADAPTER_D3D9EX_KHR||IDirect3DDeviceEx*||Specifies an IDirect3DDevice9Ex to use for D3D9 interop (applies if the cl_khr_dx9_media_sharing(3clc) extension is supported)|
|CL_CONTEXT_ADAPTER_DXVA_KHR||IDXVAHD_Device *||Specifies an IDXVAHD_Device to use for DXVA interop (applies if the cl_khr_dx9_media_sharing(3clc) extension is supported)|
|CL_GL_CONTEXT_KHR||0, OpenGL context handle||OpenGL context to associated the OpenCL context with (available if the cl_khr_gl_sharing(3clc) extension is enabled)|
|CL_CGL_SHAREGROUP_KHR||0, CGL share group handle||CGL share group to associate the OpenCL context with (available if the cl_khr_gl_sharing(3clc) extension is enabled)|
|CL_EGL_DISPLAY_KHR||EGL_NO_DISPLAY, EGLDisplay handle||CGL share group to associate the OpenCL context with (available if the cl_khr_gl_sharing(3clc) extension is enabled)|
|CL_GLX_DISPLAY_KHR||None, X handle||X Display an OpenGL context was created with respect to (available if the cl_khr_gl_sharing(3clc) extension is enabled)|
|CL_WGL_HDC_KHR||0, HDC handle||HDC an OpenGL context was created with respect to (available if the cl_khr_gl_sharing(3clc) extension is enabled)|
|CL_CONTEXT_D3D11_DEVICE_KHR||ID3D11Device *||Specifies the ID3D11Device * to use for Direct3D 11 interoperability. The default value is NULL * (applies if the cl_khr_d3d11_sharing(3clc) extension is supported)|
|CL_DEVICE_TYPE_CPU||An OpenCL device that is the host processor. The host processor runs the OpenCL implementations and is a single or multi-core CPU.|
|CL_DEVICE_TYPE_GPU||An OpenCL device that is a GPU. By this we mean that the device can also be used to accelerate a 3D API such as OpenGL or DirectX.|
|CL_DEVICE_TYPE_ACCELERATOR||Dedicated OpenCL accelerators (for example the IBM CELL Blade). These devices communicate with the host processor using a peripheral interconnect such as PCIe.|
|CL_DEVICE_TYPE_CUSTOM||Dedicated accelerators that do not support programs written in OpenCL C.|
|CL_DEVICE_TYPE_DEFAULT||The default OpenCL device in the system. The default device cannot be a CL_DEVICE_TYPE_CUSTOM device.|
|CL_DEVICE_TYPE_ALL||All OpenCL devices available in the system except CL_DEVICE_TYPE_CUSTOM devices.|
errinfo is a pointer to an error string.
private_info and cb represent a pointer to binary data that is returned by the OpenCL implementation that can be used to log additional information helpful in debugging the error.
user_data is a pointer to user supplied data.
There are a number of cases where error notifications need to be delivered due to an error that occurs outside a context. Such notifications may not be delivered through the pfn_notify callback. Where these notifications go is implementation-defined.
DESCRIPTION¶Only devices that are returned by clGetDeviceIDs(3clc) for device_type are used to create the context. The context does not reference any sub-devices that may have been created from these devices.
NOTES¶clCreateContextFromType may return all or a subset of the actual physical devices present in the platform and that match device_type.
clCreateContextFromType and clCreateContext(3clc) perform an implicit retain. This is very helpful for 3rd party libraries, which typically get a context passed to them by the application. However, it is possible that the application may delete the context without informing the library. Allowing functions to attach to (i.e. retain) and release a context solves the problem of a context being used by a library no longer being valid.
ERRORS¶clCreateContextFromType returns a valid non-zero context and errcode_ret is set to CL_SUCCESS if the context is created successfully. Otherwise, it returns a NULL value with the following error vlaues returned in errcode_ret:
and any of the following conditions hold:
SEE ALSO¶clCreateContext(3clc), clGetContextInfo(3clc), clReleaseContext(3clc), clRetainContext(3clc), clGetContextInfo(3clc), classDiagram(3clc)
AUTHORS¶The Khronos Group
COPYRIGHT¶Copyright © 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
- OpenCL Specification
|02/03/2019||The Khronos Group|