Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 1 | // |
| 2 | // Copyright 2012 Francisco Jerez |
| 3 | // |
| 4 | // Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | // copy of this software and associated documentation files (the "Software"), |
| 6 | // to deal in the Software without restriction, including without limitation |
| 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | // and/or sell copies of the Software, and to permit persons to whom the |
| 9 | // Software is furnished to do so, subject to the following conditions: |
| 10 | // |
| 11 | // The above copyright notice and this permission notice shall be included in |
| 12 | // all copies or substantial portions of the Software. |
| 13 | // |
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
Kenneth Graunke | f0cb66b | 2013-04-21 13:52:08 -0700 | [diff] [blame] | 17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 | // OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 | // OTHER DEALINGS IN THE SOFTWARE. |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 21 | // |
| 22 | |
Francisco Jerez | 099d281 | 2013-09-15 15:29:34 -0700 | [diff] [blame] | 23 | #ifndef CLOVER_CORE_QUEUE_HPP |
| 24 | #define CLOVER_CORE_QUEUE_HPP |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 25 | |
Francisco Jerez | 6db1025 | 2013-09-15 23:04:28 -0700 | [diff] [blame] | 26 | #include <deque> |
Tom Stellard | f546902 | 2015-05-07 13:57:14 +0000 | [diff] [blame] | 27 | #include <mutex> |
Francisco Jerez | 6db1025 | 2013-09-15 23:04:28 -0700 | [diff] [blame] | 28 | |
Francisco Jerez | bff60c8 | 2013-10-06 13:51:01 -0700 | [diff] [blame] | 29 | #include "core/object.hpp" |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 30 | #include "core/context.hpp" |
Francisco Jerez | ebfdce0 | 2013-10-06 13:48:23 -0700 | [diff] [blame] | 31 | #include "core/timestamp.hpp" |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 32 | #include "pipe/p_context.h" |
| 33 | |
| 34 | namespace clover { |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 35 | class resource; |
| 36 | class mapping; |
| 37 | class hard_event; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 38 | |
| 39 | class command_queue : public ref_counter, public _cl_command_queue { |
| 40 | public: |
Francisco Jerez | c4578d2 | 2014-02-18 15:07:11 +0100 | [diff] [blame] | 41 | command_queue(clover::context &ctx, clover::device &dev, |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 42 | cl_command_queue_properties props); |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 43 | ~command_queue(); |
| 44 | |
Francisco Jerez | 5226eac | 2013-09-16 21:44:36 -0700 | [diff] [blame] | 45 | command_queue(const command_queue &q) = delete; |
| 46 | command_queue & |
| 47 | operator=(const command_queue &q) = delete; |
| 48 | |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 49 | void flush(); |
| 50 | |
Francisco Jerez | 9b2fe7c | 2014-02-18 13:12:52 +0100 | [diff] [blame] | 51 | cl_command_queue_properties properties() const; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 52 | bool profiling_enabled() const; |
| 53 | |
Francisco Jerez | c4578d2 | 2014-02-18 15:07:11 +0100 | [diff] [blame] | 54 | const intrusive_ref<clover::context> context; |
| 55 | const intrusive_ref<clover::device> device; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 56 | |
| 57 | friend class resource; |
| 58 | friend class root_resource; |
| 59 | friend class mapping; |
| 60 | friend class hard_event; |
Francisco Jerez | 04d0ab9 | 2013-09-15 22:20:43 -0700 | [diff] [blame] | 61 | friend class sampler; |
Francisco Jerez | 35307f5 | 2013-09-17 23:20:11 -0700 | [diff] [blame] | 62 | friend class kernel; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 63 | friend class clover::timestamp::query; |
| 64 | friend class clover::timestamp::current; |
| 65 | |
| 66 | private: |
| 67 | /// Serialize a hardware event with respect to the previous ones, |
| 68 | /// and push it to the pending list. |
Francisco Jerez | c4578d2 | 2014-02-18 15:07:11 +0100 | [diff] [blame] | 69 | void sequence(hard_event &ev); |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 70 | |
Francisco Jerez | 9b2fe7c | 2014-02-18 13:12:52 +0100 | [diff] [blame] | 71 | cl_command_queue_properties props; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 72 | pipe_context *pipe; |
Tom Stellard | f546902 | 2015-05-07 13:57:14 +0000 | [diff] [blame] | 73 | std::mutex queued_events_mutex; |
Francisco Jerez | c4578d2 | 2014-02-18 15:07:11 +0100 | [diff] [blame] | 74 | std::deque<intrusive_ref<hard_event>> queued_events; |
Francisco Jerez | 9968d9d | 2013-10-01 11:57:32 -0700 | [diff] [blame] | 75 | }; |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 76 | } |
| 77 | |
Francisco Jerez | c6db1b3 | 2012-04-20 16:56:19 +0200 | [diff] [blame] | 78 | #endif |