aboutsummaryrefslogtreecommitdiff
path: root/src/queue_context.cc
diff options
context:
space:
mode:
authorNicolas James <Eele1Ephe7uZahRie@tutanota.com>2026-02-20 20:57:37 +1100
committerNicolas James <Eele1Ephe7uZahRie@tutanota.com>2026-02-20 20:57:37 +1100
commit7f3439714858d4c70f60db71543df15db5708d92 (patch)
tree93ce5d3f5f9ec715b0c3627ae82362175678c9d7 /src/queue_context.cc
parent9954233c9a730acba0a433dabd158ee5e8f131a5 (diff)
Don't inject timestamps into unsupported queues
Diffstat (limited to 'src/queue_context.cc')
-rw-r--r--src/queue_context.cc37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/queue_context.cc b/src/queue_context.cc
index 6968720..d20cc79 100644
--- a/src/queue_context.cc
+++ b/src/queue_context.cc
@@ -4,6 +4,7 @@
#include <algorithm>
#include <chrono>
+#include <fstream>
#include <iostream>
#include <ranges>
#include <span>
@@ -172,12 +173,16 @@ void QueueContext::notify_present(const VkPresentInfoKHR& info) {
this->submissions.clear();
}
-const auto debug_log_time = [](const auto& diff) {
+const auto debug_log_time2 = [](auto& stream, const auto& diff) {
using namespace std::chrono;
const auto ms = duration_cast<milliseconds>(diff);
const auto us = duration_cast<microseconds>(diff - ms);
const auto ns = duration_cast<nanoseconds>(diff - ms - us);
- std::cerr << ms << " " << us << " " << ns << " ago\n";
+ stream << ms << " " << us << " " << ns << " ago\n";
+};
+
+const auto debug_log_time = [](const auto& diff) {
+ debug_log_time2(std::cerr, diff);
};
void QueueContext::process_frames() {
@@ -361,11 +366,6 @@ void QueueContext::sleep_in_present() {
const auto expected_cputime =
calc_median([](const auto& timing) { return timing->cputime; });
- std::cerr << " expected gputime: ";
- debug_log_time(expected_gputime);
- std::cerr << " expected cputime: ";
- debug_log_time(expected_cputime);
-
// Should look like this:
// total_length = expected_gputime
// |------------------------x------------------------------|
@@ -382,6 +382,29 @@ void QueueContext::sleep_in_present() {
last_gpu_work->get_time_spinlock(now + wait_time);
frame.cpu_post_present_time = std::chrono::steady_clock::now();
+
+ std::ofstream f("/tmp/times.txt", std::ios::trunc);
+ f << " expected gputime: ";
+ debug_log_time2(f, expected_gputime);
+ f << " expected cputime: ";
+ debug_log_time2(f, expected_cputime);
+ f << " requestd sleep: ";
+ debug_log_time2(f, wait_time);
+ f << " observed sleep: ";
+ debug_log_time2(f, frame.cpu_post_present_time - now);
+}
+
+bool QueueContext::should_inject_timestamps() const {
+ const auto& pd = this->device_context.physical_device;
+
+ assert(pd.queue_properties);
+ const auto& queue_props = *pd.queue_properties;
+ assert(this->queue_family_index < std::size(queue_props));
+
+ const auto& props = queue_props[this->queue_family_index];
+ // Probably need at least 64, don't worry about it just yet and just ensure
+ // it's not zero (because that will cause a crash if we inject).
+ return props.queueFamilyProperties.timestampValidBits;
}
} // namespace low_latency \ No newline at end of file