CLCREATEFROMGLRENDER(3clc)
πΈ NAME πΈ
bestie, meet clCreateFromGLRenderbuffer β she makes an OpenCL 2D image object out of an OpenGL renderbuffer object. that's the whole gig. and she eats every time π
cl_mem clCreateFromGLRenderbuffer(cl_context context,
cl_mem_flags flags,
GLuint renderbuffer,
cl_int * errcode_ret);
(this is the <cyan>3clc</cyan> manual btw, OpenCL Manual energy, iykyk β¨)
π PARAMETERS π
contextβ a valid OpenCL context that was created from an OpenGL context. like, she needs the GL glue or she's not coming to the party. no cap.flagsβ a bit-field specifying usage info. go peek at the table over inclCreateBuffer(3clc)for what flags even means. β οΈ only these three are allowed here:CL_MEM_READ_ONLY,CL_MEM_WRITE_ONLY, andCL_MEM_READ_WRITEβ the ones specified in that table atclCreateBuffer(3clc). that's it, that's the list, don't try anything else πrenderbufferβ the name of a GL renderbuffer object. π«Ά heads up: the renderbuffer storage must be specified before the image object can be created, periodt. the renderbuffer format and dimensions that OpenGL defines are what get used to create the 2D image object. and only GL renderbuffers whose internal formats map to an appropriate image channel order and data type β the ones in the table of supported Image Channel Order Values and the table of supported Image Channel Data Types forcl_image_format(3clc)β can be used to create the 2D image object. so check the tables, bestie πerrcode_retβ returns an appropriate error code, all the deets below. iferrcode_retisNULL, then no error code comes back at all. she's quiet like that π€«
π« DESCRIPTION π«
okay so here's the tea, and it's a little scary: if the state of a GL renderbuffer object gets modified through the GL API β like, changes to the dimensions or the format used to represent pixels of the GL renderbuffer via appropriate GL API calls such as glRenderbufferStorage β while a corresponding CL image object exists, then subsequent use of the CL image object will result in undefined behavior. π not a vibe. don't do that.
you can use clRetainMemObject(3clc) and clReleaseMemObject(3clc) to retain and release the image objects. those are your girls for keeping the refcount situation cute β¨
the table below (Table 9.4) is the β¨canonβ¨ list of GL texture internal formats and their matching CL image formats. if a GL texture object with an internal format from this table gets successfully created by OpenGL, then a mapping to one of the corresponding CL image format(s) in that table is guaranteed. texture objects created with other OpenGL internal formats may β but are not guaranteed to β have a mapping to a CL image format. and if such mappings do exist, they're guaranteed to preserve all color components, data types, and at least the number of bits/component that OpenGL actually allocated for that format. slay π
GL_RGBA8βCL_RGBA, CL_UNORM_INT8orCL_BGRA, CL_UNORM_INT8GL_RGBA,GL_UNSIGNED_INT_8_8_8_8_REVβCL_RGBA, CL_UNORM_INT8GL_BGRA,GL_UNSIGNED_INT_8_8_8_8_REVβCL_BGRA, CL_UNORM_INT8GL_RGBA16βCL_RGBA, CL_UNORM_INT16GL_RGBA8I,GL_RGBA8I_EXTβCL_RGBA, CL_SIGNED_INT8GL_RGBA16I,GL_RGBA16I_EXTβCL_RGBA, CL_SIGNED_INT16GL_RGBA32I,GL_RGBA32I_EXTβCL_RGBA, CL_SIGNED_INT32GL_RGBA8UI,GL_RGBA8UI_EXTβCL_RGBA, CL_UNSIGNED_INT8GL_RGBA16UI,GL_RGBA16UI_EXTβCL_RGBA, CL_UNSIGNED_INT16GL_RGBA32UI,GL_RGBA32UI_EXTβCL_RGBA, CL_UNSIGNED_INT32GL_RGBA16F,GL_RGBA16F_ARBβCL_RGBA, CL_HALF_FLOATGL_RGBA32F,GL_RGBA32F_ARBβCL_RGBA, CL_FLOAT
π¦ ERRORS π¦
she returns a valid non-zero OpenCL image object and errcode_ret gets set to CL_SUCCESS if the image object is created successfully. π otherwise she returns a NULL value, and one of these error values comes back in errcode_ret:
CL_INVALID_CONTEXTβ ifcontextis not a valid context, or was not created from a GL context. πCL_INVALID_VALUEβ if the values specified inflagsare not valid.CL_INVALID_GL_OBJECTβ ifrenderbufferis not a GL renderbuffer object, or if the width or height ofrenderbufferis zero.CL_INVALID_IMAGE_FORMAT_DESCRIPTORβ if the OpenGL renderbuffer internal format does not map to a supported OpenCL image format.CL_INVALID_OPERATIONβ ifrenderbufferis a multi-sample GL renderbuffer object. (not her thing, sorry π«)CL_OUT_OF_RESOURCESβ if there's a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYβ if there's a failure to allocate resources required by the OpenCL implementation on the host.
π SPECIFICATION π
OpenCL Specification[1] β yes, the actual spec, main character behaviour π
π SEE ALSO π
cl_khr_gl_sharing(3clc)clCreateBuffer(3clc)cl_image_format(3clc)clRetainMemObject(3clc)clReleaseMemObject(3clc)
π§ AUTHORS π§
The Khronos Group π
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
β NOTES β
- OpenCL Specification β page 53, section 9.7.4 - CL Image Objects -> GL Renderbuffers π
and that's the whole page bestie!! this was the 3clc OpenCL Manual, brought to you by The Khronos Group, dated 01/14/2021, page CLCREATEFROMGLRENDER(3clc). go forth and map those renderbuffers, you absolute icon πβ¨ππ¦
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms