Friday, January 15, 2010

使用 clCreateImage 需要注意的地方


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);

image_width , image_height , image_depth 的單位是 pixels
但 image_row_pitch , image_slice_pitch 的單位是 bytes!

此外 host_ptr 似乎要是 power of 2 in bytes. 實作中似乎並不需要

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.

No comments:

Post a Comment