C Specification

#pragma OPENCL EXTENSION cl_khr_gl_depth_images : enable


The cl_khr_gl_depth_images extension extends CL / GL sharing (i.e. the cl_khr_gl_sharing extension) defined in section 9.7 to allow a CL depth image to be created from a GL depth or depth-stencil texture. If this extension is supported by an implementation, the string cl_khr_gl_depth_images will be present in the CL_PLATFORM_EXTENSIONS string described in table 4.1 or CL_DEVICE_EXTENSIONS string described in table 4.3.

Depth images with an image channel order of CL_DEPTH_STENCIL can only be created using the clCreateFromGLTexture API.

For the image format given by channel order of CL_DEPTH_STENCIL and channel data type of CL_UNORM_INT24, the depth is stored as an unsigned normalized 24-bit value.

For the image format given by channel order of CL_DEPTH_STENCIL and channel data type of CL_FLOAT, each pixel is two 32-bit values. The depth is stored as a single precision floating-point value followed by the stencil which is stored as a 8-bit integer value.

The stencil value cannot be read or written using the read imagef and write imagef built-in functions in an OpenCL kernel.

Depth image objects with an image channel order = CL_DEPTH_STENCIL cannot be used as arguments to clEnqueueReadImage, clEnqueueWriteImage, clEnqueueCopyImage, clEnqueueCopyImageToBuffer, clEnqueueCopyBufferToImage, clEnqueueMapImage and clEnqueueFillImage and will return a CL_INVALID_OPERATION error.

The following new image formats are added to table 9.4 in section of the OpenCL 2.1 extension specification. If a GL texture object with an internal format from table 9.4 is successfully created by OpenGL, then there is guaranteed to be a mapping to one of the corresponding CL image format(s) in that table.

GL internal format CL image format (channel order, channel data type)









See Also

No cross-references are available

Document Notes

For more information, see the OpenCL Extension Specification at URL

Copyright 2014-2023 The Khronos Group Inc.

SPDX-License-Identifier: CC-BY-4.0