--- OpenCL/OpenCL.xs 2012/04/21 17:56:21 1.36 +++ OpenCL/OpenCL.xs 2012/04/21 18:49:21 1.37 @@ -6,6 +6,16 @@ #include #endif +// how stupid is that, the 1.2 header files define CL_VERSION_1_1, +// but then fail to define the api functions unless you ALSO define +// this. This breaks 100% of the opencl 1.1 apps, for what reason? +// after all, the functions are deprecated, not removed. +// in addition, you cannot test for this in any future-proof way. +// each time a new opencl version comes out, you need to make a new +// release. +#define CL_USE_DEPRECATED_OPENCL_1_1_APIS +#define CL_USE_DEPRECATED_OPENCL_1_2_APIS /* just guessing, you stupid idiots */ + #ifdef __APPLE__ #include #else @@ -91,7 +101,7 @@ static void *buf [buffers]; static size_t len [buffers]; - idx = ++idx % buffers; + idx = (idx + 1) % buffers; if (len [idx] < size) { @@ -326,7 +336,9 @@ cl_int errno () CODE: - errno = res; + RETVAL = res; + OUTPUT: + RETVAL const char * err2str (cl_int err) @@ -355,11 +367,15 @@ NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, 0, 0, &res)); XPUSH_NEW_OBJ ("OpenCL::Context", ctx); +#if 0 + void context (cl_context_properties *properties = 0, FUTURE devices, FUTURE notify = 0) PPCODE: /* der Gipfel der Kunst */ +#endif + void wait_for_events (...) CODE: @@ -710,6 +726,8 @@ NEED_SUCCESS_ARG (cl_mem mem, CreateBuffer, (self, flags, len, ptr, &res)); XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); +#if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS + void image2d (OpenCL::Context self, cl_mem_flags flags, cl_channel_order channel_order, cl_channel_type channel_type, size_t width, size_t height, size_t row_pitch = 0, SV *data = &PL_sv_undef) PPCODE: @@ -728,6 +746,8 @@ NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); +#endif + #if cl_apple_gl_sharing || cl_khr_gl_sharing void @@ -736,6 +756,8 @@ NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); +#if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS + void gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) PPCODE: @@ -748,6 +770,8 @@ NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); +#endif + void gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) PPCODE: @@ -943,7 +967,7 @@ if (len < min_len) croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); - NEED_SUCCESS (EnqueueWriteBufferRect, (self, 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)); + NEED_SUCCESS (EnqueueWriteBufferRect, (self, buf, blocking, buf_origin, host_origin, region, buf_row_pitch, buf_slice_pitch, host_row_pitch, host_slice_pitch, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) XPUSH_NEW_OBJ ("OpenCL::Event", ev); @@ -1008,7 +1032,7 @@ if (len < min_len) croak ("clEnqueueWriteImage: data string is shorter than what would be transferred"); - NEED_SUCCESS (EnqueueWriteImage, (self, dst, blocking, dst_origin, region, row_pitch, slice_pitch, SvPVX (data), event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); + NEED_SUCCESS (EnqueueWriteImage, (self, dst, blocking, dst_origin, region, row_pitch, slice_pitch, ptr, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); if (ev) XPUSH_NEW_OBJ ("OpenCL::Event", ev); @@ -1100,7 +1124,7 @@ if (SvOK (local_work_size)) { - if (SvOK (local_work_size) && !SvROK (local_work_size) || SvTYPE (SvRV (local_work_size)) != SVt_PVAV) + if ((SvOK (local_work_size) && !SvROK (local_work_size)) || SvTYPE (SvRV (local_work_size)) != SVt_PVAV) croak ("clEnqueueNDRangeKernel: global_work_size must be undef or an array reference"); if (AvFILLp (SvRV (local_work_size)) + 1 != gws_len) @@ -1146,6 +1170,8 @@ #endif +#if !defined CL_VERSION_1_2 || defined CL_USE_DEPRECATED_OPENCL_1_1_APIS + void enqueue_marker (OpenCL::Queue self) PPCODE: @@ -1164,6 +1190,8 @@ CODE: NEED_SUCCESS (EnqueueBarrier, (self)); +#endif + void flush (OpenCL::Queue self) CODE: @@ -1542,7 +1570,7 @@ SvUPGRADE (sv, SVt_PV); SvPOK_only (sv); SvCUR_set (sv, sizes [i]); - ptrs [i] = SvPVX (sv); + ptrs [i] = (void *)SvPVX (sv); PUSHs (sv); }