… | |
… | |
213 | $ev->wait; |
213 | $ev->wait; |
214 | |
214 | |
215 | =head2 Use the OpenGL module to share a texture between OpenCL and OpenGL and draw some julia |
215 | =head2 Use the OpenGL module to share a texture between OpenCL and OpenGL and draw some julia |
216 | set flight effect. |
216 | set flight effect. |
217 | |
217 | |
218 | This is quite a long example to get you going - you can download it from |
218 | This is quite a long example to get you going - you can also download it |
219 | L<http://cvs.schmorp.de/OpenCL/examples/juliaflight>. |
219 | from L<http://cvs.schmorp.de/OpenCL/examples/juliaflight>. |
220 | |
220 | |
221 | use OpenGL ":all"; |
221 | use OpenGL ":all"; |
222 | use OpenCL; |
222 | use OpenCL; |
223 | |
223 | |
224 | my $S = $ARGV[0] || 256; # window/texture size, smaller is faster |
224 | my $S = $ARGV[0] || 256; # window/texture size, smaller is faster |
… | |
… | |
398 | |
398 | |
399 | =head2 CONSTANTS |
399 | =head2 CONSTANTS |
400 | |
400 | |
401 | All C<CL_xxx> constants that this module supports are always available |
401 | All C<CL_xxx> constants that this module supports are always available |
402 | in the C<OpenCL> namespace as C<OpenCL::xxx> (i.e. without the C<CL_> |
402 | in the C<OpenCL> namespace as C<OpenCL::xxx> (i.e. without the C<CL_> |
403 | prefix). Constants which are not defined in the heaer files used during |
403 | prefix). Constants which are not defined in the header files used during |
404 | compilation, or otherwise are not available, will have the value C<-1>. |
404 | compilation, or otherwise are not available, will have the value C<0> (in |
|
|
405 | some cases, this will make them indistinguishable from real constants, |
|
|
406 | sorry). |
|
|
407 | |
|
|
408 | The latest version of this module knows and exports the constants |
|
|
409 | listed in L<http://cvs.schmorp.de/OpenCL/constiv.h>. |
405 | |
410 | |
406 | =head2 OPENCL 1.1 VS. OPENCL 1.2 |
411 | =head2 OPENCL 1.1 VS. OPENCL 1.2 |
407 | |
412 | |
408 | This module supports both OpenCL version 1.1 and 1.2, although the OpenCL |
413 | This module supports both OpenCL version 1.1 and 1.2, although the OpenCL |
409 | 1.2 interface hasn't been tested much for lack of availability of an |
414 | 1.2 interface hasn't been tested much for lack of availability of an |
… | |
… | |
413 | particular OpenCL function has a link to the its C manual page. |
418 | particular OpenCL function has a link to the its C manual page. |
414 | |
419 | |
415 | If the link contains a F<1.1>, then this function is an OpenCL 1.1 |
420 | If the link contains a F<1.1>, then this function is an OpenCL 1.1 |
416 | function. Most but not all also exist in OpenCL 1.2, and this module |
421 | function. Most but not all also exist in OpenCL 1.2, and this module |
417 | tries to emulate the missing ones for you, when told to do so at |
422 | tries to emulate the missing ones for you, when told to do so at |
418 | compiletime. You cna check whether a function was removed in OpenCL 1.2 by |
423 | compiletime. You can check whether a function was removed in OpenCL 1.2 by |
419 | replacing the F<1.1> component in the URL by F<1.2>. |
424 | replacing the F<1.1> component in the URL by F<1.2>. |
420 | |
425 | |
421 | If the link contains a F<1.2>, then this is a OpenCL 1.2-only |
426 | If the link contains a F<1.2>, then this is a OpenCL 1.2-only |
422 | function. Even if the module was compiled with OpenCL 1.2 header files |
427 | function. Even if the module was compiled with OpenCL 1.2 header files |
423 | and has an 1.2 OpenCL library, calling such a function on a platform that |
428 | and has an 1.2 OpenCL library, calling such a function on a platform that |
… | |
… | |
592 | use Async::Interrupt (); |
597 | use Async::Interrupt (); |
593 | |
598 | |
594 | our $POLL_FUNC; # set by XS |
599 | our $POLL_FUNC; # set by XS |
595 | |
600 | |
596 | BEGIN { |
601 | BEGIN { |
597 | our $VERSION = '0.99'; |
602 | our $VERSION = '1.0'; |
598 | |
603 | |
599 | require XSLoader; |
604 | require XSLoader; |
600 | XSLoader::load (__PACKAGE__, $VERSION); |
605 | XSLoader::load (__PACKAGE__, $VERSION); |
601 | |
606 | |
602 | @OpenCL::Platform::ISA = |
607 | @OpenCL::Platform::ISA = |
… | |
… | |
638 | The last error returned by a function - it's only valid after an error occured |
643 | The last error returned by a function - it's only valid after an error occured |
639 | and before calling another OpenCL function. |
644 | and before calling another OpenCL function. |
640 | |
645 | |
641 | =item $str = OpenCL::err2str [$errval] |
646 | =item $str = OpenCL::err2str [$errval] |
642 | |
647 | |
643 | Converts an error value into a human readable string. IF no error value is |
648 | Converts an error value into a human readable string. If no error value is |
644 | given, then the last error will be used (as returned by OpenCL::errno). |
649 | given, then the last error will be used (as returned by OpenCL::errno). |
|
|
650 | |
|
|
651 | The latest version of this module knows the error constants |
|
|
652 | listed in L<http://cvs.schmorp.de/OpenCL/errstr.h>. |
645 | |
653 | |
646 | =item $str = OpenCL::enum2str $enum |
654 | =item $str = OpenCL::enum2str $enum |
647 | |
655 | |
648 | Converts most enum values (of parameter names, image format constants, |
656 | Converts most enum values (of parameter names, image format constants, |
649 | object types, addressing and filter modes, command types etc.) into a |
657 | object types, addressing and filter modes, command types etc.) into a |
650 | human readable string. When confronted with some random integer it can be |
658 | human readable string. When confronted with some random integer it can be |
651 | very helpful to pass it through this function to maybe get some readable |
659 | very helpful to pass it through this function to maybe get some readable |
652 | string out of it. |
660 | string out of it. |
|
|
661 | |
|
|
662 | The latest version of this module knows the enumaration constants |
|
|
663 | listed in L<http://cvs.schmorp.de/OpenCL/enumstr.h>. |
653 | |
664 | |
654 | =item @platforms = OpenCL::platforms |
665 | =item @platforms = OpenCL::platforms |
655 | |
666 | |
656 | Returns all available OpenCL::Platform objects. |
667 | Returns all available OpenCL::Platform objects. |
657 | |
668 | |
… | |
… | |
1413 | |
1424 | |
1414 | =item $ev = $queue->copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
1425 | =item $ev = $queue->copy_buffer ($src, $dst, $src_offset, $dst_offset, $len, $wait_events...) |
1415 | |
1426 | |
1416 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
1427 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBuffer.html> |
1417 | |
1428 | |
1418 | =item $ev = $queue->read_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) |
1429 | $eue->read_buffer_rect ($buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) |
1419 | |
1430 | |
1420 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html |
1431 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadBufferRect.html |
1421 | |
1432 | |
1422 | =item $ev = $queue->write_buffer_rect (OpenCL::Memory buf, cl_bool blocking, $buf_x, $buf_y, $buf_z, $host_x, $host_y, $host_z, $width, $height, $depth, $buf_row_pitch, $buf_slice_pitch, $host_row_pitch, $host_slice_pitch, $data, $wait_events...) |
1433 | =item $ev = $queue->write_buffer_rect ($buf, $blocking, $buf_y, $host_x, $host_z, $height, $buf_row_pitch, $host_row_pitch, $data, $wait_events...) |
1423 | |
1434 | |
1424 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1435 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1425 | |
1436 | |
1426 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1437 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1427 | |
1438 | |
… | |
… | |
1611 | it. You are not necessarily meant to do it this way, this example just |
1622 | it. You are not necessarily meant to do it this way, this example just |
1612 | shows you the accessors to use :) |
1623 | shows you the accessors to use :) |
1613 | |
1624 | |
1614 | my $mapped = $queue->map_image ($image, 1, OpenCL::MAP_WRITE); |
1625 | my $mapped = $queue->map_image ($image, 1, OpenCL::MAP_WRITE); |
1615 | |
1626 | |
1616 | $mapped->set ($_ * $mapped->row_pitch, pack "C", 5) |
1627 | $mapped->write ($_ * $mapped->row_pitch, pack "C", 5) |
1617 | for 0..$image->height; |
1628 | for 0 .. $mapped->height - 1; |
1618 | |
1629 | |
1619 | $mapped->unmap;. |
1630 | $mapped->unmap;. |
1620 | $mapped->wait; # only needed for out of order queues normally |
1631 | $mapped->wait; # only needed for out of order queues normally |
1621 | |
1632 | |
1622 | =item $ev = $queue->unmap ($mapped, $wait_events...) |
1633 | =item $ev = $queue->unmap ($mapped, $wait_events...) |
… | |
… | |
1641 | =item $packed_value = $memory->info ($name) |
1652 | =item $packed_value = $memory->info ($name) |
1642 | |
1653 | |
1643 | See C<< $platform->info >> for details. |
1654 | See C<< $platform->info >> for details. |
1644 | |
1655 | |
1645 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html> |
1656 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clGetMemObjectInfo.html> |
|
|
1657 | |
|
|
1658 | =item $memory->destructor_callback ($cb->()) |
|
|
1659 | |
|
|
1660 | Sets a callback that will be invoked after the memory object is destructed. |
|
|
1661 | |
|
|
1662 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clSetMemObjectDestructorCallback.html> |
1646 | |
1663 | |
1647 | =for gengetinfo begin mem |
1664 | =for gengetinfo begin mem |
1648 | |
1665 | |
1649 | =item $mem_object_type = $mem->type |
1666 | =item $mem_object_type = $mem->type |
1650 | |
1667 | |
… | |
… | |
2328 | |
2345 | |
2329 | This is a subclass of OpenCL::Mapped, representing mapped images. |
2346 | This is a subclass of OpenCL::Mapped, representing mapped images. |
2330 | |
2347 | |
2331 | =over 4 |
2348 | =over 4 |
2332 | |
2349 | |
|
|
2350 | =item $pixels = $mapped->width |
|
|
2351 | |
|
|
2352 | =item $pixels = $mapped->height |
|
|
2353 | |
|
|
2354 | =item $pixels = $mapped->depth |
|
|
2355 | |
|
|
2356 | Return the width/height/depth of the mapped image region, in pixels. |
|
|
2357 | |
2333 | =item $bytes = $mapped->row_pitch |
2358 | =item $bytes = $mapped->row_pitch |
2334 | |
2359 | |
2335 | =item $bytes = $mapped->slice_pitch |
2360 | =item $bytes = $mapped->slice_pitch |
2336 | |
2361 | |
2337 | Return the row or slice pitch of the image that has been mapped. |
2362 | Return the row or slice pitch of the image that has been mapped. |
2338 | |
2363 | |
|
|
2364 | =item $bytes = $mapped->element_size |
|
|
2365 | |
|
|
2366 | Return the size of a single pixel. |
|
|
2367 | |
|
|
2368 | =item $data = $mapped->get_row ($count, $x=0, $y=0, $z=0) |
|
|
2369 | |
|
|
2370 | Return C<$count> pixels from the given coordinates. The pixel data must |
|
|
2371 | be completely contained within a single row. |
|
|
2372 | |
|
|
2373 | If C<$count> is C<undef>, then all the remaining pixels in that row are |
|
|
2374 | returned. |
|
|
2375 | |
|
|
2376 | =item $mapped->set_row ($data, $x=0, $y=0, $z=0) |
|
|
2377 | |
|
|
2378 | Write the given pixel data at the given coordinate. The pixel data must |
|
|
2379 | be completely contained within a single row. |
|
|
2380 | |
2339 | =back |
2381 | =back |
2340 | |
|
|
2341 | |
2382 | |
2342 | =cut |
2383 | =cut |
2343 | |
2384 | |
2344 | 1; |
2385 | 1; |
2345 | |
2386 | |