… | |
… | |
35 | |
35 | |
36 | /* up to two temporary buffers */ |
36 | /* up to two temporary buffers */ |
37 | static void * |
37 | static void * |
38 | tmpbuf (size_t size) |
38 | tmpbuf (size_t size) |
39 | { |
39 | { |
|
|
40 | enum { buffers = 3 }; |
40 | static int idx; |
41 | static int idx; |
41 | static void *buf [2]; |
42 | static void *buf [buffers]; |
42 | static size_t len [2]; |
43 | static size_t len [buffers]; |
43 | |
44 | |
44 | idx ^= 1; |
45 | idx = ++idx % buffers; |
45 | |
46 | |
46 | if (len [idx] < size) |
47 | if (len [idx] < size) |
47 | { |
48 | { |
48 | free (buf [idx]); |
49 | free (buf [idx]); |
49 | len [idx] = ((size + 31) & ~4095) + 4096 - 32; |
50 | len [idx] = ((size + 31) & ~4095) + 4096 - 32; |
… | |
… | |
131 | croak ("%s: %s is not of type %s", func, svname, pkg); |
132 | croak ("%s: %s is not of type %s", func, svname, pkg); |
132 | } |
133 | } |
133 | |
134 | |
134 | /*****************************************************************************/ |
135 | /*****************************************************************************/ |
135 | |
136 | |
|
|
137 | static cl_context_properties * |
|
|
138 | SvCONTEXTPROPERTIES (const char *func, const char *svname, SV *sv, cl_context_properties *extra, int extracount) |
|
|
139 | { |
|
|
140 | if (!sv || !SvOK (sv)) |
|
|
141 | if (extra) |
|
|
142 | sv = sv_2mortal (newRV_noinc ((SV *)newAV ())); // slow, but rarely used hopefully |
|
|
143 | else |
|
|
144 | return 0; |
|
|
145 | |
|
|
146 | if (SvROK (sv) && SvTYPE (SvRV (sv)) == SVt_PVAV) |
|
|
147 | { |
|
|
148 | AV *av = (AV *)SvRV (sv); |
|
|
149 | int i, len = av_len (av); |
|
|
150 | cl_context_properties *p = tmpbuf (sizeof (cl_context_properties) * (len + extracount + 1)); |
|
|
151 | cl_context_properties *l = p; |
|
|
152 | |
|
|
153 | if (len & 1) |
|
|
154 | croak ("%s: %s is not a property list (must be even number of elements)", func, svname); |
|
|
155 | |
|
|
156 | while (extracount--) |
|
|
157 | *l++ = *extra++; |
|
|
158 | |
|
|
159 | for (i = 0; i < len; i += 2) |
|
|
160 | { |
|
|
161 | cl_context_properties t = SvIV (*av_fetch (av, i, 0)); |
|
|
162 | cl_context_properties v; |
|
|
163 | |
|
|
164 | switch (t) |
|
|
165 | { |
|
|
166 | default: |
|
|
167 | /* unknown property, treat as int */ |
|
|
168 | v = SvIV (*av_fetch (av, i, 0)); |
|
|
169 | break; |
|
|
170 | } |
|
|
171 | |
|
|
172 | *l++ = t; |
|
|
173 | *l++ = v; |
|
|
174 | } |
|
|
175 | |
|
|
176 | *l = 0; |
|
|
177 | |
|
|
178 | return p; |
|
|
179 | } |
|
|
180 | |
|
|
181 | croak ("%s: %s is not a property list (either undef or [type => value, ...])", func, svname); |
|
|
182 | } |
|
|
183 | |
|
|
184 | /*****************************************************************************/ |
|
|
185 | |
136 | static size_t |
186 | static size_t |
137 | img_row_pitch (cl_mem img) |
187 | img_row_pitch (cl_mem img) |
138 | { |
188 | { |
139 | size_t res; |
189 | size_t res; |
140 | clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0); |
190 | clGetImageInfo (img, CL_IMAGE_ROW_PITCH, sizeof (res), &res, 0); |
… | |
… | |
159 | cl_uint event_list_count = (count); \ |
209 | cl_uint event_list_count = (count); \ |
160 | cl_event *event_list_ptr = event_list (&ST (items), event_list_count) |
210 | cl_event *event_list_ptr = event_list (&ST (items), event_list_count) |
161 | |
211 | |
162 | #define INFO(class) \ |
212 | #define INFO(class) \ |
163 | { \ |
213 | { \ |
164 | size_t size; \ |
214 | size_t size; \ |
165 | NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \ |
215 | NEED_SUCCESS (Get ## class ## Info, (self, name, 0, 0, &size)); \ |
166 | SV *sv = sv_2mortal (newSV (size)); \ |
216 | SV *sv = sv_2mortal (newSV (size)); \ |
167 | SvUPGRADE (sv, SVt_PV); \ |
217 | SvUPGRADE (sv, SVt_PV); \ |
168 | SvPOK_only (sv); \ |
218 | SvPOK_only (sv); \ |
169 | SvCUR_set (sv, size); \ |
219 | SvCUR_set (sv, size); \ |
170 | NEED_SUCCESS (Get ## class ## Info, (self, name, size, SvPVX (sv), 0)); \ |
220 | NEED_SUCCESS (Get ## class ## Info, (self, name, size, SvPVX (sv), 0)); \ |
171 | XPUSHs (sv); \ |
221 | XPUSHs (sv); \ |
172 | } |
222 | } |
173 | |
223 | |
174 | MODULE = OpenCL PACKAGE = OpenCL |
224 | MODULE = OpenCL PACKAGE = OpenCL |
175 | |
225 | |
176 | PROTOTYPES: ENABLE |
226 | PROTOTYPES: ENABLE |
177 | |
227 | |
178 | BOOT: |
228 | BOOT: |
179 | { |
229 | { |
180 | HV *stash = gv_stashpv ("OpenCL", 1); |
230 | HV *stash = gv_stashpv ("OpenCL", 1); |
181 | static const ivstr *civ, const_iv[] = { |
231 | static const ivstr *civ, const_iv[] = { |
182 | { sizeof (cl_char ), "SIZEOF_CHAR" }, |
232 | { sizeof (cl_char ), "SIZEOF_CHAR" }, |
183 | { sizeof (cl_uchar ), "SIZEOF_UCHAR" }, |
233 | { sizeof (cl_uchar ), "SIZEOF_UCHAR" }, |
184 | { sizeof (cl_short ), "SIZEOF_SHORT" }, |
234 | { sizeof (cl_short ), "SIZEOF_SHORT" }, |
185 | { sizeof (cl_ushort), "SIZEOF_USHORT" }, |
235 | { sizeof (cl_ushort), "SIZEOF_USHORT" }, |
186 | { sizeof (cl_int ), "SIZEOF_INT" }, |
236 | { sizeof (cl_int ), "SIZEOF_INT" }, |
187 | { sizeof (cl_uint ), "SIZEOF_UINT" }, |
237 | { sizeof (cl_uint ), "SIZEOF_UINT" }, |
188 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
238 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
189 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
239 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
190 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
240 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
191 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
241 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
192 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
242 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
193 | #include "constiv.h" |
243 | #include "constiv.h" |
194 | }; |
244 | }; |
195 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
245 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ > const_iv; civ--) |
196 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
246 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
197 | } |
247 | } |
198 | |
248 | |
199 | cl_int |
249 | cl_int |
200 | errno () |
250 | errno () |
201 | CODE: |
251 | CODE: |
… | |
… | |
221 | EXTEND (SP, count); |
271 | EXTEND (SP, count); |
222 | for (i = 0; i < count; ++i) |
272 | for (i = 0; i < count; ++i) |
223 | PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i])); |
273 | PUSHs (NEW_MORTAL_OBJ ("OpenCL::Platform", list [i])); |
224 | |
274 | |
225 | void |
275 | void |
226 | context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
276 | context_from_type (cl_context_properties *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
227 | PPCODE: |
277 | PPCODE: |
228 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (0, type, 0, 0, &res)); |
278 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (properties, type, 0, 0, &res)); |
229 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
279 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
230 | |
280 | |
231 | void |
281 | void |
232 | context (FUTURE properties, FUTURE devices, FUTURE notify = 0) |
282 | context (cl_context_properties *properties = 0, FUTURE devices, FUTURE notify = 0) |
233 | PPCODE: |
283 | PPCODE: |
234 | /* der Gipfel der Kunst */ |
284 | /* der Gipfel der Kunst */ |
235 | |
285 | |
236 | void |
286 | void |
237 | wait_for_events (...) |
287 | wait_for_events (...) |
… | |
… | |
283 | EXTEND (SP, count); |
333 | EXTEND (SP, count); |
284 | for (i = 0; i < count; ++i) |
334 | for (i = 0; i < count; ++i) |
285 | PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i])); |
335 | PUSHs (sv_setref_pv (sv_newmortal (), "OpenCL::Device", list [i])); |
286 | |
336 | |
287 | void |
337 | void |
288 | context (OpenCL::Platform self, FUTURE properties, SV *devices, FUTURE notify = 0) |
338 | context (OpenCL::Platform self, cl_context_properties *properties = 0, SV *devices, FUTURE notify = 0) |
289 | PPCODE: |
339 | PPCODE: |
290 | if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) |
340 | if (!SvROK (devices) || SvTYPE (SvRV (devices)) != SVt_PVAV) |
291 | croak ("OpenCL::Platform argument 'device' must be an arrayref with device objects, in call"); |
341 | croak ("OpenCL::Platform argument 'device' must be an arrayref with device objects, in call"); |
292 | |
342 | |
293 | AV *av = (AV *)SvRV (devices); |
343 | AV *av = (AV *)SvRV (devices); |
… | |
… | |
296 | int i; |
346 | int i; |
297 | |
347 | |
298 | for (i = num_devices; i--; ) |
348 | for (i = num_devices; i--; ) |
299 | device_list [i] = SvPTROBJ ("clCreateContext", "devices", *av_fetch (av, i, 0), "OpenCL::Device"); |
349 | device_list [i] = SvPTROBJ ("clCreateContext", "devices", *av_fetch (av, i, 0), "OpenCL::Device"); |
300 | |
350 | |
301 | NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (0, num_devices, device_list, 0, 0, &res)); |
351 | NEED_SUCCESS_ARG (cl_context ctx, CreateContext, (properties, num_devices, device_list, 0, 0, &res)); |
302 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
352 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
303 | |
353 | |
304 | void |
354 | void |
305 | context_from_type (OpenCL::Platform self, FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
355 | context_from_type (OpenCL::Platform self, SV *properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) |
306 | PPCODE: |
356 | PPCODE: |
307 | cl_context_properties props[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self, 0 }; |
357 | cl_context_properties extra[] = { CL_CONTEXT_PLATFORM, (cl_context_properties)self }; |
|
|
358 | cl_context_properties *props = SvCONTEXTPROPERTIES ("OpenCL::Platform::context_from_type", "properties", properties, extra, 2); |
308 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, 0, 0, &res)); |
359 | NEED_SUCCESS_ARG (cl_context ctx, CreateContextFromType, (props, type, 0, 0, &res)); |
309 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
360 | XPUSH_NEW_OBJ ("OpenCL::Context", ctx); |
310 | |
361 | |
311 | MODULE = OpenCL PACKAGE = OpenCL::Device |
362 | MODULE = OpenCL PACKAGE = OpenCL::Device |
312 | |
363 | |
… | |
… | |
552 | INFO (Context) |
603 | INFO (Context) |
553 | |
604 | |
554 | void |
605 | void |
555 | queue (OpenCL::Context self, OpenCL::Device device, cl_command_queue_properties properties = 0) |
606 | queue (OpenCL::Context self, OpenCL::Device device, cl_command_queue_properties properties = 0) |
556 | PPCODE: |
607 | PPCODE: |
557 | NEED_SUCCESS_ARG (cl_command_queue queue, CreateCommandQueue, (self, device, properties, &res)); |
608 | NEED_SUCCESS_ARG (cl_command_queue queue, CreateCommandQueue, (self, device, properties, &res)); |
558 | XPUSH_NEW_OBJ ("OpenCL::Queue", queue); |
609 | XPUSH_NEW_OBJ ("OpenCL::Queue", queue); |
559 | |
610 | |
560 | void |
611 | void |
561 | user_event (OpenCL::Context self) |
612 | user_event (OpenCL::Context self) |
562 | PPCODE: |
613 | PPCODE: |
563 | NEED_SUCCESS_ARG (cl_event ev, CreateUserEvent, (self, &res)); |
614 | NEED_SUCCESS_ARG (cl_event ev, CreateUserEvent, (self, &res)); |
564 | XPUSH_NEW_OBJ ("OpenCL::UserEvent", ev); |
615 | XPUSH_NEW_OBJ ("OpenCL::UserEvent", ev); |
565 | |
616 | |
566 | void |
617 | void |
567 | buffer (OpenCL::Context self, cl_mem_flags flags, size_t len) |
618 | buffer (OpenCL::Context self, cl_mem_flags flags, size_t len) |
568 | PPCODE: |
619 | PPCODE: |
… | |
… | |
586 | 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) |
637 | 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) |
587 | PPCODE: |
638 | PPCODE: |
588 | STRLEN len; |
639 | STRLEN len; |
589 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
640 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
590 | const cl_image_format format = { channel_order, channel_type }; |
641 | const cl_image_format format = { channel_order, channel_type }; |
591 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (self, flags, &format, width, height, row_pitch, ptr, &res)); |
642 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage2D, (self, flags, &format, width, height, row_pitch, ptr, &res)); |
592 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
643 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
593 | |
644 | |
594 | void |
645 | void |
595 | image3d (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 depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef) |
646 | image3d (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 depth, size_t row_pitch = 0, size_t slice_pitch = 0, SV *data = &PL_sv_undef) |
596 | PPCODE: |
647 | PPCODE: |
597 | STRLEN len; |
648 | STRLEN len; |
598 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
649 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
599 | const cl_image_format format = { channel_order, channel_type }; |
650 | const cl_image_format format = { channel_order, channel_type }; |
600 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
651 | NEED_SUCCESS_ARG (cl_mem mem, CreateImage3D, (self, flags, &format, width, height, depth, row_pitch, slice_pitch, ptr, &res)); |
601 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
652 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
|
|
653 | |
|
|
654 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
|
|
655 | |
|
|
656 | void |
|
|
657 | gl_buffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint bufobj) |
|
|
658 | PPCODE: |
|
|
659 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLBuffer, (self, flags, bufobj, &res)); |
|
|
660 | XPUSH_NEW_OBJ ("OpenCL::BufferObj", mem); |
|
|
661 | |
|
|
662 | void |
|
|
663 | gl_texture2d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
|
|
664 | PPCODE: |
|
|
665 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture2D, (self, flags, target, miplevel, texture, &res)); |
|
|
666 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
|
|
667 | |
|
|
668 | void |
|
|
669 | gl_texture3d (OpenCL::Context self, cl_mem_flags flags, cl_GLenum target, cl_GLint miplevel, cl_GLuint texture) |
|
|
670 | PPCODE: |
|
|
671 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLTexture3D, (self, flags, target, miplevel, texture, &res)); |
|
|
672 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
|
|
673 | |
|
|
674 | void |
|
|
675 | gl_renderbuffer (OpenCL::Context self, cl_mem_flags flags, cl_GLuint renderbuffer) |
|
|
676 | PPCODE: |
|
|
677 | NEED_SUCCESS_ARG (cl_mem mem, CreateFromGLRenderbuffer, (self, flags, renderbuffer, &res)); |
|
|
678 | XPUSH_NEW_OBJ ("OpenCL::Image2D", mem); |
|
|
679 | |
|
|
680 | #endif |
602 | |
681 | |
603 | void |
682 | void |
604 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |
683 | supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) |
605 | PPCODE: |
684 | PPCODE: |
606 | { |
685 | { |
607 | cl_uint count; |
686 | cl_uint count; |
608 | cl_image_format *list; |
687 | cl_image_format *list; |
609 | int i; |
688 | int i; |
610 | |
689 | |
611 | NEED_SUCCESS (GetSupportedImageFormats, (self, flags, image_type, 0, 0, &count)); |
690 | NEED_SUCCESS (GetSupportedImageFormats, (self, flags, image_type, 0, 0, &count)); |
612 | Newx (list, count, cl_image_format); |
691 | Newx (list, count, cl_image_format); |
613 | NEED_SUCCESS (GetSupportedImageFormats, (self, flags, image_type, count, list, 0)); |
692 | NEED_SUCCESS (GetSupportedImageFormats, (self, flags, image_type, count, list, 0)); |
614 | |
693 | |
615 | EXTEND (SP, count); |
694 | EXTEND (SP, count); |
616 | for (i = 0; i < count; ++i) |
695 | for (i = 0; i < count; ++i) |
617 | { |
696 | { |
618 | AV *av = newAV (); |
697 | AV *av = newAV (); |
… | |
… | |
623 | } |
702 | } |
624 | |
703 | |
625 | void |
704 | void |
626 | sampler (OpenCL::Context self, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode) |
705 | sampler (OpenCL::Context self, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode) |
627 | PPCODE: |
706 | PPCODE: |
628 | NEED_SUCCESS_ARG (cl_sampler sampler, CreateSampler, (self, normalized_coords, addressing_mode, filter_mode, &res)); |
707 | NEED_SUCCESS_ARG (cl_sampler sampler, CreateSampler, (self, normalized_coords, addressing_mode, filter_mode, &res)); |
629 | XPUSH_NEW_OBJ ("OpenCL::Sampler", sampler); |
708 | XPUSH_NEW_OBJ ("OpenCL::Sampler", sampler); |
630 | |
709 | |
631 | void |
710 | void |
632 | program_with_source (OpenCL::Context self, SV *program) |
711 | program_with_source (OpenCL::Context self, SV *program) |
633 | PPCODE: |
712 | PPCODE: |
634 | STRLEN len; |
713 | STRLEN len; |
635 | size_t len2; |
714 | size_t len2; |
636 | const char *ptr = SvPVbyte (program, len); |
715 | const char *ptr = SvPVbyte (program, len); |
637 | |
716 | |
638 | len2 = len; |
717 | len2 = len; |
639 | NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (self, 1, &ptr, &len2, &res)); |
718 | NEED_SUCCESS_ARG (cl_program prog, CreateProgramWithSource, (self, 1, &ptr, &len2, &res)); |
640 | XPUSH_NEW_OBJ ("OpenCL::Program", prog); |
719 | XPUSH_NEW_OBJ ("OpenCL::Program", prog); |
641 | |
720 | |
642 | #BEGIN:context |
721 | #BEGIN:context |
643 | |
722 | |
644 | void |
723 | void |
… | |
… | |
958 | NEED_SUCCESS (EnqueueNDRangeKernel, (self, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
1037 | NEED_SUCCESS (EnqueueNDRangeKernel, (self, kernel, gws_len, gwo, gws, lws, event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
959 | |
1038 | |
960 | if (ev) |
1039 | if (ev) |
961 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1040 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
962 | |
1041 | |
|
|
1042 | #if 0 |
|
|
1043 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
|
|
1044 | |
|
|
1045 | void |
|
|
1046 | enqueue_acquire_gl_objects (OpenCL::Queue self, SV *objects, ...) |
|
|
1047 | CODE: |
|
|
1048 | cl_event ev = 0; |
|
|
1049 | EVENT_LIST (2, items - 2); |
|
|
1050 | |
|
|
1051 | NEED_SUCCESS (EnqueueAcquireGLObjects, (self, ..., event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1052 | |
|
|
1053 | if (ev) |
|
|
1054 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
|
|
1055 | |
|
|
1056 | void |
|
|
1057 | enqueue_release_gl_objects (OpenCL::Queue self, SV *objects, ...) |
|
|
1058 | CODE: |
|
|
1059 | cl_event ev = 0; |
|
|
1060 | EVENT_LIST (2, items - 2); |
|
|
1061 | |
|
|
1062 | NEED_SUCCESS (EnqueueAcquireGLObjects, (self, ..., event_list_count, event_list_ptr, GIMME_V != G_VOID ? &ev : 0)); |
|
|
1063 | |
|
|
1064 | if (ev) |
|
|
1065 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
|
|
1066 | |
|
|
1067 | #endif |
|
|
1068 | #endif |
|
|
1069 | |
963 | void |
1070 | void |
964 | enqueue_marker (OpenCL::Queue self) |
1071 | enqueue_marker (OpenCL::Queue self) |
965 | PPCODE: |
1072 | PPCODE: |
966 | cl_event ev; |
1073 | cl_event ev; |
967 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
1074 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
… | |
… | |
1126 | NEED_SUCCESS (RetainMemObject, (value [i])); |
1233 | NEED_SUCCESS (RetainMemObject, (value [i])); |
1127 | PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i])); |
1234 | PUSHs (NEW_MORTAL_OBJ ("OpenCL::Memory", value [i])); |
1128 | } |
1235 | } |
1129 | |
1236 | |
1130 | #END:mem |
1237 | #END:mem |
|
|
1238 | |
|
|
1239 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
|
|
1240 | |
|
|
1241 | void |
|
|
1242 | gl_object_info (OpenCL::Memory self) |
|
|
1243 | PPCODE: |
|
|
1244 | cl_gl_object_type type; |
|
|
1245 | cl_GLuint name; |
|
|
1246 | NEED_SUCCESS (clGetGLObjectInfo, (self, &type, &name)); |
|
|
1247 | EXTEND (SP, 2); |
|
|
1248 | PUSHs (sv_2mortal (newSVuv (type))); |
|
|
1249 | PUSHs (sv_2mortal (newSVuv (name))); |
|
|
1250 | |
|
|
1251 | #endif |
1131 | |
1252 | |
1132 | MODULE = OpenCL PACKAGE = OpenCL::BufferObj |
1253 | MODULE = OpenCL PACKAGE = OpenCL::BufferObj |
1133 | |
1254 | |
1134 | void |
1255 | void |
1135 | sub_buffer_region (OpenCL::BufferObj self, cl_mem_flags flags, size_t origin, size_t size) |
1256 | sub_buffer_region (OpenCL::BufferObj self, cl_mem_flags flags, size_t origin, size_t size) |
… | |
… | |
1167 | const int i = 0; |
1288 | const int i = 0; |
1168 | PUSHs (sv_2mortal (newSVuv (value [i]))); |
1289 | PUSHs (sv_2mortal (newSVuv (value [i]))); |
1169 | |
1290 | |
1170 | #END:image |
1291 | #END:image |
1171 | |
1292 | |
|
|
1293 | #if cl_apple_gl_sharing || cl_khr_gl_sharing |
|
|
1294 | |
|
|
1295 | #BEGIN:gl_texture |
|
|
1296 | |
|
|
1297 | void |
|
|
1298 | target (OpenCL::Image self) |
|
|
1299 | PPCODE: |
|
|
1300 | cl_GLenum value [1]; |
|
|
1301 | NEED_SUCCESS (GetGlTextureInfo, (self, CL_GL_TEXTURE_TARGET, sizeof (value), value, 0)); |
|
|
1302 | EXTEND (SP, 1); |
|
|
1303 | const int i = 0; |
|
|
1304 | PUSHs (sv_2mortal (newSVuv (value [i]))); |
|
|
1305 | |
|
|
1306 | void |
|
|
1307 | gl_mipmap_level (OpenCL::Image self) |
|
|
1308 | PPCODE: |
|
|
1309 | cl_GLint value [1]; |
|
|
1310 | NEED_SUCCESS (GetGlTextureInfo, (self, CL_GL_MIPMAP_LEVEL, sizeof (value), value, 0)); |
|
|
1311 | EXTEND (SP, 1); |
|
|
1312 | const int i = 0; |
|
|
1313 | PUSHs (sv_2mortal (newSViv (value [i]))); |
|
|
1314 | |
|
|
1315 | #END:gl_texture |
|
|
1316 | |
|
|
1317 | #endif |
|
|
1318 | |
1172 | MODULE = OpenCL PACKAGE = OpenCL::Sampler |
1319 | MODULE = OpenCL PACKAGE = OpenCL::Sampler |
1173 | |
1320 | |
1174 | void |
1321 | void |
1175 | DESTROY (OpenCL::Sampler self) |
1322 | DESTROY (OpenCL::Sampler self) |
1176 | CODE: |
1323 | CODE: |
… | |
… | |
1246 | NEED_SUCCESS (BuildProgram, (self, 1, &device, SvPVbyte_nolen (options), 0, 0)); |
1393 | NEED_SUCCESS (BuildProgram, (self, 1, &device, SvPVbyte_nolen (options), 0, 0)); |
1247 | |
1394 | |
1248 | void |
1395 | void |
1249 | build_info (OpenCL::Program self, OpenCL::Device device, cl_program_build_info name) |
1396 | build_info (OpenCL::Program self, OpenCL::Device device, cl_program_build_info name) |
1250 | PPCODE: |
1397 | PPCODE: |
1251 | size_t size; |
1398 | size_t size; |
1252 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, name, 0, 0, &size)); |
1399 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, name, 0, 0, &size)); |
1253 | SV *sv = sv_2mortal (newSV (size)); |
1400 | SV *sv = sv_2mortal (newSV (size)); |
1254 | SvUPGRADE (sv, SVt_PV); |
1401 | SvUPGRADE (sv, SVt_PV); |
1255 | SvPOK_only (sv); |
1402 | SvPOK_only (sv); |
1256 | SvCUR_set (sv, size); |
1403 | SvCUR_set (sv, size); |
1257 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, name, size, SvPVX (sv), 0)); |
1404 | NEED_SUCCESS (GetProgramBuildInfo, (self, device, name, size, SvPVX (sv), 0)); |
1258 | XPUSHs (sv); |
1405 | XPUSHs (sv); |
1259 | |
1406 | |
1260 | #BEGIN:program_build |
1407 | #BEGIN:program_build |
1261 | |
1408 | |
1262 | void |
1409 | void |
… | |
… | |
1285 | #END:program_build |
1432 | #END:program_build |
1286 | |
1433 | |
1287 | void |
1434 | void |
1288 | kernel (OpenCL::Program program, SV *function) |
1435 | kernel (OpenCL::Program program, SV *function) |
1289 | PPCODE: |
1436 | PPCODE: |
1290 | NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res)); |
1437 | NEED_SUCCESS_ARG (cl_kernel kernel, CreateKernel, (program, SvPVbyte_nolen (function), &res)); |
1291 | XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel); |
1438 | XPUSH_NEW_OBJ ("OpenCL::Kernel", kernel); |
1292 | |
1439 | |
1293 | void |
1440 | void |
1294 | info (OpenCL::Program self, cl_program_info name) |
1441 | info (OpenCL::Program self, cl_program_info name) |
1295 | PPCODE: |
1442 | PPCODE: |