C Specification
To query the OpenCL device corresponding to an OpenGL context, call the function
// Provided by cl_khr_gl_sharing
cl_int clGetGLContextInfoKHR(
const cl_context_properties* properties,
cl_gl_context_info param_name,
size_t param_value_size,
void* param_value,
size_t* param_value_size_ret);
Parameters
-
properties points to an property list whose format and valid contents are identical to the properties argument of clCreateContext. properties must identify a single valid GL context or GL share group object.
-
param_name is a constant that specifies the device types to query, and must be one of the values shown in the Supported Device Types table below.
-
param_value is a pointer to memory where the result of the query is returned, as described in the Supported Device Types table. If param_value is
NULL, it is ignored. -
param_value_size specifies the size in bytes of memory pointed to by param_value. This size must be greater than or equal to the size of the return type specified in the Supported Device Types table. If param_value is
NULL, it is ignored. -
param_value_size_ret returns the actual size in bytes of data being queried by param_value. If param_value_size_ret is
NULL, it is ignored.
Description
| param_name | Return Type | Information returned in param_value |
|---|---|---|
provided by the |
|
Return the OpenCL device currently associated with the specified OpenGL context. |
provided by the |
|
Return all OpenCL devices which may be associated with the specified OpenGL context. |
clGetGLContextInfoKHR returns CL_SUCCESS if the function is executed
successfully.
If no device(s) exist corresponding to param_name, the call will not fail,
but the value of param_value_size_ret will be zero.
Otherwise, it returns one of the following errors:
-
CL_INVALID_if a context was specified for an OpenGL or OpenGL ES implementation using the EGL, GLX, or WGL binding APIs, as described forGL_ SHAREGROUP_ REFERENCE_ KHR clCreateContext; and any of the following conditions hold:-
The specified display and context properties do not identify a valid OpenGL or OpenGL ES context.
-
The specified context does not support buffer and renderbuffer objects.
-
The specified context is not compatible with the OpenCL context being created (for example, it exists in a physically distinct address space, such as another hardware device; or it does not support sharing data with OpenCL due to implementation restrictions).
-
-
CL_INVALID_if a share group was specified for a CGL-based OpenGL implementation by setting the propertyGL_ SHAREGROUP_ REFERENCE_ KHR CL_CGL_, and the specified share group does not identify a valid CGL share group object.SHAREGROUP_ KHR -
CL_INVALID_if a context was specified as described above and any of the following conditions hold:OPERATION -
A context or share group object was specified for one of CGL, EGL, GLX, or WGL and the OpenGL implementation does not support that window-system binding API.
-
More than one of the properties
CL_CGL_,SHAREGROUP_ KHR CL_EGL_,DISPLAY_ KHR CL_GLX_, andDISPLAY_ KHR CL_WGL_is set to a non-default value.HDC_ KHR -
Both of the properties
CL_CGL_andSHAREGROUP_ KHR CL_GL_are set to non-default values.CONTEXT_ KHR
-
-
CL_INVALID_if a property name specified in properties is invalid.VALUE -
CL_INVALID_if param_name is not one of the supported values, or if the size in bytes specified by param_value_size is less than size of the return type specified in the Supported Device Types table and param_value is notVALUE NULL. -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the deviceOF_ RESOURCES -
CL_OUT_if there is a failure to allocate resources required by the OpenCL implementation on the host.OF_ HOST_ MEMORY
Document Notes
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.