Example #1
0
// Enqueue command to write to a region in buffer object from host memory.
func (q *CommandQueue) EnqueueCopyBufferRect(dst, src *MemObject, dst_origin, src_origin, region *Dim3, dst_row_pitch, dst_slice_pitch, src_row_pitch, src_slice_pitch int, eventWaitList []*Event) (*Event, error) {
	var event C.cl_event
	dst_offset := make([]C.size_t, 3)
	defer C.free(dst_offset)
	dst_offset[0], dst_offset[1], dst_offset[2] = (C.size_t)(dst_origin.X), (C.size_t)(dst_origin.Y), (C.size_t)(dst_origin.Z)
	src_offset := make([]C.size_t, 3)
	defer C.free(src_offset)
	src_offset[0], src_offset[1], src_offset[2] = (C.size_t)(src_origin.X), (C.size_t)(src_origin.Y), (C.size_t)(src_origin.Z)
	mem_size := make([]C.size_t, 3)
	defer C.free(mem_size)
	mem_size[0], mem_size[1], mem_size[2] = (C.size_t)(region.X), (C.size_t)(region.Y), (C.size_t)(region.Z)
	err := toError(C.clEnqueueCopyBufferRect(q.clQueue, src.clMem, dst.clMem, &src_offset[0], &dst_offset[0], &mem_size[0],
		(C.size_t)(src_row_pitch), (C.size_t)(src_slice_pitch), (C.size_t)(dst_row_pitch), (C.size_t)(dst_slice_pitch),
		C.cl_uint(len(eventWaitList)), eventListPtr(eventWaitList), &event))
	return newEvent(event), err
}
Example #2
0
func CLEnqueueCopyBufferRect(command_queue CL_command_queue,
	src_buffer CL_mem,
	dst_buffer CL_mem,
	src_origin [3]CL_size_t,
	dst_origin [3]CL_size_t,
	region [3]CL_size_t,
	src_row_pitch CL_size_t,
	src_slice_pitch CL_size_t,
	dst_row_pitch CL_size_t,
	dst_slice_pitch CL_size_t,
	num_events_in_wait_list CL_uint,
	event_wait_list []CL_event,
	event *CL_event) CL_int {

	if (num_events_in_wait_list == 0 && event_wait_list != nil) ||
		(num_events_in_wait_list != 0 && event_wait_list == nil) ||
		int(num_events_in_wait_list) != len(event_wait_list) {
		return CL_INVALID_EVENT_WAIT_LIST
	}

	var c_src_origin [3]C.size_t
	var c_dst_origin [3]C.size_t
	var c_region [3]C.size_t

	for i := 0; i < 3; i++ {
		c_src_origin[i] = C.size_t(src_origin[i])
		c_dst_origin[i] = C.size_t(dst_origin[i])
		c_region[i] = C.size_t(region[i])
	}

	var c_event C.cl_event
	var c_errcode_ret C.cl_int

	if num_events_in_wait_list != 0 {
		var c_event_wait_list []C.cl_event
		c_event_wait_list = make([]C.cl_event, num_events_in_wait_list)
		for i := 0; i < int(num_events_in_wait_list); i++ {
			c_event_wait_list[i] = event_wait_list[i].cl_event
		}

		c_errcode_ret = C.clEnqueueCopyBufferRect(command_queue.cl_command_queue,
			src_buffer.cl_mem,
			dst_buffer.cl_mem,
			&c_src_origin[0],
			&c_dst_origin[0],
			&c_region[0],
			C.size_t(src_row_pitch),
			C.size_t(src_slice_pitch),
			C.size_t(dst_row_pitch),
			C.size_t(dst_slice_pitch),
			C.cl_uint(num_events_in_wait_list),
			&c_event_wait_list[0],
			&c_event)
	} else {
		c_errcode_ret = C.clEnqueueCopyBufferRect(command_queue.cl_command_queue,
			src_buffer.cl_mem,
			dst_buffer.cl_mem,
			&c_src_origin[0],
			&c_dst_origin[0],
			&c_region[0],
			C.size_t(src_row_pitch),
			C.size_t(src_slice_pitch),
			C.size_t(dst_row_pitch),
			C.size_t(dst_slice_pitch),
			0,
			nil,
			&c_event)
	}

	if event != nil {
		event.cl_event = c_event
	}

	return CL_int(c_errcode_ret)
}