PDA

View Full Version : Write only a single color component



ilya.s
12-02-2012, 09:19 AM
Hi,
I'm using images to output some precise data. write_imageui accepts a complete BGRA color. My kernel outputs only a single color component. Is there a way to write only a single color component instead of a complete BGRA color?
Reading color value and then writing it back doesn't seem like a good solution to me - I might get some really strange values if two threads attempt to read/write it at the same time.

Thank you!

Dithermaster
12-02-2012, 09:55 AM
You can't read and write to the same image anyway, so that isn't an option.

You can't write a single color component using images.

Other solutions:

1. Use buffers, which can read/modify/write (but then you simultaneous access issue arises).
2. If you are really thinking of individual channels separately, use multiple single channel images instead of packed RGB[A] images.
3. Read from one image, modify the single channel, and write to another image.

ilya.s
12-02-2012, 06:12 PM
Thanks for clarifying!
I think I'll go with the second solution - I'll write to 4 different single-channel images and then I'll have a separate kernel that will join them into a single image.