logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

clCreateFromGLRenderbuffer - Creates an OpenCL 2D image object from an OpenGL renderbuffer object.

Authors

TheKhronosGroup

Description

       If the state of a GL renderbuffer object is modified through the GL API (i.e. changes to the dimensions
       or format used to represent pixels of the GL renderbuffer using appropriate GL API calls such as
       glRenderbufferStorage) while there exists a corresponding CL image object, subsequent use of the CL image
       object will result in undefined behavior.

       The clRetainMemObject(3clc) and clReleaseMemObject(3clc) functions can be used to retain and release the
       image objects.

       The table below (Table 9.4) describes the list of GL texture internal formats and the corresponding CL
       image formats. If a GL texture object with an internal format from the table below 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. Texture objects created with other OpenGL internal formats may (but are not
       guaranteed to) have a mapping to a CL image format; if such mappings exist, they are guaranteed to
       preserve all color components, data types, and at least the number of bits/component actually allocated
       by OpenGL for that format.
                    ┌──────────────────────────────────────┬────────────────────────────────────┐
                    │          GLinternalformatCLimageformat(channelorder,   │
                    │                                      │  channeldatatype)                │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │               GL_RGBA8CL_RGBA,CL_UNORM_INT8orCL_BGRA, │
                    │                                      │ CL_UNORM_INT8                      │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │ GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REVCL_RGBA,CL_UNORM_INT8       │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │ GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REVCL_BGRA,CL_UNORM_INT8       │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │              GL_RGBA16CL_RGBA,CL_UNORM_INT16       │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │       GL_RGBA8I,GL_RGBA8I_EXTCL_RGBA,CL_SIGNED_INT8       │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │      GL_RGBA16I,GL_RGBA16I_EXTCL_RGBA,CL_SIGNED_INT16      │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │      GL_RGBA32I,GL_RGBA32I_EXTCL_RGBA,CL_SIGNED_INT32      │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │      GL_RGBA8UI,GL_RGBA8UI_EXTCL_RGBA,CL_UNSIGNED_INT8      │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │     GL_RGBA16UI,GL_RGBA16UI_EXTCL_RGBA,CL_UNSIGNED_INT16     │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │     GL_RGBA32UI,GL_RGBA32UI_EXTCL_RGBA,CL_UNSIGNED_INT32     │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │      GL_RGBA16F,GL_RGBA16F_ARBCL_RGBA,CL_HALF_FLOAT       │
                    ├──────────────────────────────────────┼────────────────────────────────────┤
                    │      GL_RGBA32F,GL_RGBA32F_ARBCL_RGBA,CL_FLOAT          │
                    └──────────────────────────────────────┴────────────────────────────────────┘

Errors

       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_CONTEXT if context is not a valid context or was not created from a GL context.

       •   CL_INVALID_VALUE if values specified in flags are not valid.

       •   CL_INVALID_GL_OBJECT if renderbuffer is not a GL renderbuffer object or if the width or height of
           renderbuffer is zero.

       •   CL_INVALID_IMAGE_FORMAT_DESCRIPTOR if the OpenGL renderbuffer internal format does not map to a
           supported OpenCL image format.

       •   CL_INVALID_OPERATION if renderbuffer is a multi-sample GL renderbuffer object.

       •   CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation
           on the device.

       •   CL_OUT_OF_HOST_MEMORY if there is a failure to allocate resources required by the OpenCL
           implementation on the host.

Name

       clCreateFromGLRenderbuffer - Creates an OpenCL 2D image object from an OpenGL renderbuffer object.

       cl_memclCreateFromGLRenderbuffer(cl_contextcontext,cl_mem_flagsflags,GLuintrenderbuffer,cl_int*errcode_ret);

Notes

        1. OpenCL Specification
           page 53, section 9.7.4 - CL Image Objects -> GL Renderbuffers

The Khronos Group                                  11/18/2024                         CLCREATEFROMGLRENDER(3clc)

Parameters

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 at clCreateBuffer(3clc) for
           a description of flags. Only CL_MEM_READ_ONLY, CL_MEM_WRITE_ONLY, and CL_MEM_READ_WRITE values
           specified in the table at clCreateBuffer(3clc) can be used.

        renderbuffer
           The name of a GL renderbuffer object. The renderbuffer storage must be specified before the image
           object can be created. The renderbuffer format and dimensions defined by OpenGL will be used to
           create the 2D image object. Only GL renderbuffers with internal formats that map to appropriate image
           channel order and data type specified in the table of supported Image Channel Order Values and the
           table of supported Image Channel Data Types for cl_image_format(3clc) can be used to create the 2D
           image object.

        errcode_ret
           Returns an appropriate error code as described below. If errcode_ret is NULL, no error code is
           returned.

See Also

cl_khr_gl_sharing(3clc), clCreateBuffer(3clc), cl_image_format(3clc), clRetainMemObject(3clc),
       clReleaseMemObject(3clc)

Specification

OpenCLSpecification[1]

See Also