Creates an OpenCL image object, image array object, or image buffer object from an OpenGL texture object, texture array object, texture buffer object, or a single face of an OpenGL cubemap texture object.
cl_mem clCreateFromGLTexture(cl_context context,
cl_mem_flags flags,
GLenum texture_target,
GLint miplevel,
GLuint texture,
cl_int * errcode_ret)context-
A valid OpenCL context created from an OpenGL context.
flags-
A bit-field that is used to specify usage information. Refer to the table for
clCreateBufferfor a description offlags. Only the valuesCL_MEM_READ_ONLY,CL_MEM_WRITE_ONLYandCL_MEM_READ_WRITEcan be used. texture_target-
texture_targetThis value must be one ofGL_TEXTURE_1D,GL_TEXTURE_1D_ARRAY,GL_TEXTURE_BUFFER,GL_TEXTURE_2D,GL_TEXTURE_2D_ARRAY,GL_TEXTURE_3D,GL_TEXTURE_CUBE_MAP_POSITIVE_X,GL_TEXTURE_CUBE_MAP_POSITIVE_Y,GL_TEXTURE_CUBE_MAP_POSITIVE_Z,GL_TEXTURE_CUBE_MAP_NEGATIVE_X,GL_TEXTURE_CUBE_MAP_NEGATIVE_Y,GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, orGL_TEXTURE_RECTANGLE. (GL_TEXTURE_RECTANGLErequires OpenGL 3.1. Alternatively,GL_TEXTURE_RECTANGLE_ARBmay be specified if the OpenGL extensionGL_ARB_texture_rectangleis supported.)texture_targetis used only to define the image type oftexture. No reference to a bound GL texture object is made or implied by this parameter.If the
cl_khr_gl_msaa_sharingextension is enabled,texture_targetmay beGL_TEXTURE_2D_MULTISAMPLEorGL_TEXTURE_2D_MULTISAMPLE_ARRAY.If
texture_targetisGL_TEXTURE_2D_MULTISAMPLE,clCreateFromGLTexturecreates an OpenCL 2D multi-sample image object from an OpenGL 2D multi-sample textureIf
texture_targetisGL_TEXTURE_2D_MULTISAMPLE_ARRAY,clCreateFromGLTexturecreates an OpenCL 2D multi-sample array image object from an OpenGL 2D multi-sample texture. miplevel-
The mipmap level to be used. If
texture_targetisGL_TEXTURE_BUFFER, miplevel must be 0. Implementations may returnCL_INVALID_OPERATIONfor miplevel values > 0 texture-
The name of a GL 1D, 2D, 3D, 1D array, 2D array, cubemap, rectangle or buffer texture object. The texture object must be a complete texture as per OpenGL rules on texture completeness. The
textureformat and dimensions defined by OpenGL for the specifiedmiplevelof the texture will be used to create the OpenCL image memory object. Only GL texture objects with an internal format that maps to appropriate image channel order and data type specified in tables 5.5 and 5.6 (seecl_image_format) may be used to create the OpenCL image memory object. errcode_ret-
Returns an appropriate error code as described below. If
errcode_retis NULL, no error code is returned.
If the state of a GL texture object is modified through the GL API (e.g.
glTexImage2D, glTexImage3D or the values of the texture parameters GL_TEXTURE_BASE_LEVEL or GL_TEXTURE_MAX_LEVEL are modified) while there exists a corresponding CL image object, subsequent use of the CL image object will result in undefined behavior.
The clRetainMemObject and clReleaseMemObject functions can be used to retain and release the image objects.
Returns a valid non-zero OpenCL image object and errcode_ret is set to CL_SUCCESS if the image object is created successfully.
Otherwise, it returns a NULL value with one of the following error values returned in errcode_ret:
-
CL_INVALID_CONTEXTifcontextis not a valid context or was not created from a GL context. -
CL_INVALID_VALUEif values specified inflagsare not valid or if value specified intexture_targetis not one of the values specified in the description oftexture_target. -
CL_INVALID_MIP_LEVELifmiplevelis less than the value oflevelbase(for OpenGL implementations) or zero (for OpenGL ES implementations); or greater than the value ofq(for both OpenGL and OpenGL ES).levelbaseandqare defined for the texture in section 3.8.10 (Texture Completeness) of the OpenGL 2.1 specification and section 3.7.10 of the OpenGL ES 2.0. -
CL_INVALID_MIP_LEVELifmiplevelis greater than zero and the OpenGL implementation does not support creating from non-zero mipmap levels. -
CL_INVALID_GL_OBJECTiftextureis not a GL texture object whose type matchestexture_target, if the specifiedmipleveloftextureis not defined, or if the width or height of the specifiedmiplevelis zero or if the GL texture object is incomplete. -
CL_INVALID_IMAGE_FORMAT_DESCRIPTORif the OpenGL texture internal format does not map to a supported OpenCL image format. -
CL_INVALID_OPERATIONiftextureis a GL texture object created with a border width value greater than zero. -
CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device. -
CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.