Enqueues a command to map a region of an image object into the host address space and returns a pointer to this mapped region.
void * clEnqueueMapImage
(
| cl_command_queue command_queue, |
cl_mem image, | |
cl_bool blocking_map, | |
cl_map_flags map_flags, | |
const size_t origin[3], | |
const size_t region[3], | |
size_t *image_row_pitch, | |
size_t *image_slice_pitch, | |
cl_uint num_events_in_wait_list, | |
const cl_event *event_wait_list, | |
cl_event *event, | |
cl_int *errcode_ret) |
command_queue
Must be a valid command-queue.
image
A valid image object. The OpenCL context associated with command_queue
and image
must be the same.
blocking_map
Indicates if the map operation is blocking
or non-blocking
. If blocking_map
is CL_TRUE
, clEnqueueMapImage
does not return until the specified region in image
can be mapped.
If blocking_map
is CL_FALSE
i.e. map operation is non-blocking, the pointer to the mapped region returned by clEnqueueMapImage
cannot be used until the map command has completed. The event
argument returns an event object which can be used to query the execution status of the map command. When the map command is completed, the application can access the contents of the mapped region using the pointer returned by clEnqueueMapImage
.
map_flags
Is a bit-field and can be set to CL_MAP_READ
to indicate that the region specified by (origin
, region
) in the image object is being mapped for reading, and/or CL_MAP_WRITE
to indicate that the region specified by (origin
, region
) in the image object is being mapped for writing.
origin,
region
Define the (x, y, z) offset in pixels and (width
, height
, depth
) in pixels of the 2D or 3D rectangle region that is to be mapped. If image
is a 2D image object, the z value given by origin
[2] must be 0 and the depth
value given by region
[2] must be 1.
image_row_pitch
Returns the scan-line pitch in bytes for the mapped region. This must be a non-NULL value.
image_slice_pitch
Returns the size in bytes of each 2D slice for the mapped region. For a 2D image, zero is returned if this argument is not NULL. For a 3D image, image_slice_pitch
must be a non-NULL value.
event_wait_list
,
num_events_in_wait_list
Specify events that need to complete before clEnqueueMapImage
can be executed. If event_wait_list
is NULL, then clEnqueueMapImage
does not wait on any event to complete. If event_wait_list
is NULL, num_events_in_wait_list
must be 0. If event_wait_list
is not NULL, the list of events pointed to by event_wait_list
must be valid and num_events_in_wait_list
must be greater than 0. The events specified in event_wait_list
act as synchronization points. The context associated with events in event_wait_list
and command_queue
must be the same.
event
Returns an event object that identifies this particular copy command and can be used to query or queue a wait for this particular command to complete. event
can be NULL in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete.
errcode_ret
Returns an appropriate error code. If errcode_ret
is NULL, no error code is returned.
If the image object is created with CL_MEM_USE_HOST_PTR
set in mem_flags
, the
following will be true:
host_ptr
specified in clCreateImage2d
or clCreateImage3d is guaranteed to contain the latest bits
in the region being mapped when the clEnqueueMapImage
command has completed.
clEnqueueMapImage
will be derived from
the host_ptr
specified when the image object is created.
Mapped image objects are unmapped using clEnqueueUnmapMemObject.
The contents of the regions of a memory object mapped for writing (i.e. CL_MAP_WRITE
is set
in map_flags
argument to clEnqueueMapBuffer or clEnqueueMapImage
) are considered to be
undefined until this region is unmapped. Reads and writes by a kernel executing on a device to a
memory region(s) mapped for writing are undefined.
Multiple command-queues can map a region or overlapping regions of a memory object for
reading (i.e. map_flags
= CL_MAP_READ
). The contents of the regions of a memory object
mapped for reading can also be read by kernels executing on a device(s). The behavior of writes
by a kernel executing on a device to a mapped region of a memory object is undefined.
Mapping (and unmapping) overlapped regions of a memory object for writing is
undefined.
The behavior of OpenCL function calls that enqueue commands that write or copy to regions of a memory object that are mapped is undefined.
The pointer returned maps a 2D or 3D region starting at origin
and is at least (image_row_pitch
* region
[1]) pixels in size for a 2D image, and is at least (image_slice_pitch
* region
[2]) pixels in size for a 3D image. The result of a memory access outside this region is undefined.
clEnqueueMapImage
will return a pointer to the mapped region if the function is executed successfully.
The errcode_ret
is set to CL_SUCCESS.
A NULL pointer is returned otherwise with one of the following error values returned in
errcode_ret
:
command_queue
is not a valid command-queue.
command_queue
and image
are not the same or if the context associated with command_queue
and events
in event_wait_list
are not the same.
image
is not a valid image object.
origin
, origin
+region
) is out of bounds or if
values specified in map_flags
are not valid.
image
is a 2D image object and origin
[2] is not equal to 0 or
region
[2] is not equal to 1.
image_row_pitch
is NULL.
image
is a 3D image object and image_slice_pitch
is NULL.
event_wait_list
is NULL and
num_events_in_wait_list
greater than 0, or event_wait_list
is not NULL and
num_events_in_wait_list
is 0, or if event objects in event_wait_list
are not valid events.
image
are not supported by device associated with queue
.
CL_MEM_USE_HOST_PTR
or CL_MEM_ALLOC_HOST_PTR
.
buffer
.
event_wait_list
is a negative integer value.
command_queue
does not support
images (i.e. CL_DEVICE_IMAGE_SUPPORT specified in the table of OpenCL Device Queries
for clGetDeviceInfo.