CLENQUEUECOPYBUFFERT(3clc)
โจ NAME โจ
okay bestie, gather round ๐ this one is clEnqueueCopyBufferToImage from the OpenCL Manual โ and it's exactly what it sounds like: it enqueues a command to copy a buffer object to an image object. like, buffer data goes in, image comes out. the glow-up is real. ๐
(this is page CLENQUEUECOPYBUFFERT(3clc) btw, iykyk ๐)
๐ฆ SYNOPSIS ๐ฆ
cl_int clEnqueueCopyBufferToImage(cl_command_queue command_queue,
cl_mem src_buffer, cl_mem dst_image,
size_t src_offset,
const size_t *dst_origin,
const size_t *region,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event);
๐ธ PARAMETERS ๐ธ
command_queueโ a valid command-queue, periodt. and the OpenCL context linked tocommand_queue,src_buffer, anddst_imagehas to be the same one โ no mixing contexts, that's not the vibe.src_bufferโ a valid buffer object ๐dst_imageโ a valid image object โจsrc_offsetโ where you start copying data from insrc_buffer. that's it, that's the starting line.dst_originโ this one's the โจcoordinate queenโจ. it defines the(x, y, z)offset in pixels for a 1D, 2D or 3D image; or the(x, y)offset plus the image index in a 2D image array; or the(x)offset plus the image index in a 1D image array. here's the rules, no cap:- if
dst_imageis a 2D image object,dst_origin[2]must be 0. - if
dst_imageis a 1D image or 1D image buffer object,dst_origin[1]anddst_origin[2]must be 0. - if
dst_imageis a 1D image array object,dst_origin[2]must be 0. - if
dst_imageis a 1D image array object,dst_origin[1]describes the image index in that 1D image array. - if
dst_imageis a 2D image array object,dst_origin[2]describes the image index in that 2D image array.
- if
regionโ the size situation ๐ it defines the(width, height, depth)in pixels of the 1D, 2D or 3D rectangle; or the(width, height)in pixels of the 2D rectangle plus the number of images of a 2D image array; or the(width)in pixels of the 1D rectangle plus the number of images of a 1D image array. rules again:- if
dst_imageis a 2D image object,region[2]must be 1. - if
dst_imageis a 1D image or 1D image buffer object,region[1]andregion[2]must be 1. - if
dst_imageis a 1D image array object,region[2]must be 1.
- if
and now the math, bestie, stay with me ๐งฎ โ the size in bytes of the region to be copied from src_buffer, called src_cb, gets computed like this:
width * height * depth * bytes/image_elementifdst_imageis a 3D image objectwidth * height * bytes/image_elementifdst_imageis a 2D imagewidth * height * arraysize * bytes/image_elementifdst_imageis a 2D image array objectwidth * bytes/image_elementifdst_imageis a 1D image or 1D image buffer objectwidth * arraysize * bytes/image_elementifdst_imageis a 1D image array object
event_wait_list,num_events_in_wait_listโ these two are a package deal ๐ซถ they specify events that need to finish before this particular command can run. the deets:- if
event_wait_listisNULL, then this particular command doesn't wait on any event to complete. - if
event_wait_listisNULL,num_events_in_wait_listmust be 0. - if
event_wait_listis notNULL, the list of events pointed to byevent_wait_listmust be valid andnum_events_in_wait_listmust be greater than 0. - the events in
event_wait_listact as synchronization points โ - the context associated with the events in
event_wait_listandcommand_queuemust be the same. - the memory associated with
event_wait_listcan be reused or freed after the function returns โ go ahead, reclaim that memory, you deserve it ๐
- if
eventโ returns an event object that identifies this particular copy command, and you can use it to query or queue a wait for this particular command to complete. but lowkey:eventcan beNULL, and if it is, the application won't be able to query the status of this command or queue a wait for it to complete. in that caseclEnqueueBarrierWithWaitList(3clc)can be used instead. and heads up โ ๏ธ ifevent_wait_listand theeventarguments are both notNULL, theeventargument should not refer to an element of theevent_wait_listarray.
๐ ERRORS ๐
clEnqueueCopyBufferToImage returns CL_SUCCESS if the function is executed successfully ๐ otherwise, it hands you one of these:
CL_INVALID_COMMAND_QUEUEifcommand_queueis not a valid command-queue.CL_INVALID_CONTEXTif the context associated withcommand_queue,src_bufferanddst_imageare not the same, or if the context associated withcommand_queueand events inevent_wait_listare not the same.CL_INVALID_MEM_OBJECTifsrc_bufferis not a valid buffer object anddst_imageis not a valid image object, or ifdst_imageis a 1D image buffer object created fromsrc_buffer.CL_INVALID_VALUEif the 1D, 2D, or 3D rectangular region specified bydst_originanddst_origin + regionrefers to a region outsidedst_origin, or if the region specified bysrc_offsetandsrc_offset + src_cbrefers to a region outsidesrc_buffer.CL_INVALID_VALUEif values indst_originandregiondo not follow the rules described in the argument description fordst_originandregion. (yes, the rules above. read them. ๐)CL_INVALID_EVENT_WAIT_LISTifevent_wait_listisNULLandnum_events_in_wait_list> 0, orevent_wait_listis notNULLandnum_events_in_wait_listis 0, or if event objects inevent_wait_listare not valid events.CL_MISALIGNED_SUB_BUFFER_OFFSETifsrc_bufferis a sub-buffer object and the offset specified when the sub-buffer object is created is not aligned to theCL_DEVICE_MEM_BASE_ADDR_ALIGNvalue for the device associated with the queue.CL_INVALID_IMAGE_SIZEif image dimensions (image width, height, specified or computed row and/or slice pitch) fordst_imageare not supported by the device associated with the queue.CL_INVALID_IMAGE_FORMATif image format (image channel order and data type) fordst_imageare not supported by the device associated with the queue.CL_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for the data store associated withsrc_bufferordst_image.CL_INVALID_OPERATIONif the device associated withcommand_queuedoes not support images โ i.e.CL_DEVICE_IMAGE_SUPPORTspecified in the table of OpenCL Device Queries forclGetDeviceInfo(3clc)isCL_FALSE. no images, no service ๐ญ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.
๐ SPECIFICATION ๐
OpenCL Specification[1]
๐ SEE ALSO ๐
clEnqueueReadBuffer(3clc), clEnqueueWriteBuffer(3clc), clCreateBuffer(3clc), clEnqueueCopyBuffer(3clc), clEnqueueCopyImageToBuffer(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 110, section 5.3.4 - Copying between Image and Buffer Objects
and that's the whole page, bestie ๐ซถ brought to you by The Khronos Group, dated 01/14/2021, living its life as CLENQUEUECOPYBUFFERT(3clc) in the OpenCL Manual. go copy that buffer into that image. slay. ๐
โจ
๐ฆ 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