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

Comparing OpenCL/OpenCL.pm (file contents):
Revision 1.84 by root, Sat May 5 16:44:02 2012 UTC vs.
Revision 1.88 by root, Tue Oct 22 17:25:38 2013 UTC

232 # find and use the first opencl device that let's us get a shared opengl context 232 # find and use the first opencl device that let's us get a shared opengl context
233 my $platform; 233 my $platform;
234 my $dev; 234 my $dev;
235 my $ctx; 235 my $ctx;
236 236
237 sub get_context {
237 for (OpenCL::platforms) { 238 for (OpenCL::platforms) {
238 $platform = $_; 239 $platform = $_;
239 for ($platform->devices) { 240 for ($platform->devices) {
240 $dev = $_; 241 $dev = $_;
241 $ctx = $platform->context ([OpenCL::GLX_DISPLAY_KHR, undef, OpenCL::GL_CONTEXT_KHR, undef], [$dev]) 242 $ctx = eval { $platform->context ([OpenCL::GLX_DISPLAY_KHR, undef, OpenCL::GL_CONTEXT_KHR, undef], [$dev]) }
242 and last; 243 and return;
244 }
243 } 245 }
246
247 die "cannot find suitable OpenCL device\n";
244 } 248 }
245 249
246 $ctx 250 get_context;
247 or die "cannot find suitable OpenCL device\n";
248 251
249 my $queue = $ctx->queue ($dev); 252 my $queue = $ctx->queue ($dev);
250 253
251 # now attach an opencl image2d object to the opengl texture 254 # now attach an opencl image2d object to the opengl texture
252 my $tex = $ctx->gl_texture2d (OpenCL::MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, $texid); 255 my $tex = $ctx->gl_texture2d (OpenCL::MEM_WRITE_ONLY, GL_TEXTURE_2D, 0, $texid);
399=head2 CONSTANTS 402=head2 CONSTANTS
400 403
401All C<CL_xxx> constants that this module supports are always available 404All C<CL_xxx> constants that this module supports are always available
402in the C<OpenCL> namespace as C<OpenCL::xxx> (i.e. without the C<CL_> 405in the C<OpenCL> namespace as C<OpenCL::xxx> (i.e. without the C<CL_>
403prefix). Constants which are not defined in the header files used during 406prefix). Constants which are not defined in the header files used during
404compilation, or otherwise are not available, will have the value C<-1>. 407compilation, or otherwise are not available, will have the value C<0> (in
408some cases, this will make them indistinguishable from real constants,
409sorry).
405 410
406The latest version of this module knows and exports the constants 411The latest version of this module knows and exports the constants
407listed in L<http://cvs.schmorp.de/OpenCL/constiv.h>. 412listed in L<http://cvs.schmorp.de/OpenCL/constiv.h>.
408 413
409=head2 OPENCL 1.1 VS. OPENCL 1.2 414=head2 OPENCL 1.1 VS. OPENCL 1.2
595use Async::Interrupt (); 600use Async::Interrupt ();
596 601
597our $POLL_FUNC; # set by XS 602our $POLL_FUNC; # set by XS
598 603
599BEGIN { 604BEGIN {
600 our $VERSION = '0.99'; 605 our $VERSION = '1.01';
601 606
602 require XSLoader; 607 require XSLoader;
603 XSLoader::load (__PACKAGE__, $VERSION); 608 XSLoader::load (__PACKAGE__, $VERSION);
604 609
605 @OpenCL::Platform::ISA = 610 @OpenCL::Platform::ISA =
1218OpenCL::MEM_USE_HOST_PTR, OpenCL::MEM_ALLOC_HOST_PTR, OpenCL::MEM_COPY_HOST_PTR, 1223OpenCL::MEM_USE_HOST_PTR, OpenCL::MEM_ALLOC_HOST_PTR, OpenCL::MEM_COPY_HOST_PTR,
1219OpenCL::MEM_HOST_WRITE_ONLY, OpenCL::MEM_HOST_READ_ONLY, OpenCL::MEM_HOST_NO_ACCESS. 1224OpenCL::MEM_HOST_WRITE_ONLY, OpenCL::MEM_HOST_READ_ONLY, OpenCL::MEM_HOST_NO_ACCESS.
1220 1225
1221L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html> 1226L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clCreateBuffer.html>
1222 1227
1228A somewhat informative thread on the flags is:
1229
1230L<http://www.khronos.org/message_boards/viewtopic.php?f=28&t=2440>
1231
1223=item $buf = $ctx->buffer_sv ($flags, $data) 1232=item $buf = $ctx->buffer_sv ($flags, $data)
1224 1233
1225Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object and 1234Creates a new OpenCL::Buffer (actually OpenCL::BufferObj) object and
1226initialise it with the given data values. 1235initialise it with the given data values.
1227 1236

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines