Strange results when using image objects

Hi

This is a follow up to my recent topic. The kernel is the same (it should just copy an image to another):

const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE |
CLK_ADDRESS_CLAMP_TO_EDGE |
CLK_FILTER_NEAREST;

__kernel void copy(__read_only image2d_t src, __write_only image2d_t dst)
{
int2 pos;
uint4 input;
int x = get_global_id(0);
int y = get_global_id(1);

pos.x = x;
pos.y = y;

input = read_imageui(src, sampler, pos);
write_imageui(dst, pos, input);

}

When I use grayscale version of the classic Lena picture (

lena512I.bmp (257 KB)

) as source I get this:

out.bmp (32 KB)

I’m quite sure that the problem is in the kernel since if I load the picture to image object and then out again I get right results. But if I run it through this kernel, distortion occurs.

I don’t understand what could go wrong since the kernel is so simple. Any ideas?

out.bmp (768 KB)