summaryrefslogtreecommitdiff
path: root/src/video_core/buffer_cache/map_interval.h
blob: a01eddf4949c4864154a8aef5152a61916655074 (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
// 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 CacheAddr start, const CacheAddr 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 CacheAddr other_start, const CacheAddr 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;
    }

    CacheAddr GetStart() const {
        return start;
    }

    CacheAddr GetEnd() const {
        return end;
    }

private:
    CacheAddr start;
    CacheAddr end;
    GPUVAddr gpu_addr;
    VAddr cpu_addr{};
    bool is_write{};
    bool is_modified{};
    bool is_registered{};
    u64 ticks{};
};

} // namespace VideoCommon