aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/video_core/host1x/sync_manager.h
blob: 7bb77fa27877a71c0cafa0d47162a38443cf5591 (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
// SPDX-FileCopyrightText: Ryujinx Team and Contributors
// SPDX-License-Identifier: MIT

#pragma once

#include <mutex>
#include <vector>
#include "common/common_types.h"

namespace Tegra {

namespace Host1x {

class Host1x;

struct SyncptIncr {
    u32 id;
    u32 class_id;
    u32 syncpt_id;
    bool complete;

    SyncptIncr(u32 id_, u32 class_id_, u32 syncpt_id_, bool done = false)
        : id(id_), class_id(class_id_), syncpt_id(syncpt_id_), complete(done) {}
};

class SyncptIncrManager {
public:
    explicit SyncptIncrManager(Host1x& host1x);
    ~SyncptIncrManager();

    /// Add syncpoint id and increment all
    void Increment(u32 id);

    /// Returns a handle to increment later
    u32 IncrementWhenDone(u32 class_id, u32 id);

    /// IncrememntAllDone, including handle
    void SignalDone(u32 handle);

    /// Increment all sequential pending increments that are already done.
    void IncrementAllDone();

private:
    std::vector<SyncptIncr> increments;
    std::mutex increment_lock;
    u32 current_id{};

    Host1x& host1x;
};

} // namespace Host1x

} // namespace Tegra