summaryrefslogtreecommitdiffstats
path: root/src/video_core/buffer_cache/map_interval.h
blob: 29d8b26f3d00c6e4110c2021fe13b9fc3c164551 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include "common/common_types.h"
#include "video_core/gpu.h"

namespace VideoCommon {

class MapIntervalBase {
public:
    MapIntervalBase(const VAddr start, const VAddr end, const GPUVAddr gpu_addr)
        : start{start}, end{end}, gpu_addr{gpu_addr} {}

    void SetCpuAddress(VAddr new_cpu_addr) {
        cpu_addr = new_cpu_addr;
    }

    VAddr GetCpuAddress() const {
        return cpu_addr;
    }

    GPUVAddr GetGpuAddress() const {
        return gpu_addr;
    }

    bool IsInside(const VAddr other_start, const VAddr other_end) const {
        return (start <= other_start && other_end <= end);
    }

    bool operator==(const MapIntervalBase& rhs) const {
        return std::tie(start, end) == std::tie(rhs.start, rhs.end);
    }

    bool operator!=(const MapIntervalBase& rhs) const {
        return !operator==(rhs);
    }

    void MarkAsRegistered(const bool registered) {
        is_registered = registered;
    }

    bool IsRegistered() const {
        return is_registered;
    }

    void SetMemoryMarked(bool is_memory_marked_) {
        is_memory_marked = is_memory_marked_;
    }

    bool IsMemoryMarked() const {
        return is_memory_marked;
    }

    void SetSyncPending(bool is_sync_pending_) {
        is_sync_pending = is_sync_pending_;
    }

    bool IsSyncPending() const {
        return is_sync_pending;
    }

    VAddr GetStart() const {
        return start;
    }

    VAddr GetEnd() const {
        return end;
    }

    void MarkAsModified(const bool is_modified_, const u64 tick) {
        is_modified = is_modified_;
        ticks = tick;
    }

    bool IsModified() const {
        return is_modified;
    }

    u64 GetModificationTick() const {
        return ticks;
    }

    void MarkAsWritten(const bool is_written_) {
        is_written = is_written_;
    }

    bool IsWritten() const {
        return is_written;
    }

private:
    VAddr start;
    VAddr end;
    GPUVAddr gpu_addr;
    VAddr cpu_addr{};
    bool is_written{};
    bool is_modified{};
    bool is_registered{};
    bool is_memory_marked{};
    bool is_sync_pending{};
    u64 ticks{};
};

} // namespace VideoCommon