OpenCL write_imagei problem

Hi,
I have a very strange issue when try to write data into a 2d integer image.
This are the important parts of the code (I’m useing the C++ wrapper cl.hpp):


    cl_int err = 0;
    cl::ImageFormat format(CL_RGBA, CL_SIGNED_INT32);
    cl::Image2D border(mContext, CL_MEM_READ_WRITE, format, 1, 1, 0, NULL, &err);

And read it back with this lines (this code is not very clean, but it’s there just for debug):


    int *im = new int[4];
    cl::size_t<3> o; o[0] = o[1] = o[2] = 0;
    cl::size_t<3> s; s[0] = s[1] = s[2] = 1;
    err = mCommandQueue.enqueueReadImage(border, CL_TRUE, o, s, 0, 0, im)

And finally the kernel (again just a test kernel):


kernel void generateVertexBuffer(write_only image2d_t borders){
    int4 b = {1, 2, 3, 4};
    if(get_global_id(0) == 0)
        write_imagei(border, (int2)(0, 0), b);
}

When try to run this code the enqueueReadImage always return -5: CL_OUT_OF_RESOURCES.
The code works if I change the image format to CL_[UN]SIGNED_INT[8|16], the problem arise only with 32 bit integer formats, which is odd considering that clGetSupportedImageFormats with CL_MEM_READ_WRITE and CL_MEM_OBJECT_IMAGE2D tells me that four channel 32bit images are supported.
Lasts informations: OS: windows 8 64bit, GeForce GTX 470, driver version: 320.49.

Any ideas?
Thanks!

Where is your sampler definition?

without that, noone can tell i think

Which sampler? write_imagei doesn’t require a sampler as parameter.

Is it possible your reading/writing past the end of the image? That’s usually the case when -5 is thrown from a read buffer command.

At first i thought that, but then I got the same error with the kernel in the first post wher i’m writing at 0,0. And if I change the data type to CL_SIGNED_INT8 or CL_SIGNED_INT16 the code works perfectly.

Have you queryied the image format you are trying to use?
cl_int clGetSupportedImageFormats in [5.3.2] in opelCL 1.1 spec

Should be returned because its in the minimum supported list. Strange…

I did it, and the strage thing is that the CL_RGBA, CL_SIGNED_INT32 combination is in the returned list. I’m thinking at a driver bug at this point…

I’ve checked your code on my system (same OS, same driver but with a GeForce GT 650M) and it just works fine…

Well, considering this I guess that it is a driver bug that presents with the gtx 470…