summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/vi/conductor.h
blob: 52e3595d2171f060eb2bbb12ea6716f69e14a432 (plain) (blame)
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
55
56
57
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <memory>
#include <unordered_map>

#include "common/common_types.h"
#include "common/polyfill_thread.h"
#include "common/thread.h"

namespace Core {
class System;
}

namespace Core::Timing {
struct EventType;
}

namespace Service {
class Event;
}

namespace Service::VI {

class Container;
class DisplayList;
class VsyncManager;

class Conductor {
public:
    explicit Conductor(Core::System& system, Container& container, DisplayList& displays);
    ~Conductor();

    void LinkVsyncEvent(u64 display_id, Event* event);
    void UnlinkVsyncEvent(u64 display_id, Event* event);

private:
    void ProcessVsync();
    void VsyncThread(std::stop_token token);
    s64 GetNextTicks() const;

private:
    Core::System& m_system;
    Container& m_container;
    std::unordered_map<u64, VsyncManager> m_vsync_managers;
    std::shared_ptr<Core::Timing::EventType> m_event;
    Common::Event m_signal;
    std::jthread m_thread;

private:
    s32 m_swap_interval = 1;
    f32 m_compose_speed_scale = 1.0f;
};

} // namespace Service::VI