… | |
… | |
304 | |
304 | |
305 | glXSwapBuffers; |
305 | glXSwapBuffers; |
306 | |
306 | |
307 | select undef, undef, undef, 1/60; |
307 | select undef, undef, undef, 1/60; |
308 | } |
308 | } |
|
|
309 | |
|
|
310 | =item How to modify the previous example to not rely on GL sharing. |
|
|
311 | |
|
|
312 | For those poor souls with only a sucky CPU OpenCL implementation, you |
|
|
313 | currently have to read the image into some perl scalar, and then modify a |
|
|
314 | texture or use glDrawPixels or so). |
|
|
315 | |
|
|
316 | First, when you don't need gl sharing, you can create the context much simpler: |
|
|
317 | |
|
|
318 | $ctx = $platform->context (undef, [$dev]) |
|
|
319 | |
|
|
320 | To use a texture, you would modify the above example by creating an |
|
|
321 | OpenCL::Image manually instead of deriving it from a texture: |
|
|
322 | |
|
|
323 | my $tex = $ctx->image2d (OpenCL::MEM_WRITE_ONLY, OpenCL::RGBA, OpenCL::UNORM_INT8, $S, $S); |
|
|
324 | |
|
|
325 | And in the darw loop, intead of acquire_gl_objects/release_gl_objects, you |
|
|
326 | would read the image2d after the kernel has written it: |
|
|
327 | |
|
|
328 | $queue->read_image ($tex, 0, 0, 0, 0, $S, $S, 1, 0, 0, my $data); |
|
|
329 | |
|
|
330 | And then you would upload the pixel data to the texture (or use glDrawPixels): |
|
|
331 | |
|
|
332 | glTexSubImage2D_s GL_TEXTURE_2D, 0, 0, 0, $S, $S, GL_RGBA, GL_UNSIGNED_BYTE, $data; |
|
|
333 | |
|
|
334 | The fully modified example can be found at |
|
|
335 | L<http://cvs.schmorp.de/OpenCL/examples/juliaflight-nosharing>. |
309 | |
336 | |
310 | =head1 DOCUMENTATION |
337 | =head1 DOCUMENTATION |
311 | |
338 | |
312 | =head2 BASIC CONVENTIONS |
339 | =head2 BASIC CONVENTIONS |
313 | |
340 | |
… | |
… | |
1207 | |
1234 | |
1208 | =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...) |
1235 | =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...) |
1209 | |
1236 | |
1210 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1237 | http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteBufferRect.html |
1211 | |
1238 | |
|
|
1239 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
1240 | |
|
|
1241 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferToImage.html> |
|
|
1242 | |
1212 | =item $ev = $queue->read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
1243 | =item $ev = $queue->read_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
1213 | |
1244 | |
1214 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyBufferRect.html> |
1245 | C<$row_pitch> (and C<$slice_pitch>) can be C<0>, in which case the OpenCL |
1215 | |
1246 | module uses the image width (and height) to supply default values. |
1216 | =item $ev = $queue->copy_buffer_to_image ($src_buffer, $dst_image, $src_offset, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
|
|
1217 | |
1247 | |
1218 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
1248 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueReadImage.html> |
1219 | |
1249 | |
1220 | =item $ev = $queue->write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
1250 | =item $ev = $queue->write_image ($src, $blocking, $x, $y, $z, $width, $height, $depth, $row_pitch, $slice_pitch, $data, $wait_events...) |
1221 | |
1251 | |
|
|
1252 | C<$row_pitch> (and C<$slice_pitch>) can be C<0>, in which case the OpenCL |
|
|
1253 | module uses the image width (and height) to supply default values. |
1222 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
1254 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueWriteImage.html> |
1223 | |
1255 | |
1224 | =item $ev = $queue->copy_image ($src_image, $dst_image, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1256 | =item $ev = $queue->copy_image ($src_image, $dst_image, $src_x, $src_y, $src_z, $dst_x, $dst_y, $dst_z, $width, $height, $depth, $wait_events...) |
1225 | |
1257 | |
1226 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |
1258 | L<http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clEnqueueCopyImage.html> |