aboutsummaryrefslogtreecommitdiff
path: root/src/strategies/anti_lag/queue_strategy.cc
blob: 9c49e7c0e042a540b75dd0953d166e6ccc2f4998 (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
50
51
52
53
54
#include "queue_strategy.hh"
#include "device_context.hh"
#include "device_strategy.hh"
#include "queue_context.hh"

namespace low_latency {

AntiLagQueueStrategy::AntiLagQueueStrategy(QueueContext& queue)
    : QueueStrategy(queue) {}

AntiLagQueueStrategy::~AntiLagQueueStrategy() {}

void AntiLagQueueStrategy::notify_submit(
    [[maybe_unused]] const VkSubmitInfo& submit,
    std::shared_ptr<TimestampPool::Handle> handle) {

    const auto strategy =
        dynamic_cast<AntiLagDeviceStrategy*>(this->queue.device.strategy.get());
    assert(strategy);
    if (!strategy->should_track_submissions()) {
        return;
    }

    const auto lock = std::scoped_lock(this->mutex);
    if (this->frame_span) {
        this->frame_span->update(std::move(handle));
    } else {
        this->frame_span = std::make_unique<FrameSpan>(std::move(handle));
    }
}

void AntiLagQueueStrategy::notify_submit(
    [[maybe_unused]] const VkSubmitInfo2& submit,
    std::shared_ptr<TimestampPool::Handle> handle) {

    const auto strategy =
        dynamic_cast<AntiLagDeviceStrategy*>(this->queue.device.strategy.get());
    assert(strategy);
    if (!strategy->should_track_submissions()) {
        return;
    }

    const auto lock = std::scoped_lock(this->mutex);
    if (this->frame_span) {
        this->frame_span->update(std::move(handle));
    } else {
        this->frame_span = std::make_unique<FrameSpan>(std::move(handle));
    }
}

// Stub - AntiLag doesn't care about presents.
void AntiLagQueueStrategy::notify_present(const VkPresentInfoKHR&) {}

} // namespace low_latency