Description

Image objects specified as arguments to a kernel can be declared to be read-only, write-only or read-write. A kernel cannot read from and write to the same image object. The __read_only (or read_only) and __write_only (or write_only) qualifiers must be used with image object arguments to declare if the image object is being read or written by a kernel or function. The __read_write (or read_write) qualifier must be used with image object arguments of kernels and of user-defined functions to declare if the image object is being both read and written by the kernel. If no qualifier is provided, read_only is assumed.

In the following example

kernel void
foo (read_only image2d_t imageA,
     write_only image2d_t imageB)
{
    ...
}

imageA is a read-only 2D image object, and image is a write-only 2D image object.

The sampler-less read image and write image built-ins can be used with image declared with the __read_write (or read_write) qualifier. Calls to built-ins that read from an image using a sampler for images declared with the __read_write (or read_write) qualifier will be a compilation error.

Pipe objects specified as arguments to a kernel also use these access qualifiers. See the detailed description on how these access qualifiers can be used with pipes.

The __read_only, __write_only, __read_write, read_only, write_only and read_write names are reserved for use as access qualifiers and shall not be used otherwise.

See Also

Document Notes

For more information, see the OpenCL C Specification

This page is extracted from the OpenCL C Specification. Fixes and changes should be made to the Specification, not directly.

Copyright (c) 2014-2020 Khronos Group. This work is licensed under a Creative Commons Attribution 4.0 International License.