PDA

View Full Version : Error when create image with clCreateImage2D



YOYOSENIOR
05-02-2011, 01:28 PM
Hello,
I have a simple problem with clCreateImage2D.

When I create the memory object with CL_MEM_READ_ONLY creation is a success.
But when I create the memory object with CL_MEM_WRITE_ONLY I got an error code
-10 which is CL_IMAGE_FORMAT_NOT_SUPPORTED.

Why ?

cl_image_format image_format;
image_format.image_channel_order = CL_BGRA;
image_format.image_channel_data_type = CL_UNSIGNED_INT8;

cl_mem image1;
image1 = clCreateImage2D(context, CL_MEM_READ_ONLY, &image_format, 512, 512, 512*4, NULL, &err);

cl_mem image2;
image2 = clCreateImage2D(context, CL_MEM_WRITE_ONLY, &image_format, 512, 512, 512*4, NULL, &err);

david.garcia
05-02-2011, 03:34 PM
This will probably not help, but it's possible that the OpenCL implementation you are using only supports BGRA8888 formats for reading, not for writing. What happens if you pass CL_MEM_READ_WRITE as flags?

YOYOSENIOR
05-03-2011, 12:35 PM
This will probably not help, but it's possible that the OpenCL implementation you are using only supports BGRA8888 formats for reading, not for writing. What happens if you pass CL_MEM_READ_WRITE as flags?

Same problem, but I have found a solution.

If I don't specify the Image row pitch (0 instead of the value), the function is correctly executed
with Read Only and Write Only.

If think it's a bug in the Apple OpenCL implementation.

Thanks for your help.

ajs2
05-03-2011, 04:48 PM
When host_ptr is NULL, image_row_pitch must be zero (here it is 512*4), but no error code is specified for this case.

david.garcia
05-03-2011, 05:15 PM
Ah! Thanks, ajs2, you are completely right :D