OpenCL - Skip image2d_t twice to get both read and write from kernel?

In my OpenCL core, I would like to read and write an image2d_t object. According to the OpenCL standard, I can only specify __read_only or __write_only. However, I figured I would send the same cl_mem as two separate kernel arguments (one with __read_only and one with __write_only), I can do both.

Probably when I write and then read I can get the old value (?), But in my case I need the old value first, update it and write back to the image. A simple example would be "increase each pixel by 1". It looks like it works at 99.9% but sometimes gives me artifacts.

Does anyone know if this is possible at all or if I should expect undefined behavior?

+3


source to share


1 answer


According to the OpenCL standard, one image can be used for both reading and writing in a single core. So, if you need to read-write to one memory object, you have to use 2 images, or switch to a regular buffer. There is no guarantee that your kernel will work properly.



+3


source







All Articles