11c8ef0195d8aa69a242b32445c234f24acd71c1
[mesa.git] / src / gallium / state_trackers / clover / core / timestamp.hpp
1 //
2 // Copyright 2013 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
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.
21 //
22
23 #ifndef CLOVER_CORE_TIMESTAMP_HPP
24 #define CLOVER_CORE_TIMESTAMP_HPP
25
26 #include "core/object.hpp"
27
28 struct pipe_query;
29
30 namespace clover {
31 class command_queue;
32
33 namespace timestamp {
34 ///
35 /// Emit a timestamp query that is executed asynchronously by
36 /// the command queue \a q.
37 ///
38 class query {
39 public:
40 query(command_queue &q);
41 query(query &&other);
42 ~query();
43
44 query &operator=(const query &) = delete;
45
46 ///
47 /// Retrieve the query results.
48 ///
49 cl_ulong operator()() const;
50
51 private:
52 command_queue &q;
53 pipe_query *_query;
54 };
55
56 ///
57 /// Get the current timestamp value.
58 ///
59 class current {
60 public:
61 current(command_queue &q);
62
63 ///
64 /// Retrieve the query results.
65 ///
66 cl_ulong operator()() const;
67
68 private:
69 cl_ulong result;
70 };
71 }
72 }
73
74 #endif