… | |
… | |
4 | |
4 | |
5 | #ifdef __APPLE__ |
5 | #ifdef __APPLE__ |
6 | #include <OpenCL/opencl.h> |
6 | #include <OpenCL/opencl.h> |
7 | #else |
7 | #else |
8 | #include <CL/opencl.h> |
8 | #include <CL/opencl.h> |
9 | #endif |
|
|
10 | #if HAVE_OPENGL |
|
|
11 | #ifdef __APPLE__ |
|
|
12 | #include <OpenGL/gl.h> |
|
|
13 | #include <OpenCL/cl_gl.h> |
|
|
14 | #else |
|
|
15 | #include <GL/gl.h> |
|
|
16 | #include <CL/cl_gl.h> |
|
|
17 | #endif |
|
|
18 | #endif |
9 | #endif |
19 | |
10 | |
20 | typedef cl_platform_id OpenCL__Platform; |
11 | typedef cl_platform_id OpenCL__Platform; |
21 | typedef cl_device_id OpenCL__Device; |
12 | typedef cl_device_id OpenCL__Device; |
22 | typedef cl_context OpenCL__Context; |
13 | typedef cl_context OpenCL__Context; |
… | |
… | |
247 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
238 | { sizeof (cl_long ), "SIZEOF_LONG" }, |
248 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
239 | { sizeof (cl_ulong ), "SIZEOF_ULONG" }, |
249 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
240 | { sizeof (cl_half ), "SIZEOF_HALF" }, |
250 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
241 | { sizeof (cl_float ), "SIZEOF_FLOAT" }, |
251 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
242 | { sizeof (cl_double), "SIZEOF_DOUBLE" }, |
252 | { HAVE_OPENGL , "HAVE_OPENGL" }, |
|
|
253 | #include "constiv.h" |
243 | #include "constiv.h" |
254 | }; |
244 | }; |
255 | 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--) |
256 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
246 | newCONSTSUB (stash, (char *)civ[-1].name, newSViv (civ[-1].iv)); |
257 | } |
247 | } |
… | |
… | |
659 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
649 | char *ptr = SvOK (data) ? SvPVbyte (data, len) : 0; |
660 | const cl_image_format format = { channel_order, channel_type }; |
650 | const cl_image_format format = { channel_order, channel_type }; |
661 | 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)); |
662 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
652 | XPUSH_NEW_OBJ ("OpenCL::Image3D", mem); |
663 | |
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 |
|
|
681 | |
664 | void |
682 | void |
665 | 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) |
666 | PPCODE: |
684 | PPCODE: |
667 | { |
685 | { |
668 | cl_uint count; |
686 | cl_uint count; |
… | |
… | |
1019 | 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)); |
1020 | |
1038 | |
1021 | if (ev) |
1039 | if (ev) |
1022 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1040 | XPUSH_NEW_OBJ ("OpenCL::Event", ev); |
1023 | |
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 | |
1024 | void |
1070 | void |
1025 | enqueue_marker (OpenCL::Queue self) |
1071 | enqueue_marker (OpenCL::Queue self) |
1026 | PPCODE: |
1072 | PPCODE: |
1027 | cl_event ev; |
1073 | cl_event ev; |
1028 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |
1074 | NEED_SUCCESS (EnqueueMarker, (self, &ev)); |