aboutsummaryrefslogtreecommitdiff
path: root/src/queue_context.cc
diff options
context:
space:
mode:
authorNicolas James <nj3ahxac@gmail.com>2026-02-18 16:14:25 +1100
committerNicolas James <nj3ahxac@gmail.com>2026-02-18 16:14:25 +1100
commitbb6195afa0fc2ae2a5fe00b718fc71630a696855 (patch)
tree3f2baddeaa4fa28a88a5d4481f635bb91e1cb2e7 /src/queue_context.cc
parentbb7c9b56e1710a7f2a3f4bb57f181e4fa196aba2 (diff)
Fix incorrect dist calcuation
Diffstat (limited to 'src/queue_context.cc')
-rw-r--r--src/queue_context.cc22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/queue_context.cc b/src/queue_context.cc
index 363149b..3914691 100644
--- a/src/queue_context.cc
+++ b/src/queue_context.cc
@@ -288,6 +288,20 @@ void QueueContext::process_frames() {
return merged;
}();
+ // It's important to note that gputime starts from a point which isn't
+ // equal to the below 'start' var. It looks something like this, where a
+ // '-' represents CPU time only and '=' represents CPU + GPU.
+ //
+ // |---------------------|=========|--------|====|-----------------|
+ // ^ last_present ^ merged.front().start present ^
+ // merged.back().end ^
+ //
+ // I would imagine there would be more GPU than cpu to reach the anti
+ // lag codepath than is depicted here. We can track the total time
+ // between vkPresent calls as future_submit - last_submit. The total
+ // time the GPU spent engaged is the sum of all intervals. So we can
+ // get a meaningful 'not_gputime' as total - gpu_time.
+
const auto gputime = std::ranges::fold_left(
merged, DeviceContext::Clock::time_point_t::duration{},
[](auto gputime, const auto& interval) {
@@ -295,12 +309,6 @@ void QueueContext::process_frames() {
return gputime + (end - start);
});
- // The start should be the previous frame's last submission, NOT when we
- // start here. Otherwise, we won't account for the time between the
- // previous frame's last submission and our first submission, which
- // could genuinely be a large period of time. So look for it in timings,
- // because it's guaranteed to be there at this stage. Either that, or
- // we're the first frame, and it doesn't really matter.
const auto start = frame.prev_frame_last_submit->end_handle->get_time();
const auto end = merged.back().end;
const auto not_gputime = (end - start) - gputime;
@@ -425,7 +433,7 @@ void QueueContext::sleep_in_present() {
// We now know that A is available because its semaphore has been
// signalled.
- const auto a = frame.prev_frame_last_submit->end_handle->get_time();
+ const auto a = frame.submissions.front()->start_handle->get_time();
const auto now = std::chrono::steady_clock::now();
const auto dist = now - a;