17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2021 Google, Inc. 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 217ec681f3Smrg * SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef TU_PERFETTO_H_ 257ec681f3Smrg#define TU_PERFETTO_H_ 267ec681f3Smrg 277ec681f3Smrg#ifdef __cplusplus 287ec681f3Smrgextern "C" { 297ec681f3Smrg#endif 307ec681f3Smrg 317ec681f3Smrg#ifdef HAVE_PERFETTO 327ec681f3Smrg 337ec681f3Smrg/** 347ec681f3Smrg * Render-stage id's 357ec681f3Smrg */ 367ec681f3Smrgenum tu_stage_id { 377ec681f3Smrg SURFACE_STAGE_ID, /* Surface is a sort of meta-stage for render-target info */ 387ec681f3Smrg BINNING_STAGE_ID, 397ec681f3Smrg GMEM_STAGE_ID, 407ec681f3Smrg BYPASS_STAGE_ID, 417ec681f3Smrg BLIT_STAGE_ID, 427ec681f3Smrg COMPUTE_STAGE_ID, 437ec681f3Smrg CLEAR_SYSMEM_STAGE_ID, 447ec681f3Smrg CLEAR_GMEM_STAGE_ID, 457ec681f3Smrg GMEM_LOAD_STAGE_ID, 467ec681f3Smrg GMEM_STORE_STAGE_ID, 477ec681f3Smrg SYSMEM_RESOLVE_STAGE_ID, 487ec681f3Smrg // TODO add the rest 497ec681f3Smrg 507ec681f3Smrg NUM_STAGES 517ec681f3Smrg}; 527ec681f3Smrg 537ec681f3Smrgstatic const struct { 547ec681f3Smrg const char *name; 557ec681f3Smrg const char *desc; 567ec681f3Smrg} stages[] = { 577ec681f3Smrg [SURFACE_STAGE_ID] = {"Surface"}, 587ec681f3Smrg [BINNING_STAGE_ID] = {"Binning", "Perform Visibility pass and determine target bins"}, 597ec681f3Smrg [GMEM_STAGE_ID] = {"Render", "Rendering to GMEM"}, 607ec681f3Smrg [BYPASS_STAGE_ID] = {"Render", "Rendering to system memory"}, 617ec681f3Smrg [BLIT_STAGE_ID] = {"Blit", "Performing a Blit operation"}, 627ec681f3Smrg [COMPUTE_STAGE_ID] = {"Compute", "Compute job"}, 637ec681f3Smrg [CLEAR_SYSMEM_STAGE_ID] = {"Clear Sysmem", ""}, 647ec681f3Smrg [CLEAR_GMEM_STAGE_ID] = {"Clear GMEM", "Per-tile (GMEM) clear"}, 657ec681f3Smrg [GMEM_LOAD_STAGE_ID] = {"GMEM Load", "Per tile system memory to GMEM load"}, 667ec681f3Smrg [GMEM_STORE_STAGE_ID] = {"GMEM Store", "Per tile GMEM to system memory store"}, 677ec681f3Smrg [SYSMEM_RESOLVE_STAGE_ID] = {"SysMem Resolve", "System memory MSAA resolve"}, 687ec681f3Smrg // TODO add the rest 697ec681f3Smrg}; 707ec681f3Smrg 717ec681f3Smrg/** 727ec681f3Smrg * Queue-id's 737ec681f3Smrg */ 747ec681f3Smrgenum { 757ec681f3Smrg DEFAULT_HW_QUEUE_ID, 767ec681f3Smrg}; 777ec681f3Smrg 787ec681f3Smrgstatic const struct { 797ec681f3Smrg const char *name; 807ec681f3Smrg const char *desc; 817ec681f3Smrg} queues[] = { 827ec681f3Smrg [DEFAULT_HW_QUEUE_ID] = {"GPU Queue 0", "Default Adreno Hardware Queue"}, 837ec681f3Smrg}; 847ec681f3Smrg 857ec681f3Smrgstruct tu_perfetto_state { 867ec681f3Smrg uint64_t start_ts[NUM_STAGES]; 877ec681f3Smrg}; 887ec681f3Smrg 897ec681f3Smrgvoid tu_perfetto_init(void); 907ec681f3Smrg 917ec681f3Smrgstruct tu_device; 927ec681f3Smrgvoid tu_perfetto_submit(struct tu_device *dev, uint32_t submission_id); 937ec681f3Smrg 947ec681f3Smrg/* Helpers */ 957ec681f3Smrg 967ec681f3Smrgstruct tu_perfetto_state * 977ec681f3Smrgtu_device_get_perfetto_state(struct tu_device *dev); 987ec681f3Smrg 997ec681f3Smrgint 1007ec681f3Smrgtu_device_get_timestamp(struct tu_device *dev, 1017ec681f3Smrg uint64_t *ts); 1027ec681f3Smrg 1037ec681f3Smrguint64_t 1047ec681f3Smrgtu_device_ticks_to_ns(struct tu_device *dev, uint64_t ts); 1057ec681f3Smrg 1067ec681f3Smrgstruct tu_u_trace_flush_data; 1077ec681f3Smrguint32_t 1087ec681f3Smrgtu_u_trace_flush_data_get_submit_id(const struct tu_u_trace_flush_data *data); 1097ec681f3Smrg 1107ec681f3Smrg#endif 1117ec681f3Smrg 1127ec681f3Smrg#ifdef __cplusplus 1137ec681f3Smrg} 1147ec681f3Smrg#endif 1157ec681f3Smrg 1167ec681f3Smrg#endif /* TU_PERFETTO_H_ */ 117