ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/OpenCL/OpenCL.xs
(Generate patch)

Comparing OpenCL/OpenCL.xs (file contents):
Revision 1.22 by root, Mon Apr 16 09:42:33 2012 UTC vs.
Revision 1.26 by root, Thu Apr 19 13:06:55 2012 UTC

35 35
36/* up to two temporary buffers */ 36/* up to two temporary buffers */
37static void * 37static void *
38tmpbuf (size_t size) 38tmpbuf (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
137static cl_context_properties *
138SvCONTEXTPROPERTIES (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
136static size_t 186static size_t
137img_row_pitch (cl_mem img) 187img_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
174MODULE = OpenCL PACKAGE = OpenCL 224MODULE = OpenCL PACKAGE = OpenCL
175 225
176PROTOTYPES: ENABLE 226PROTOTYPES: ENABLE
177 227
178BOOT: 228BOOT:
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
199cl_int 249cl_int
200errno () 250errno ()
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
225void 275void
226context_from_type (FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) 276context_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
231void 281void
232context (FUTURE properties, FUTURE devices, FUTURE notify = 0) 282context (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
236void 286void
237wait_for_events (...) 287wait_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
287void 337void
288context (OpenCL::Platform self, FUTURE properties, SV *devices, FUTURE notify = 0) 338context (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
304void 354void
305context_from_type (OpenCL::Platform self, FUTURE properties = 0, cl_device_type type = CL_DEVICE_TYPE_DEFAULT, FUTURE notify = 0) 355context_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
311MODULE = OpenCL PACKAGE = OpenCL::Device 362MODULE = OpenCL PACKAGE = OpenCL::Device
312 363
552 INFO (Context) 603 INFO (Context)
553 604
554void 605void
555queue (OpenCL::Context self, OpenCL::Device device, cl_command_queue_properties properties = 0) 606queue (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
560void 611void
561user_event (OpenCL::Context self) 612user_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
566void 617void
567buffer (OpenCL::Context self, cl_mem_flags flags, size_t len) 618buffer (OpenCL::Context self, cl_mem_flags flags, size_t len)
568 PPCODE: 619 PPCODE:
586image2d (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) 637image2d (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
594void 645void
595image3d (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) 646image3d (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
656void
657gl_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
662void
663gl_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
668void
669gl_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
674void
675gl_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
603void 682void
604supported_image_formats (OpenCL::Context self, cl_mem_flags flags, cl_mem_object_type image_type) 683supported_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
625void 704void
626sampler (OpenCL::Context self, cl_bool normalized_coords, cl_addressing_mode addressing_mode, cl_filter_mode filter_mode) 705sampler (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
631void 710void
632program_with_source (OpenCL::Context self, SV *program) 711program_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
644void 723void
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
1045void
1046enqueue_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
1056void
1057enqueue_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
963void 1070void
964enqueue_marker (OpenCL::Queue self) 1071enqueue_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
1241void
1242gl_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
1132MODULE = OpenCL PACKAGE = OpenCL::BufferObj 1253MODULE = OpenCL PACKAGE = OpenCL::BufferObj
1133 1254
1134void 1255void
1135sub_buffer_region (OpenCL::BufferObj self, cl_mem_flags flags, size_t origin, size_t size) 1256sub_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
1297void
1298target (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
1306void
1307gl_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
1172MODULE = OpenCL PACKAGE = OpenCL::Sampler 1319MODULE = OpenCL PACKAGE = OpenCL::Sampler
1173 1320
1174void 1321void
1175DESTROY (OpenCL::Sampler self) 1322DESTROY (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
1248void 1395void
1249build_info (OpenCL::Program self, OpenCL::Device device, cl_program_build_info name) 1396build_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
1262void 1409void
1285#END:program_build 1432#END:program_build
1286 1433
1287void 1434void
1288kernel (OpenCL::Program program, SV *function) 1435kernel (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
1293void 1440void
1294info (OpenCL::Program self, cl_program_info name) 1441info (OpenCL::Program self, cl_program_info name)
1295 PPCODE: 1442 PPCODE:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines