summaryrefslogtreecommitdiffstats
path: root/src/video_core/buffer_cache/map_interval.h
blob: 652a35dcdd08b4d997e8337dc27fedda45587f7d (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
// Copyright 2019 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.

#pragma once

#include <boost/functional/hash.hpp>
#include "common/common_types.h"
#include "video_core/gpu.h"

namespace VideoCommon {

struct MapInterval {
    MapInterval(const CacheAddr start, const CacheAddr end) : start{start}, end{end} {}
    CacheAddr start;
    CacheAddr end;
    bool IsInside(const CacheAddr other_start, const CacheAddr other_end) {
        return (start <= other_start && other_end <= end);
    }

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

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

struct MapInfo {
    GPUVAddr gpu_addr;
    VAddr cpu_addr;
};

} // namespace VideoCommon

namespace std {

template <>
struct hash<VideoCommon::MapInterval> {
    std::size_t operator()(const VideoCommon::MapInterval& k) const noexcept {
        std::size_t a = std::hash<CacheAddr>()(k.start);
        boost::hash_combine(a, std::hash<CacheAddr>()(k.end));
        return a;
    }
};

} // namespace std