1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2021 Google, Inc. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include <perfetto.h> 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#include "util/u_perfetto.h" 27bf215546Sopenharmony_ci 28bf215546Sopenharmony_ci#include "freedreno_tracepoints.h" 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_cistatic uint32_t gpu_clock_id; 31bf215546Sopenharmony_cistatic uint64_t next_clock_sync_ns; /* cpu time of next clk sync */ 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci/** 34bf215546Sopenharmony_ci * The timestamp at the point where we first emitted the clock_sync.. 35bf215546Sopenharmony_ci * this will be a *later* timestamp that the first GPU traces (since 36bf215546Sopenharmony_ci * we capture the first clock_sync from the CPU *after* the first GPU 37bf215546Sopenharmony_ci * tracepoints happen). To avoid confusing perfetto we need to drop 38bf215546Sopenharmony_ci * the GPU traces with timestamps before this. 39bf215546Sopenharmony_ci */ 40bf215546Sopenharmony_cistatic uint64_t sync_gpu_ts; 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_cistruct FdRenderpassIncrementalState { 43bf215546Sopenharmony_ci bool was_cleared = true; 44bf215546Sopenharmony_ci}; 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_cistruct FdRenderpassTraits : public perfetto::DefaultDataSourceTraits { 47bf215546Sopenharmony_ci using IncrementalStateType = FdRenderpassIncrementalState; 48bf215546Sopenharmony_ci}; 49bf215546Sopenharmony_ci 50bf215546Sopenharmony_ciclass FdRenderpassDataSource : public perfetto::DataSource<FdRenderpassDataSource, FdRenderpassTraits> { 51bf215546Sopenharmony_cipublic: 52bf215546Sopenharmony_ci void OnSetup(const SetupArgs &) override 53bf215546Sopenharmony_ci { 54bf215546Sopenharmony_ci // Use this callback to apply any custom configuration to your data source 55bf215546Sopenharmony_ci // based on the TraceConfig in SetupArgs. 56bf215546Sopenharmony_ci } 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_ci void OnStart(const StartArgs &) override 59bf215546Sopenharmony_ci { 60bf215546Sopenharmony_ci // This notification can be used to initialize the GPU driver, enable 61bf215546Sopenharmony_ci // counters, etc. StartArgs will contains the DataSourceDescriptor, 62bf215546Sopenharmony_ci // which can be extended. 63bf215546Sopenharmony_ci u_trace_perfetto_start(); 64bf215546Sopenharmony_ci PERFETTO_LOG("Tracing started"); 65bf215546Sopenharmony_ci 66bf215546Sopenharmony_ci /* Note: clock_id's below 128 are reserved.. for custom clock sources, 67bf215546Sopenharmony_ci * using the hash of a namespaced string is the recommended approach. 68bf215546Sopenharmony_ci * See: https://perfetto.dev/docs/concepts/clock-sync 69bf215546Sopenharmony_ci */ 70bf215546Sopenharmony_ci gpu_clock_id = 71bf215546Sopenharmony_ci _mesa_hash_string("org.freedesktop.mesa.freedreno") | 0x80000000; 72bf215546Sopenharmony_ci } 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci void OnStop(const StopArgs &) override 75bf215546Sopenharmony_ci { 76bf215546Sopenharmony_ci PERFETTO_LOG("Tracing stopped"); 77bf215546Sopenharmony_ci 78bf215546Sopenharmony_ci // Undo any initialization done in OnStart. 79bf215546Sopenharmony_ci u_trace_perfetto_stop(); 80bf215546Sopenharmony_ci // TODO we should perhaps block until queued traces are flushed? 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci Trace([](FdRenderpassDataSource::TraceContext ctx) { 83bf215546Sopenharmony_ci auto packet = ctx.NewTracePacket(); 84bf215546Sopenharmony_ci packet->Finalize(); 85bf215546Sopenharmony_ci ctx.Flush(); 86bf215546Sopenharmony_ci }); 87bf215546Sopenharmony_ci } 88bf215546Sopenharmony_ci}; 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ciPERFETTO_DECLARE_DATA_SOURCE_STATIC_MEMBERS(FdRenderpassDataSource); 91bf215546Sopenharmony_ciPERFETTO_DEFINE_DATA_SOURCE_STATIC_MEMBERS(FdRenderpassDataSource); 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_cistatic void 94bf215546Sopenharmony_cisend_descriptors(FdRenderpassDataSource::TraceContext &ctx, uint64_t ts_ns) 95bf215546Sopenharmony_ci{ 96bf215546Sopenharmony_ci PERFETTO_LOG("Sending renderstage descriptors"); 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci auto packet = ctx.NewTracePacket(); 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ci packet->set_timestamp(0); 101bf215546Sopenharmony_ci// packet->set_timestamp(ts_ns); 102bf215546Sopenharmony_ci// packet->set_timestamp_clock_id(gpu_clock_id); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_ci auto event = packet->set_gpu_render_stage_event(); 105bf215546Sopenharmony_ci event->set_gpu_id(0); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_ci auto spec = event->set_specifications(); 108bf215546Sopenharmony_ci 109bf215546Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(queues); i++) { 110bf215546Sopenharmony_ci auto desc = spec->add_hw_queue(); 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci desc->set_name(queues[i].name); 113bf215546Sopenharmony_ci desc->set_description(queues[i].desc); 114bf215546Sopenharmony_ci } 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ci for (unsigned i = 0; i < ARRAY_SIZE(stages); i++) { 117bf215546Sopenharmony_ci auto desc = spec->add_stage(); 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci desc->set_name(stages[i].name); 120bf215546Sopenharmony_ci if (stages[i].desc) 121bf215546Sopenharmony_ci desc->set_description(stages[i].desc); 122bf215546Sopenharmony_ci } 123bf215546Sopenharmony_ci} 124bf215546Sopenharmony_ci 125bf215546Sopenharmony_cistatic void 126bf215546Sopenharmony_cistage_start(struct pipe_context *pctx, uint64_t ts_ns, enum fd_stage_id stage) 127bf215546Sopenharmony_ci{ 128bf215546Sopenharmony_ci struct fd_context *ctx = fd_context(pctx); 129bf215546Sopenharmony_ci struct fd_perfetto_state *p = &ctx->perfetto; 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_ci p->start_ts[stage] = ts_ns; 132bf215546Sopenharmony_ci} 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_cistatic void 135bf215546Sopenharmony_cistage_end(struct pipe_context *pctx, uint64_t ts_ns, enum fd_stage_id stage) 136bf215546Sopenharmony_ci{ 137bf215546Sopenharmony_ci struct fd_context *ctx = fd_context(pctx); 138bf215546Sopenharmony_ci struct fd_perfetto_state *p = &ctx->perfetto; 139bf215546Sopenharmony_ci 140bf215546Sopenharmony_ci /* If we haven't managed to calibrate the alignment between GPU and CPU 141bf215546Sopenharmony_ci * timestamps yet, then skip this trace, otherwise perfetto won't know 142bf215546Sopenharmony_ci * what to do with it. 143bf215546Sopenharmony_ci */ 144bf215546Sopenharmony_ci if (!sync_gpu_ts) 145bf215546Sopenharmony_ci return; 146bf215546Sopenharmony_ci 147bf215546Sopenharmony_ci FdRenderpassDataSource::Trace([=](FdRenderpassDataSource::TraceContext tctx) { 148bf215546Sopenharmony_ci if (auto state = tctx.GetIncrementalState(); state->was_cleared) { 149bf215546Sopenharmony_ci send_descriptors(tctx, p->start_ts[stage]); 150bf215546Sopenharmony_ci state->was_cleared = false; 151bf215546Sopenharmony_ci } 152bf215546Sopenharmony_ci 153bf215546Sopenharmony_ci auto packet = tctx.NewTracePacket(); 154bf215546Sopenharmony_ci 155bf215546Sopenharmony_ci packet->set_timestamp(p->start_ts[stage]); 156bf215546Sopenharmony_ci packet->set_timestamp_clock_id(gpu_clock_id); 157bf215546Sopenharmony_ci 158bf215546Sopenharmony_ci auto event = packet->set_gpu_render_stage_event(); 159bf215546Sopenharmony_ci event->set_event_id(0); // ??? 160bf215546Sopenharmony_ci event->set_hw_queue_id(DEFAULT_HW_QUEUE_ID); 161bf215546Sopenharmony_ci event->set_duration(ts_ns - p->start_ts[stage]); 162bf215546Sopenharmony_ci event->set_stage_id(stage); 163bf215546Sopenharmony_ci event->set_context((uintptr_t)pctx); 164bf215546Sopenharmony_ci 165bf215546Sopenharmony_ci /* The "surface" meta-stage has extra info about render target: */ 166bf215546Sopenharmony_ci if (stage == SURFACE_STAGE_ID) { 167bf215546Sopenharmony_ci 168bf215546Sopenharmony_ci event->set_submission_id(p->submit_id); 169bf215546Sopenharmony_ci 170bf215546Sopenharmony_ci if (p->cbuf0_format) { 171bf215546Sopenharmony_ci auto data = event->add_extra_data(); 172bf215546Sopenharmony_ci 173bf215546Sopenharmony_ci data->set_name("color0 format"); 174bf215546Sopenharmony_ci data->set_value(util_format_short_name(p->cbuf0_format)); 175bf215546Sopenharmony_ci } 176bf215546Sopenharmony_ci 177bf215546Sopenharmony_ci if (p->zs_format) { 178bf215546Sopenharmony_ci auto data = event->add_extra_data(); 179bf215546Sopenharmony_ci 180bf215546Sopenharmony_ci data->set_name("zs format"); 181bf215546Sopenharmony_ci data->set_value(util_format_short_name(p->zs_format)); 182bf215546Sopenharmony_ci } 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci { 185bf215546Sopenharmony_ci auto data = event->add_extra_data(); 186bf215546Sopenharmony_ci 187bf215546Sopenharmony_ci data->set_name("width"); 188bf215546Sopenharmony_ci data->set_value(std::to_string(p->width)); 189bf215546Sopenharmony_ci } 190bf215546Sopenharmony_ci 191bf215546Sopenharmony_ci { 192bf215546Sopenharmony_ci auto data = event->add_extra_data(); 193bf215546Sopenharmony_ci 194bf215546Sopenharmony_ci data->set_name("height"); 195bf215546Sopenharmony_ci data->set_value(std::to_string(p->height)); 196bf215546Sopenharmony_ci } 197bf215546Sopenharmony_ci 198bf215546Sopenharmony_ci { 199bf215546Sopenharmony_ci auto data = event->add_extra_data(); 200bf215546Sopenharmony_ci 201bf215546Sopenharmony_ci data->set_name("MSAA"); 202bf215546Sopenharmony_ci data->set_value(std::to_string(p->samples)); 203bf215546Sopenharmony_ci } 204bf215546Sopenharmony_ci 205bf215546Sopenharmony_ci { 206bf215546Sopenharmony_ci auto data = event->add_extra_data(); 207bf215546Sopenharmony_ci 208bf215546Sopenharmony_ci data->set_name("MRTs"); 209bf215546Sopenharmony_ci data->set_value(std::to_string(p->mrts)); 210bf215546Sopenharmony_ci } 211bf215546Sopenharmony_ci 212bf215546Sopenharmony_ci // "renderMode" 213bf215546Sopenharmony_ci // "surfaceID" 214bf215546Sopenharmony_ci 215bf215546Sopenharmony_ci if (p->nbins) { 216bf215546Sopenharmony_ci auto data = event->add_extra_data(); 217bf215546Sopenharmony_ci 218bf215546Sopenharmony_ci data->set_name("numberOfBins"); 219bf215546Sopenharmony_ci data->set_value(std::to_string(p->nbins)); 220bf215546Sopenharmony_ci } 221bf215546Sopenharmony_ci 222bf215546Sopenharmony_ci if (p->binw) { 223bf215546Sopenharmony_ci auto data = event->add_extra_data(); 224bf215546Sopenharmony_ci 225bf215546Sopenharmony_ci data->set_name("binWidth"); 226bf215546Sopenharmony_ci data->set_value(std::to_string(p->binw)); 227bf215546Sopenharmony_ci } 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci if (p->binh) { 230bf215546Sopenharmony_ci auto data = event->add_extra_data(); 231bf215546Sopenharmony_ci 232bf215546Sopenharmony_ci data->set_name("binHeight"); 233bf215546Sopenharmony_ci data->set_value(std::to_string(p->binh)); 234bf215546Sopenharmony_ci } 235bf215546Sopenharmony_ci } 236bf215546Sopenharmony_ci }); 237bf215546Sopenharmony_ci} 238bf215546Sopenharmony_ci 239bf215546Sopenharmony_ci#ifdef __cplusplus 240bf215546Sopenharmony_ciextern "C" { 241bf215546Sopenharmony_ci#endif 242bf215546Sopenharmony_ci 243bf215546Sopenharmony_civoid 244bf215546Sopenharmony_cifd_perfetto_init(void) 245bf215546Sopenharmony_ci{ 246bf215546Sopenharmony_ci util_perfetto_init(); 247bf215546Sopenharmony_ci 248bf215546Sopenharmony_ci perfetto::DataSourceDescriptor dsd; 249bf215546Sopenharmony_ci dsd.set_name("gpu.renderstages.msm"); 250bf215546Sopenharmony_ci FdRenderpassDataSource::Register(dsd); 251bf215546Sopenharmony_ci} 252bf215546Sopenharmony_ci 253bf215546Sopenharmony_cistatic void 254bf215546Sopenharmony_cisync_timestamp(struct fd_context *ctx) 255bf215546Sopenharmony_ci{ 256bf215546Sopenharmony_ci uint64_t cpu_ts = perfetto::base::GetBootTimeNs().count(); 257bf215546Sopenharmony_ci uint64_t gpu_ts; 258bf215546Sopenharmony_ci 259bf215546Sopenharmony_ci if (cpu_ts < next_clock_sync_ns) 260bf215546Sopenharmony_ci return; 261bf215546Sopenharmony_ci 262bf215546Sopenharmony_ci if (fd_pipe_get_param(ctx->pipe, FD_TIMESTAMP, &gpu_ts)) { 263bf215546Sopenharmony_ci PERFETTO_ELOG("Could not sync CPU and GPU clocks"); 264bf215546Sopenharmony_ci return; 265bf215546Sopenharmony_ci } 266bf215546Sopenharmony_ci 267bf215546Sopenharmony_ci /* convert GPU ts into ns: */ 268bf215546Sopenharmony_ci gpu_ts = ctx->ts_to_ns(gpu_ts); 269bf215546Sopenharmony_ci 270bf215546Sopenharmony_ci FdRenderpassDataSource::Trace([=](FdRenderpassDataSource::TraceContext tctx) { 271bf215546Sopenharmony_ci auto packet = tctx.NewTracePacket(); 272bf215546Sopenharmony_ci 273bf215546Sopenharmony_ci packet->set_timestamp(cpu_ts); 274bf215546Sopenharmony_ci 275bf215546Sopenharmony_ci auto event = packet->set_clock_snapshot(); 276bf215546Sopenharmony_ci 277bf215546Sopenharmony_ci { 278bf215546Sopenharmony_ci auto clock = event->add_clocks(); 279bf215546Sopenharmony_ci 280bf215546Sopenharmony_ci clock->set_clock_id(perfetto::protos::pbzero::BUILTIN_CLOCK_BOOTTIME); 281bf215546Sopenharmony_ci clock->set_timestamp(cpu_ts); 282bf215546Sopenharmony_ci } 283bf215546Sopenharmony_ci 284bf215546Sopenharmony_ci { 285bf215546Sopenharmony_ci auto clock = event->add_clocks(); 286bf215546Sopenharmony_ci 287bf215546Sopenharmony_ci clock->set_clock_id(gpu_clock_id); 288bf215546Sopenharmony_ci clock->set_timestamp(gpu_ts); 289bf215546Sopenharmony_ci } 290bf215546Sopenharmony_ci 291bf215546Sopenharmony_ci sync_gpu_ts = gpu_ts; 292bf215546Sopenharmony_ci next_clock_sync_ns = cpu_ts + 30000000; 293bf215546Sopenharmony_ci }); 294bf215546Sopenharmony_ci} 295bf215546Sopenharmony_ci 296bf215546Sopenharmony_cistatic void 297bf215546Sopenharmony_ciemit_submit_id(struct fd_context *ctx) 298bf215546Sopenharmony_ci{ 299bf215546Sopenharmony_ci FdRenderpassDataSource::Trace([=](FdRenderpassDataSource::TraceContext tctx) { 300bf215546Sopenharmony_ci auto packet = tctx.NewTracePacket(); 301bf215546Sopenharmony_ci 302bf215546Sopenharmony_ci packet->set_timestamp(perfetto::base::GetBootTimeNs().count()); 303bf215546Sopenharmony_ci 304bf215546Sopenharmony_ci auto event = packet->set_vulkan_api_event(); 305bf215546Sopenharmony_ci auto submit = event->set_vk_queue_submit(); 306bf215546Sopenharmony_ci 307bf215546Sopenharmony_ci submit->set_submission_id(ctx->submit_count); 308bf215546Sopenharmony_ci }); 309bf215546Sopenharmony_ci} 310bf215546Sopenharmony_ci 311bf215546Sopenharmony_civoid 312bf215546Sopenharmony_cifd_perfetto_submit(struct fd_context *ctx) 313bf215546Sopenharmony_ci{ 314bf215546Sopenharmony_ci sync_timestamp(ctx); 315bf215546Sopenharmony_ci emit_submit_id(ctx); 316bf215546Sopenharmony_ci} 317bf215546Sopenharmony_ci 318bf215546Sopenharmony_ci/* 319bf215546Sopenharmony_ci * Trace callbacks, called from u_trace once the timestamps from GPU have been 320bf215546Sopenharmony_ci * collected. 321bf215546Sopenharmony_ci */ 322bf215546Sopenharmony_ci 323bf215546Sopenharmony_civoid 324bf215546Sopenharmony_cifd_start_render_pass(struct pipe_context *pctx, uint64_t ts_ns, 325bf215546Sopenharmony_ci const void *flush_data, 326bf215546Sopenharmony_ci const struct trace_start_render_pass *payload) 327bf215546Sopenharmony_ci{ 328bf215546Sopenharmony_ci stage_start(pctx, ts_ns, SURFACE_STAGE_ID); 329bf215546Sopenharmony_ci 330bf215546Sopenharmony_ci struct fd_perfetto_state *p = &fd_context(pctx)->perfetto; 331bf215546Sopenharmony_ci 332bf215546Sopenharmony_ci p->submit_id = payload->submit_id; 333bf215546Sopenharmony_ci p->cbuf0_format = payload->cbuf0_format; 334bf215546Sopenharmony_ci p->zs_format = payload->zs_format; 335bf215546Sopenharmony_ci p->width = payload->width; 336bf215546Sopenharmony_ci p->height = payload->height; 337bf215546Sopenharmony_ci p->mrts = payload->mrts; 338bf215546Sopenharmony_ci p->samples = payload->samples; 339bf215546Sopenharmony_ci p->nbins = payload->nbins; 340bf215546Sopenharmony_ci p->binw = payload->binw; 341bf215546Sopenharmony_ci p->binh = payload->binh; 342bf215546Sopenharmony_ci} 343bf215546Sopenharmony_ci 344bf215546Sopenharmony_civoid 345bf215546Sopenharmony_cifd_end_render_pass(struct pipe_context *pctx, uint64_t ts_ns, 346bf215546Sopenharmony_ci const void *flush_data, 347bf215546Sopenharmony_ci const struct trace_end_render_pass *payload) 348bf215546Sopenharmony_ci{ 349bf215546Sopenharmony_ci stage_end(pctx, ts_ns, SURFACE_STAGE_ID); 350bf215546Sopenharmony_ci} 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_civoid 353bf215546Sopenharmony_cifd_start_binning_ib(struct pipe_context *pctx, uint64_t ts_ns, 354bf215546Sopenharmony_ci const void *flush_data, 355bf215546Sopenharmony_ci const struct trace_start_binning_ib *payload) 356bf215546Sopenharmony_ci{ 357bf215546Sopenharmony_ci stage_start(pctx, ts_ns, BINNING_STAGE_ID); 358bf215546Sopenharmony_ci} 359bf215546Sopenharmony_ci 360bf215546Sopenharmony_civoid 361bf215546Sopenharmony_cifd_end_binning_ib(struct pipe_context *pctx, uint64_t ts_ns, 362bf215546Sopenharmony_ci const void *flush_data, 363bf215546Sopenharmony_ci const struct trace_end_binning_ib *payload) 364bf215546Sopenharmony_ci{ 365bf215546Sopenharmony_ci stage_end(pctx, ts_ns, BINNING_STAGE_ID); 366bf215546Sopenharmony_ci} 367bf215546Sopenharmony_ci 368bf215546Sopenharmony_civoid 369bf215546Sopenharmony_cifd_start_draw_ib(struct pipe_context *pctx, uint64_t ts_ns, 370bf215546Sopenharmony_ci const void *flush_data, 371bf215546Sopenharmony_ci const struct trace_start_draw_ib *payload) 372bf215546Sopenharmony_ci{ 373bf215546Sopenharmony_ci stage_start( 374bf215546Sopenharmony_ci pctx, ts_ns, 375bf215546Sopenharmony_ci fd_context(pctx)->perfetto.nbins ? GMEM_STAGE_ID : BYPASS_STAGE_ID); 376bf215546Sopenharmony_ci} 377bf215546Sopenharmony_ci 378bf215546Sopenharmony_civoid 379bf215546Sopenharmony_cifd_end_draw_ib(struct pipe_context *pctx, uint64_t ts_ns, 380bf215546Sopenharmony_ci const void *flush_data, 381bf215546Sopenharmony_ci const struct trace_end_draw_ib *payload) 382bf215546Sopenharmony_ci{ 383bf215546Sopenharmony_ci stage_end( 384bf215546Sopenharmony_ci pctx, ts_ns, 385bf215546Sopenharmony_ci fd_context(pctx)->perfetto.nbins ? GMEM_STAGE_ID : BYPASS_STAGE_ID); 386bf215546Sopenharmony_ci} 387bf215546Sopenharmony_ci 388bf215546Sopenharmony_civoid 389bf215546Sopenharmony_cifd_start_blit(struct pipe_context *pctx, uint64_t ts_ns, 390bf215546Sopenharmony_ci const void *flush_data, 391bf215546Sopenharmony_ci const struct trace_start_blit *payload) 392bf215546Sopenharmony_ci{ 393bf215546Sopenharmony_ci stage_start(pctx, ts_ns, BLIT_STAGE_ID); 394bf215546Sopenharmony_ci} 395bf215546Sopenharmony_ci 396bf215546Sopenharmony_civoid 397bf215546Sopenharmony_cifd_end_blit(struct pipe_context *pctx, uint64_t ts_ns, 398bf215546Sopenharmony_ci const void *flush_data, 399bf215546Sopenharmony_ci const struct trace_end_blit *payload) 400bf215546Sopenharmony_ci{ 401bf215546Sopenharmony_ci stage_end(pctx, ts_ns, BLIT_STAGE_ID); 402bf215546Sopenharmony_ci} 403bf215546Sopenharmony_ci 404bf215546Sopenharmony_civoid 405bf215546Sopenharmony_cifd_start_compute(struct pipe_context *pctx, uint64_t ts_ns, 406bf215546Sopenharmony_ci const void *flush_data, 407bf215546Sopenharmony_ci const struct trace_start_compute *payload) 408bf215546Sopenharmony_ci{ 409bf215546Sopenharmony_ci stage_start(pctx, ts_ns, COMPUTE_STAGE_ID); 410bf215546Sopenharmony_ci} 411bf215546Sopenharmony_ci 412bf215546Sopenharmony_civoid 413bf215546Sopenharmony_cifd_end_compute(struct pipe_context *pctx, uint64_t ts_ns, 414bf215546Sopenharmony_ci const void *flush_data, 415bf215546Sopenharmony_ci const struct trace_end_compute *payload) 416bf215546Sopenharmony_ci{ 417bf215546Sopenharmony_ci stage_end(pctx, ts_ns, COMPUTE_STAGE_ID); 418bf215546Sopenharmony_ci} 419bf215546Sopenharmony_ci 420bf215546Sopenharmony_civoid 421bf215546Sopenharmony_cifd_start_clear_restore(struct pipe_context *pctx, uint64_t ts_ns, 422bf215546Sopenharmony_ci const void *flush_data, 423bf215546Sopenharmony_ci const struct trace_start_clear_restore *payload) 424bf215546Sopenharmony_ci{ 425bf215546Sopenharmony_ci stage_start(pctx, ts_ns, CLEAR_RESTORE_STAGE_ID); 426bf215546Sopenharmony_ci} 427bf215546Sopenharmony_ci 428bf215546Sopenharmony_civoid 429bf215546Sopenharmony_cifd_end_clear_restore(struct pipe_context *pctx, uint64_t ts_ns, 430bf215546Sopenharmony_ci const void *flush_data, 431bf215546Sopenharmony_ci const struct trace_end_clear_restore *payload) 432bf215546Sopenharmony_ci{ 433bf215546Sopenharmony_ci stage_end(pctx, ts_ns, CLEAR_RESTORE_STAGE_ID); 434bf215546Sopenharmony_ci} 435bf215546Sopenharmony_ci 436bf215546Sopenharmony_civoid 437bf215546Sopenharmony_cifd_start_resolve(struct pipe_context *pctx, uint64_t ts_ns, 438bf215546Sopenharmony_ci const void *flush_data, 439bf215546Sopenharmony_ci const struct trace_start_resolve *payload) 440bf215546Sopenharmony_ci{ 441bf215546Sopenharmony_ci stage_start(pctx, ts_ns, RESOLVE_STAGE_ID); 442bf215546Sopenharmony_ci} 443bf215546Sopenharmony_ci 444bf215546Sopenharmony_civoid 445bf215546Sopenharmony_cifd_end_resolve(struct pipe_context *pctx, uint64_t ts_ns, 446bf215546Sopenharmony_ci const void *flush_data, 447bf215546Sopenharmony_ci const struct trace_end_resolve *payload) 448bf215546Sopenharmony_ci{ 449bf215546Sopenharmony_ci stage_end(pctx, ts_ns, RESOLVE_STAGE_ID); 450bf215546Sopenharmony_ci} 451bf215546Sopenharmony_ci 452bf215546Sopenharmony_civoid 453bf215546Sopenharmony_cifd_start_state_restore(struct pipe_context *pctx, uint64_t ts_ns, 454bf215546Sopenharmony_ci const void *flush_data, 455bf215546Sopenharmony_ci const struct trace_start_state_restore *payload) 456bf215546Sopenharmony_ci{ 457bf215546Sopenharmony_ci stage_start(pctx, ts_ns, STATE_RESTORE_STAGE_ID); 458bf215546Sopenharmony_ci} 459bf215546Sopenharmony_ci 460bf215546Sopenharmony_civoid 461bf215546Sopenharmony_cifd_end_state_restore(struct pipe_context *pctx, uint64_t ts_ns, 462bf215546Sopenharmony_ci const void *flush_data, 463bf215546Sopenharmony_ci const struct trace_end_state_restore *payload) 464bf215546Sopenharmony_ci{ 465bf215546Sopenharmony_ci stage_end(pctx, ts_ns, STATE_RESTORE_STAGE_ID); 466bf215546Sopenharmony_ci} 467bf215546Sopenharmony_ci 468bf215546Sopenharmony_civoid 469bf215546Sopenharmony_cifd_start_vsc_overflow_test(struct pipe_context *pctx, uint64_t ts_ns, 470bf215546Sopenharmony_ci const void *flush_data, 471bf215546Sopenharmony_ci const struct trace_start_vsc_overflow_test *payload) 472bf215546Sopenharmony_ci{ 473bf215546Sopenharmony_ci stage_start(pctx, ts_ns, VSC_OVERFLOW_STAGE_ID); 474bf215546Sopenharmony_ci} 475bf215546Sopenharmony_ci 476bf215546Sopenharmony_civoid 477bf215546Sopenharmony_cifd_end_vsc_overflow_test(struct pipe_context *pctx, uint64_t ts_ns, 478bf215546Sopenharmony_ci const void *flush_data, 479bf215546Sopenharmony_ci const struct trace_end_vsc_overflow_test *payload) 480bf215546Sopenharmony_ci{ 481bf215546Sopenharmony_ci stage_end(pctx, ts_ns, VSC_OVERFLOW_STAGE_ID); 482bf215546Sopenharmony_ci} 483bf215546Sopenharmony_ci 484bf215546Sopenharmony_civoid 485bf215546Sopenharmony_cifd_start_prologue(struct pipe_context *pctx, uint64_t ts_ns, 486bf215546Sopenharmony_ci const void *flush_data, 487bf215546Sopenharmony_ci const struct trace_start_prologue *payload) 488bf215546Sopenharmony_ci{ 489bf215546Sopenharmony_ci stage_start(pctx, ts_ns, PROLOGUE_STAGE_ID); 490bf215546Sopenharmony_ci} 491bf215546Sopenharmony_ci 492bf215546Sopenharmony_civoid 493bf215546Sopenharmony_cifd_end_prologue(struct pipe_context *pctx, uint64_t ts_ns, 494bf215546Sopenharmony_ci const void *flush_data, 495bf215546Sopenharmony_ci const struct trace_end_prologue *payload) 496bf215546Sopenharmony_ci{ 497bf215546Sopenharmony_ci stage_end(pctx, ts_ns, PROLOGUE_STAGE_ID); 498bf215546Sopenharmony_ci} 499bf215546Sopenharmony_ci 500bf215546Sopenharmony_ci#ifdef __cplusplus 501bf215546Sopenharmony_ci} 502bf215546Sopenharmony_ci#endif 503