Access Qualifiers

Access Qualifiers for image memory objects.

__read_only __write_only __read_write read_only write_only read_write


Image objects specified as arguments to a kernel can be declared to be read-only, write-only or read-write. 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 imageB 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. Refer to section 6.13.16 for a 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.


OpenCL Specification

Also see


Copyright © 2007-2015 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.