Path: blob/21.2-virgl/src/panfrost/ds/pan_pps_perf.cc
4560 views
#include "pan_pps_perf.h"12#include <lib/pan_device.h>3#include <perf/pan_perf.h>4#include <util/ralloc.h>5#include <pps/pps.h>67namespace pps8{9PanfrostDevice::PanfrostDevice(int fd)10: ctx {ralloc_context(nullptr)}11, dev {reinterpret_cast<struct panfrost_device*>(new struct panfrost_device())}12{13assert(fd >= 0);14panfrost_open_device(ctx, fd, dev);15}1617PanfrostDevice::~PanfrostDevice()18{19if (ctx) {20panfrost_close_device(dev);21}22if (dev) {23delete dev;24}25}2627PanfrostDevice::PanfrostDevice(PanfrostDevice &&o)28: ctx {o.ctx}29, dev {o.dev}30{31o.ctx = nullptr;32o.dev = nullptr;33}3435PanfrostDevice &PanfrostDevice::operator=(PanfrostDevice &&o)36{37std::swap(ctx, o.ctx);38std::swap(dev, o.dev);39return *this;40}4142PanfrostPerf::PanfrostPerf(const PanfrostDevice& dev)43: perf {reinterpret_cast<struct panfrost_perf *>(rzalloc(nullptr, struct panfrost_perf))}44{45assert(perf);46assert(dev.dev);47panfrost_perf_init(perf, dev.dev);48}4950PanfrostPerf::~PanfrostPerf()51{52if (perf) {53panfrost_perf_disable(perf);54ralloc_free(perf);55}56}5758PanfrostPerf::PanfrostPerf(PanfrostPerf &&o)59: perf {o.perf}60{61o.perf = nullptr;62}6364PanfrostPerf &PanfrostPerf::operator=(PanfrostPerf &&o)65{66std::swap(perf, o.perf);67return *this;68}6970int PanfrostPerf::enable() const71{72assert(perf);73return panfrost_perf_enable(perf);74}7576void PanfrostPerf::disable() const77{78assert(perf);79panfrost_perf_disable(perf);80}8182int PanfrostPerf::dump() const83{84assert(perf);85return panfrost_perf_dump(perf);86}8788} // namespace pps899091