AnsweredAssumed Answered

clEnqueueWriteBufferRect does not work when region width is not equal to src pitch

Question asked by timchist on Jan 30, 2013
Latest reply on Jun 6, 2013 by himanshu.gautam

I'm trying to copy a rectangular area of an 8-bit image channel in host memory to GPU buffer that has the same size as the area.

 

The area starts at offset (0, 0) and is 1696 x 2048 (width x height).

The whole image is 5585 x 3723.

 

This is the code I execute:

 

size_t bufferOrigin[3], hostOrigin[3], region[3];

bufferOrigin[0] = 0;

bufferOrigin[1] = 0;

bufferOrigin[2] = 0;

hostOrigin[0] = 0;

hostOrigin[1] = 0;

hostOrigin[2] = 0;

region[0] = 1696;

region[1] = 2048;

region[2] = 1;

clEnqueueWriteBufferRect(queue, ptrD, CL_TRUE, bufferOrigin, hostOrigin, region, 1696, 0, 5585, 0, ptrH, 0, NULL, NULL);

 

The first line of my resulting image is correct, but the second one is not (as well as all subsequent writes). In fact the output pixel (y=1, x=0) is taken from source pixel (y=0, x=1696), not from (y=1, x=0). So it seems that this function somehow incorrectly interprets the host_row_pitch parameter.

 

Is it really a bug or I am doing something wrong? Unfortunately APP SDK does not have any samples for clEnqueueWriteBufferRect.

Outcomes