regarding clEnqueueCopyBufferRect

Hello all,

I am currently trying to use clEnqueueCopyBufferRect to copy parts of buffers,
and am puzzled by the pitch and region syntax for this function.

On the official doc page (
it is said that the (x,y,z) “region” should be specified in bytes, as should be the values of the row and slice pitches.

However, in the errors section, the following error value is described:
" CL_INVALID_VALUE if dst_slice_pitch is not 0 and is less than region[1] * dst_row_pitch or if dst_slice_pitch is not 0 and is
not a multiple of dst_row_pitch ".
Is this not contradictory, in terms of byte specification?

Here is a simple example.
A and B are 2 (10x10x10) arrays of doubles.
I want to copy the first (10x10) slice from A to B.
I understand “region” to be (10x8,10x8,1x8 ) , the x8 corresponding to the number of bytes per double.
The row_pitch in bytes is 10x8, the slice_pitch in bytes is 10x10x8.
Thus, slice_pitch is less than region[1] * row_pitch, which is therefore an error condition.

Could anyone explain what I am misreading?

Many thanks,

Olivier Marsden

You should have a search on this topic. I have seen it here already somewhere. If I’m remembering correctly, y and z are in pixels and are calculated automatically.

region defines the (width in bytes, height in rows, depth in slices) of the 2D or 3D rectangle
being copied. For a 2D rectangle, the depth value given by region[2] should be 1.
Description of the spec