cl_mem clCreateImage3D(
cl_context context,
cl_mem_flags flags,
const cl_image_format *image_format,
size_t image_width,
size_t image_height,
size_t image_depth,
size_t image_row_pitch,
size_t image_slice_pitch,
void *host_ptr,
cl_int *errcode_ret)
the unit for image_width , image_height , image_depth are in pixels
but the unit for image_row_pitch , image_slice_pitch are in bytes!
Example:
mem_volume = clCreateImage3D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &volume_format,
vrParam.volSize[0], vrParam.volSize[1], vrParam.volSize[2], // unit in pixels
vrParam.volSize[0]*sizeof tmpBlock, vrParam.volSize[0]* vrParam.volSize[1]*sizeof tmpBlock, // unit in bytes
tmpBlock, &err);
Besides, the spec says "they should be power of 2 in bytes" which seems not mandatory in my experiment
host_ptr
A pointer to the image data that may already be allocated by the application.
The size of the buffer that host_ptr points to must be greater than or equal to
image_slice_pitch * image_depth. The size of each element in bytes must be a power
of 2. The image data specified by host_ptr is stored as a linear sequence of
adjacent 2D slices. Each 2D slice is a linear sequence of adjacent scanlines. Each
scanline is a linear sequence of image elements.