write_imagef problem

I am trying to copy an image made out of float through a kernel. This works fine as long as both the target and the source is in CL_RGBA format. But once the target is only CL_R strange values is written to the target.

I have the following kernel code:

__kernel void copy(__read_only image2d_t in,__write_only image2d_t out,sampler_t sampler)	

{																								

int2 cord = (int2)(get_global_id(0),get_global_id(1));

float4 val = read_imagef(in,sampler,cord);

write_imagef(out,cord,val);

}

On an input image 5^5 with RGBA channels that look like this:

0;1;2;3 _ 4;5;6;7 _ 8;9;10;11 _ 12;13;14;15 _16;17;18;19

20;21;22;23 _ …

I get the result in an image that only has an R channel

4 4 4 4 16

20 20 20 20 36

48 48 48 48 56

60 60 60 60 76

84 81 81 81 96

Bu if I have a RGBA channel on the result the result is the same as the input.

What can be the cause of this strange behaviour?

I don’t know if this is the answer, but something you might want to look into is whether NVIDIA supports writing using CL_R. The Khronos spec states that the minimum for write only support is CL_RGBA and CL_BGRA. I came across this on page 66 of the 1.0 spec.

I use writing into CL_R images all the time and it works fine