#include "util/hash_table.h"
#include "util/perf/u_perfetto.h"
+#include "util/perf/u_perfetto_renderpass.h"
#include "tu_tracepoints.h"
#include "tu_tracepoints_perfetto.h"
using IncrementalStateType = TuRenderpassIncrementalState;
};
-class TuRenderpassDataSource : public perfetto::DataSource<TuRenderpassDataSource, TuRenderpassTraits> {
-public:
- void OnSetup(const SetupArgs &) override
+class TuRenderpassDataSource : public MesaRenderpassDataSource<TuRenderpassDataSource,
+ TuRenderpassTraits> {
+ void OnStart(const StartArgs &args) override
{
- // Use this callback to apply any custom configuration to your data source
- // based on the TraceConfig in SetupArgs.
- }
-
- void OnStart(const StartArgs &) override
- {
- // This notification can be used to initialize the GPU driver, enable
- // counters, etc. StartArgs will contains the DataSourceDescriptor,
- // which can be extended.
- u_trace_perfetto_start();
- PERFETTO_LOG("Tracing started");
+ MesaRenderpassDataSource<TuRenderpassDataSource, TuRenderpassTraits>::OnStart(args);
/* Note: clock_id's below 128 are reserved.. for custom clock sources,
* using the hash of a namespaced string is the recommended approach.
gpu_max_timestamp = 0;
last_suspend_count = 0;
}
-
- void OnStop(const StopArgs &) override
- {
- PERFETTO_LOG("Tracing stopped");
-
- // Undo any initialization done in OnStart.
- u_trace_perfetto_stop();
- // TODO we should perhaps block until queued traces are flushed?
-
- Trace([](TuRenderpassDataSource::TraceContext ctx) {
- auto packet = ctx.NewTracePacket();
- packet->Finalize();
- ctx.Flush();
- });
- }
};
PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(TuRenderpassDataSource);
#include <perfetto.h>
#include "util/perf/u_perfetto.h"
+#include "util/perf/u_perfetto_renderpass.h"
#include "freedreno_tracepoints.h"
using IncrementalStateType = FdRenderpassIncrementalState;
};
-class FdRenderpassDataSource : public perfetto::DataSource<FdRenderpassDataSource, FdRenderpassTraits> {
+class FdRenderpassDataSource : public MesaRenderpassDataSource<FdRenderpassDataSource, FdRenderpassTraits> {
public:
- void OnSetup(const SetupArgs &) override
- {
- // Use this callback to apply any custom configuration to your data source
- // based on the TraceConfig in SetupArgs.
- }
- void OnStart(const StartArgs &) override
+ void OnStart(const StartArgs &args) override
{
- // This notification can be used to initialize the GPU driver, enable
- // counters, etc. StartArgs will contains the DataSourceDescriptor,
- // which can be extended.
- u_trace_perfetto_start();
- PERFETTO_LOG("Tracing started");
+ MesaRenderpassDataSource<FdRenderpassDataSource, FdRenderpassTraits>::OnStart(args);
/* Note: clock_id's below 128 are reserved.. for custom clock sources,
* using the hash of a namespaced string is the recommended approach.
gpu_clock_id =
_mesa_hash_string("org.freedesktop.mesa.freedreno") | 0x80000000;
}
-
- void OnStop(const StopArgs &) override
- {
- PERFETTO_LOG("Tracing stopped");
-
- // Undo any initialization done in OnStart.
- u_trace_perfetto_stop();
- // TODO we should perhaps block until queued traces are flushed?
-
- Trace([](FdRenderpassDataSource::TraceContext ctx) {
- auto packet = ctx.NewTracePacket();
- packet->Finalize();
- ctx.Flush();
- });
- }
};
PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(FdRenderpassDataSource);
#ifdef HAVE_PERFETTO
#include "util/perf/u_perfetto.h"
+#include "util/perf/u_perfetto_renderpass.h"
#include "intel_tracepoints_perfetto.h"
using IncrementalStateType = IntelRenderpassIncrementalState;
};
-class IntelRenderpassDataSource : public perfetto::DataSource<IntelRenderpassDataSource,
- IntelRenderpassTraits> {
-public:
- void OnSetup(const SetupArgs &) override
- {
- // Use this callback to apply any custom configuration to your data source
- // based on the TraceConfig in SetupArgs.
- }
-
- void OnStart(const StartArgs &) override
- {
- // This notification can be used to initialize the GPU driver, enable
- // counters, etc. StartArgs will contains the DataSourceDescriptor,
- // which can be extended.
- u_trace_perfetto_start();
- PERFETTO_LOG("Tracing started");
- }
-
- void OnStop(const StopArgs &) override
- {
- PERFETTO_LOG("Tracing stopped");
-
- // Undo any initialization done in OnStart.
- u_trace_perfetto_stop();
- // TODO we should perhaps block until queued traces are flushed?
-
- Trace([](IntelRenderpassDataSource::TraceContext ctx) {
- auto packet = ctx.NewTracePacket();
- packet->Finalize();
- ctx.Flush();
- });
- }
+class IntelRenderpassDataSource : public MesaRenderpassDataSource<IntelRenderpassDataSource,
+ IntelRenderpassTraits> {
};
PERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(IntelRenderpassDataSource);
--- /dev/null
+/*
+ * Copyright © 2023 Google LLC
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "perfetto.h"
+
+#include "util/perf/u_trace.h"
+
+using perfetto::DataSource;
+template <typename DataSourceType, typename DataSourceTraits>
+class MesaRenderpassDataSource
+ : public perfetto::DataSource<DataSourceType, DataSourceTraits> {
+ public:
+ void OnSetup(const perfetto::DataSourceBase::SetupArgs &) override
+ {
+ // Use this callback to apply any custom configuration to your data
+ // source based on the TraceConfig in SetupArgs.
+ }
+
+ void OnStart(const perfetto::DataSourceBase::StartArgs &) override
+ {
+ // This notification can be used to initialize the GPU driver, enable
+ // counters, etc. StartArgs will contains the DataSourceDescriptor,
+ // which can be extended.
+ u_trace_perfetto_start();
+ PERFETTO_LOG("Tracing started");
+ }
+
+ void OnStop(const perfetto::DataSourceBase::StopArgs &) override
+ {
+ PERFETTO_LOG("Tracing stopped");
+
+ // Undo any initialization done in OnStart.
+ u_trace_perfetto_stop();
+ // TODO we should perhaps block until queued traces are flushed?
+
+ static_cast<DataSourceType *>(this)->Trace([](auto ctx) {
+ auto packet = ctx.NewTracePacket();
+ packet->Finalize();
+ ctx.Flush();
+ });
+ }
+};
+
+/* Begin the C API section. */