Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/panfrost/ds/pan_pps_perf.cc
4560 views
1
#include "pan_pps_perf.h"
2
3
#include <lib/pan_device.h>
4
#include <perf/pan_perf.h>
5
#include <util/ralloc.h>
6
#include <pps/pps.h>
7
8
namespace pps
9
{
10
PanfrostDevice::PanfrostDevice(int fd)
11
: ctx {ralloc_context(nullptr)}
12
, dev {reinterpret_cast<struct panfrost_device*>(new struct panfrost_device())}
13
{
14
assert(fd >= 0);
15
panfrost_open_device(ctx, fd, dev);
16
}
17
18
PanfrostDevice::~PanfrostDevice()
19
{
20
if (ctx) {
21
panfrost_close_device(dev);
22
}
23
if (dev) {
24
delete dev;
25
}
26
}
27
28
PanfrostDevice::PanfrostDevice(PanfrostDevice &&o)
29
: ctx {o.ctx}
30
, dev {o.dev}
31
{
32
o.ctx = nullptr;
33
o.dev = nullptr;
34
}
35
36
PanfrostDevice &PanfrostDevice::operator=(PanfrostDevice &&o)
37
{
38
std::swap(ctx, o.ctx);
39
std::swap(dev, o.dev);
40
return *this;
41
}
42
43
PanfrostPerf::PanfrostPerf(const PanfrostDevice& dev)
44
: perf {reinterpret_cast<struct panfrost_perf *>(rzalloc(nullptr, struct panfrost_perf))}
45
{
46
assert(perf);
47
assert(dev.dev);
48
panfrost_perf_init(perf, dev.dev);
49
}
50
51
PanfrostPerf::~PanfrostPerf()
52
{
53
if (perf) {
54
panfrost_perf_disable(perf);
55
ralloc_free(perf);
56
}
57
}
58
59
PanfrostPerf::PanfrostPerf(PanfrostPerf &&o)
60
: perf {o.perf}
61
{
62
o.perf = nullptr;
63
}
64
65
PanfrostPerf &PanfrostPerf::operator=(PanfrostPerf &&o)
66
{
67
std::swap(perf, o.perf);
68
return *this;
69
}
70
71
int PanfrostPerf::enable() const
72
{
73
assert(perf);
74
return panfrost_perf_enable(perf);
75
}
76
77
void PanfrostPerf::disable() const
78
{
79
assert(perf);
80
panfrost_perf_disable(perf);
81
}
82
83
int PanfrostPerf::dump() const
84
{
85
assert(perf);
86
return panfrost_perf_dump(perf);
87
}
88
89
} // namespace pps
90
91