]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/include/boost/compute/interop/opengl/acquire.hpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / include / boost / compute / interop / opengl / acquire.hpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2013-2014 Kyle Lutz <kyle.r.lutz@gmail.com>
3 //
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
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #ifndef BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
12 #define BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP
13
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>
19
20 namespace boost {
21 namespace compute {
22
23 /// Enqueues a command to acquire the specified OpenGL memory objects.
24 ///
25 /// \see_opencl_ref{clEnqueueAcquireGLObjects}
26 inline event opengl_enqueue_acquire_gl_objects(const uint_ num_objects,
27 const cl_mem *mem_objects,
28 command_queue &queue,
29 const wait_list &events = wait_list())
30 {
31 BOOST_ASSERT(queue != 0);
32
33 event event_;
34
35 cl_int ret = clEnqueueAcquireGLObjects(queue.get(),
36 num_objects,
37 mem_objects,
38 events.size(),
39 events.get_event_ptr(),
40 &event_.get());
41 if(ret != CL_SUCCESS){
42 BOOST_THROW_EXCEPTION(opencl_error(ret));
43 }
44
45 return event_;
46 }
47
48 /// Enqueues a command to release the specified OpenGL memory objects.
49 ///
50 /// \see_opencl_ref{clEnqueueReleaseGLObjects}
51 inline event opengl_enqueue_release_gl_objects(const uint_ num_objects,
52 const cl_mem *mem_objects,
53 command_queue &queue,
54 const wait_list &events = wait_list())
55 {
56 BOOST_ASSERT(queue != 0);
57
58 event event_;
59
60 cl_int ret = clEnqueueReleaseGLObjects(queue.get(),
61 num_objects,
62 mem_objects,
63 events.size(),
64 events.get_event_ptr(),
65 &event_.get());
66 if(ret != CL_SUCCESS){
67 BOOST_THROW_EXCEPTION(opencl_error(ret));
68 }
69
70 return event_;
71 }
72
73 /// Enqueues a command to acquire the specified OpenGL buffer.
74 ///
75 /// \see_opencl_ref{clEnqueueAcquireGLObjects}
76 inline event opengl_enqueue_acquire_buffer(const opengl_buffer &buffer,
77 command_queue &queue,
78 const wait_list &events = wait_list())
79 {
80 BOOST_ASSERT(buffer.get_context() == queue.get_context());
81
82 return opengl_enqueue_acquire_gl_objects(1, &buffer.get(), queue, events);
83 }
84
85 /// Enqueues a command to release the specified OpenGL buffer.
86 ///
87 /// \see_opencl_ref{clEnqueueReleaseGLObjects}
88 inline event opengl_enqueue_release_buffer(const opengl_buffer &buffer,
89 command_queue &queue,
90 const wait_list &events = wait_list())
91 {
92 BOOST_ASSERT(buffer.get_context() == queue.get_context());
93
94 return opengl_enqueue_release_gl_objects(1, &buffer.get(), queue, events);
95 }
96
97 } // end compute namespace
98 } // end boost namespace
99
100 #endif // BOOST_COMPUTE_INTEROP_OPENGL_ACQUIRE_HPP