Files
ppsspp/Common/TimeUtil.h
T
libretroadmin b570567b88 Give the Vulkan allocator one owning thread
Readback buffers are allocated when the readback is recorded rather than on the render thread,
so only the thread that records frames touches VMA. The allocator is created externally
synchronized, and VMA is built with no-op mutexes and plain counters instead of std::mutex and
std::atomic.

Headless runs Vulkan offscreen in builds without SDL too, and CI runs the headless tests on
lavapipe, skipping the pixel tests a hardware backend doesn't match the software references on.
sleep_ms and sleep_us go, with the thread manager test waiting on an event instead, and so does
the unused portable-file-dialogs header.
2026-10-09 07:37:57 +02:00

56 lines
1.3 KiB
C++

#pragma once
#include <cstdint>
void TimeInit();
void TimeShutdown(); // Not really necessary to call, just for completeness.
// Seconds.
double time_now_d();
// Raw time in nanoseconds.
// The only intended use is to match the timings from VK_GOOGLE_display_timing.
uint64_t time_now_raw();
// This is only interesting for Linux, in relation to VK_GOOGLE_display_timing.
double from_time_raw(uint64_t raw_time);
double from_time_raw_relative(uint64_t raw_time);
// Seconds, Unix UTC time
double time_now_unix_utc();
double time_to_unix_utc(double timeNowSeconds);
void GetCurrentTimeFormatted(char formattedTime[13]);
// Most accurate timer possible - no extra double conversions. Only for spans.
class Instant {
public:
Instant();
static Instant Now() {
return Instant();
}
double ElapsedSeconds() const;
double ElapsedMs() const { return ElapsedSeconds() * 1000.0; }
int64_t ElapsedNanos() const;
private:
uint64_t nativeStart_;
#ifndef _WIN32
int64_t nsecs_;
#endif
};
class TimeCollector {
public:
TimeCollector(double *target, bool enable) : target_(enable ? target : nullptr) {
if (enable)
startTime_ = time_now_d();
}
~TimeCollector() {
if (target_) {
*target_ += time_now_d() - startTime_;
}
}
private:
double startTime_;
double *target_;
};