diff options
| author | Nicolas James <nj3ahxac@gmail.com> | 2026-03-29 20:44:23 +1100 |
|---|---|---|
| committer | Nicolas James <nj3ahxac@gmail.com> | 2026-03-29 20:44:23 +1100 |
| commit | 681bd5096ee416b50dd7338de30af7b3db385a36 (patch) | |
| tree | 358b6bc6f9a3af66729b8ac3b15dd38cc0f4bd2a /src/device_clock.hh | |
| parent | d5ef2dbbd77c69dd93e92d5b7046a65c2361b59b (diff) | |
Implement Reflex - break AntiLag in the process. Remove AntiLag1. WIP
Diffstat (limited to 'src/device_clock.hh')
| -rw-r--r-- | src/device_clock.hh | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/device_clock.hh b/src/device_clock.hh new file mode 100644 index 0000000..a52c59c --- /dev/null +++ b/src/device_clock.hh @@ -0,0 +1,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
\ No newline at end of file |
