mesa/src/tool/pps/pps.h
Antonio Caggiano 1cc72b2aef pps: Gfx-pps v0.3.0
Add the gfx-pps backbone in `src/pps`.

v2: Simplify supported drivers creation.
v3: No default getter is provided for counters.
v4: Open DRM device in read/write mode.
v5: Wait for datasource to be started.
v6: Set FIFO scheduler while sampling counters.

Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
Acked-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: John Bates <jbates@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9652>
2021-05-07 13:41:38 +00:00

38 lines
917 B
C++

/*
* Copyright © 2020 Collabora, Ltd.
* Author: Antonio Caggiano <antonio.caggiano@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <perfetto.h>
#define PPS_LOG PERFETTO_LOG
#define PPS_LOG_IMPORTANT PERFETTO_ILOG
#define PPS_LOG_ERROR PERFETTO_ELOG
#define PPS_LOG_FATAL PERFETTO_FATAL
namespace pps
{
enum class State {
Stop, // initial state, or stopped by the tracing service
Start, // running, sampling data
};
/// @brief Checks whether a return value is valid
/// @param res Result from a syscall
/// @param msg Message to prepend to strerror
/// @return True if ok, false otherwise
bool check(int res, const char *msg);
/// @param num Numerator
/// @param den Denominator
/// @return A ratio between two floating point numbers, or 0 if the denominator is 0
constexpr double ratio(double num, double den)
{
return den > 0.0 ? num / den : 0.0;
}
} // namespace pps