1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
11 #ifndef BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
12 #define BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
14 #include <boost/compute/command_queue.hpp>
15 #include <boost/compute/interop/opengl/cl_gl.hpp>
16 #include <boost/compute/interop/opengl/opengl_buffer.hpp>
17 #include <boost/compute/types/fundamental.hpp>
18 #include <boost/compute/utility/wait_list.hpp>
23 /// Enqueues a command to acquire the specified OpenGL memory objects.
25 /// \see_opencl_ref{clEnqueueAcquireGLObjects}
26 inline event opengl_enqueue_acquire_gl_objects(const uint_ num_objects,
27 const cl_mem *mem_objects,
29 const wait_list &events = wait_list())
31 BOOST_ASSERT(queue != 0);
35 cl_int ret = clEnqueueAcquireGLObjects(queue.get(),
39 events.get_event_ptr(),
41 if(ret != CL_SUCCESS){
42 BOOST_THROW_EXCEPTION(opencl_error(ret));
48 /// Enqueues a command to release the specified OpenGL memory objects.
50 /// \see_opencl_ref{clEnqueueReleaseGLObjects}
51 inline event opengl_enqueue_release_gl_objects(const uint_ num_objects,
52 const cl_mem *mem_objects,
54 const wait_list &events = wait_list())
56 BOOST_ASSERT(queue != 0);
60 cl_int ret = clEnqueueReleaseGLObjects(queue.get(),
64 events.get_event_ptr(),
66 if(ret != CL_SUCCESS){
67 BOOST_THROW_EXCEPTION(opencl_error(ret));
73 /// Enqueues a command to acquire the specified OpenGL buffer.
75 /// \see_opencl_ref{clEnqueueAcquireGLObjects}
76 inline event opengl_enqueue_acquire_buffer(const opengl_buffer &buffer,
78 const wait_list &events = wait_list())
80 BOOST_ASSERT(buffer.get_context() == queue.get_context());
82 return opengl_enqueue_acquire_gl_objects(1, &buffer.get(), queue, events);
85 /// Enqueues a command to release the specified OpenGL buffer.
87 /// \see_opencl_ref{clEnqueueReleaseGLObjects}
88 inline event opengl_enqueue_release_buffer(const opengl_buffer &buffer,
90 const wait_list &events = wait_list())
92 BOOST_ASSERT(buffer.get_context() == queue.get_context());
94 return opengl_enqueue_release_gl_objects(1, &buffer.get(), queue, events);
97 } // end compute namespace
98 } // end boost namespace
100 #endif // BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP