Buffer size for clCreateImage3D with CL_INTENSITY

Hi.

When creating a 3D image with the following image format:

cl_image_format imgFormat;
imgFormat.image_channel_data_type = CL_UNORM_INT8;
imgFormat.image_channel_order = CL_INTENSITY;

and using CL_MEM_COPY_HOST_PTR or CL_MEM_USE_HOST_PTR, what should be the size of the buffer pointed to by host_ptr (m_inputData in example below)?
GRIDSIZE^3 or 4*GRIDSIZE^3?

example:

#define GRIDSIZE 256

m_cl_memin = clCreateImage3D (
m_clGPUContext,
CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,
&imgFormat,
GRIDSIZE,
GRIDSIZE,
GRIDSIZE,
0,
0,
m_inputdata,
&ciErrNum);

Best regards
Dag Magne

It should be sizeof(cl_uint)image_slice_pitchimage_depth, where image_slice_pitch and image_depth are the arguments that you pass to clCreateImage3D().

Why should it not be sizeof(cl_uchar)image_slice_pitchimage_depth?

While struggeling with this, I dropped the CL_MEM_COPY_HOST_PTR or CL_MEM_USE_HOST_PTR flags, and initialised the image using:

clEnqueueWriteImage, pointing to a buffer of size sizeof(cl_uchar)image_slice_pitchimage_depth,

and this works ok. (At the same time i switched to using image_channel_order=CL_A)

Dag Magne

Why should it not be sizeof(cl_uchar)image_slice_pitchimage_depth?

Sorry, that was my mistake. sizeof(cl_uchar) is correct.

At the same time i switched to using image_channel_order=CL_A

Did you check first which image formats are supported in your device? Maybe CL_INTENSITY is not supported. clGetSupportedImageFormats() gives that information.