--- OpenCL/OpenCL.xs 2011/11/22 10:29:18 1.16 +++ OpenCL/OpenCL.xs 2011/11/22 10:39:47 1.17 @@ -722,6 +722,71 @@ XPUSH_NEW_OBJ ("OpenCL::Event", ev); void +enqueue_read_buffer_rect (OpenCL::Queue this, OpenCL::Memory buf, cl_bool blocking, size_t buf_x, size_t buf_y, size_t buf_z, size_t host_x, size_t host_y, size_t host_z, size_t width, size_t height, size_t depth, size_t buf_row_pitch, size_t buf_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, SV *data, ...) + PPCODE: + cl_event ev = 0; + const size_t buf_origin [3] = { buf_x , buf_y , buf_z }; + const size_t host_origin[3] = { host_x, host_y, host_z }; + const size_t region[3] = { width, height, depth }; + EVENT_LIST (17, items - 17); + + if (!buf_row_pitch) + buf_row_pitch = region [0]; + + if (!buf_slice_pitch) + buf_slice_pitch = region [1] * buf_row_pitch; + + if (!host_row_pitch) + host_row_pitch = region [0]; + + if (!host_slice_pitch) + host_slice_pitch = region [1] * host_row_pitch; + + size_t len = host_row_pitch * host_slice_pitch * region [2]; + + SvUPGRADE (data, SVt_PV); + SvGROW (data, len); + SvPOK_only (data); + SvCUR_set (data, len); + NEED_SUCCESS (EnqueueReadBufferRect, (this, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + + if (ev) + XPUSH_NEW_OBJ ("OpenCL::Event", ev); + +void +enqueue_write_buffer_rect (OpenCL::Queue this, OpenCL::Memory buf, cl_bool blocking, size_t buf_x, size_t buf_y, size_t buf_z, size_t host_x, size_t host_y, size_t host_z, size_t width, size_t height, size_t depth, size_t buf_row_pitch, size_t buf_slice_pitch, size_t host_row_pitch, size_t host_slice_pitch, SV *data, ...) + PPCODE: + cl_event ev = 0; + const size_t buf_origin [3] = { buf_x , buf_y , buf_z }; + const size_t host_origin[3] = { host_x, host_y, host_z }; + const size_t region[3] = { width, height, depth }; + STRLEN len; + char *ptr = SvPVbyte (data, len); + EVENT_LIST (17, items - 17); + + if (!buf_row_pitch) + buf_row_pitch = region [0]; + + if (!buf_slice_pitch) + buf_slice_pitch = region [1] * buf_row_pitch; + + if (!host_row_pitch) + host_row_pitch = region [0]; + + if (!host_slice_pitch) + host_slice_pitch = region [1] * host_row_pitch; + + size_t min_len = host_row_pitch * host_slice_pitch * region [2]; + + if (len < min_len) + croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); + + NEED_SUCCESS (EnqueueWriteBufferRect, (this, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + + if (ev) + XPUSH_NEW_OBJ ("OpenCL::Event", ev); + +void enqueue_read_image (OpenCL::Queue this, OpenCL::Image src, cl_bool blocking, size_t src_x, size_t src_y, size_t src_z, size_t width, size_t height, size_t depth, size_t row_pitch, size_t slice_pitch, SV *data, ...) PPCODE: cl_event ev = 0;