blob: a52c59c789365da2cb99fa542994aa0ac679fa6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#ifndef CLOCK_HH_
#define CLOCK_HH_
#include <chrono>
// This header provides a DeviceClock that abstracts away the Vulkan details of
// comparing CPU and GPU times.
namespace low_latency {
class DeviceContext;
class DeviceClock final {
public:
// FIXME this is bad, see now().
using time_point_t = std::chrono::time_point<std::chrono::steady_clock,
std::chrono::nanoseconds>;
const DeviceContext& device;
public:
std::uint64_t host_ns;
std::uint64_t error_bound;
std::uint64_t device_ticks;
public:
DeviceClock(const DeviceContext& device);
DeviceClock(const DeviceClock&) = delete;
DeviceClock(DeviceClock&&) = delete;
DeviceClock operator=(const DeviceClock&) = delete;
DeviceClock operator=(DeviceClock&&) = delete;
~DeviceClock();
public:
// WARNING: This *MUST* be used over std::chrono::steady_clock::now if
// you're planning on comparing it to a device's clock. If it isn't, the
// timestamps might from different domains and will be completely
// nonsensical.
// FIXME we should be able to fix this with a tiny wrapper class of
// time_point_t that enforces typesafety.
static time_point_t now();
public:
void calibrate();
time_point_t ticks_to_time(const std::uint64_t& ticks) const;
};
} // namespace low_latency
#endif
|