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

clCreateFromGLBuffer - Creates an OpenCL buffer object from an OpenGL buffer object.

Authors

TheKhronosGroup

Description

       The size of the GL buffer object data store at the time clCreateFromGLBuffer is called will be used as
       the size of buffer object returned by clCreateFromGLBuffer. If the state of a GL buffer object is
       modified through the GL API (e.g.  glBufferData) while there exists a corresponding CL buffer object,
       subsequent use of the CL buffer object will result in undefined behavior.

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

       The CL buffer object created using clCreateFromGLBuffer can also be used to create a CL 1D image buffer
       object

Errors

       Returns a valid non-zero OpenCL buffer object and errcode_ret is set to CL_SUCCESS if the buffer 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 bufobj is not a GL buffer object or is a GL buffer object but does not have
           an existing data store e or the size of the buffer is 0. .

       •   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

       clCreateFromGLBuffer - Creates an OpenCL buffer object from an OpenGL buffer object.

       cl_memclCreateFromGLBuffer(cl_contextcontext,cl_mem_flagsflags,GLuintbufobj,cl_int*errcode_ret);

Notes

        1. OpenCL Specification
           page 49, section 9.7.2 - CL Buffer Objects -> GL Buffer Objects

The Khronos Group                                  11/18/2024                         CLCREATEFROMGLBUFFER(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 for 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.

        bufobj
           The name of a GL buffer object. The data store of the GL buffer object must have have been previously
           created by calling OpenGL function glBufferData, although its contents need not be initialized. The
           size of the data store will be used to determine the size of the CL buffer 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), clReleaseMemObject(3clc), clRetainMemObject(3clc)

Specification

OpenCLSpecification[1]

See Also