• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2021 Google, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #ifndef FREEDRENO_PERFETTO_H_
25 #define FREEDRENO_PERFETTO_H_
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #ifdef HAVE_PERFETTO
32 
33 /**
34  * Render-stage id's
35  */
36 enum fd_stage_id {
37    SURFACE_STAGE_ID, /* Surface is a sort of meta-stage for render-target info */
38    BINNING_STAGE_ID,
39    GMEM_STAGE_ID,
40    BYPASS_STAGE_ID,
41    BLIT_STAGE_ID,
42    COMPUTE_STAGE_ID,
43    CLEAR_RESTORE_STAGE_ID,
44    RESOLVE_STAGE_ID,
45    STATE_RESTORE_STAGE_ID,
46    VSC_OVERFLOW_STAGE_ID,
47    PROLOGUE_STAGE_ID,
48 
49    NUM_STAGES
50 };
51 
52 static const struct {
53    const char *name;
54    const char *desc;
55 } stages[] = {
56    [SURFACE_STAGE_ID] = {"Surface"},
57    [BINNING_STAGE_ID] = {"Binning", "Perform Visibility pass and determine target bins"},
58    [GMEM_STAGE_ID]    = {"Render", "Rendering to GMEM"},
59    [BYPASS_STAGE_ID]  = {"Render", "Rendering to system memory"},
60    [BLIT_STAGE_ID]    = {"Blit", "Performing a Blit operation"},
61    [COMPUTE_STAGE_ID] = {"Compute", "Compute job"},
62    [CLEAR_RESTORE_STAGE_ID] = {"Clear/Restore", "Clear (sysmem) or per-tile clear or restore (GMEM)"},
63    [RESOLVE_STAGE_ID] = {"Resolve", "Per tile resolve (GMEM to system memory"},
64    [STATE_RESTORE_STAGE_ID] = {"State Restore", "Setup at the beginning of new cmdstream buffer"},
65    [VSC_OVERFLOW_STAGE_ID] = {"VSC Overflow Test", ""},
66    [PROLOGUE_STAGE_ID] = {"Prologue", "Preemble cmdstream (executed once before first tile)"},
67 };
68 
69 /**
70  * Queue-id's
71  */
72 enum {
73    DEFAULT_HW_QUEUE_ID,
74 };
75 
76 static const struct {
77    const char *name;
78    const char *desc;
79 } queues[] = {
80    [DEFAULT_HW_QUEUE_ID] = {"GPU Queue 0", "Default Adreno Hardware Queue"},
81 };
82 
83 /**
84  * The u_trace tracepoints which are used to capture GPU timestamps and
85  * trigger perfetto events tend to come in begin/end pairs (ie. start
86  * and end of binning pass, etc), but perfetto wants one event for the
87  * whole pass.  So we need to buffer up some state at the "begin" trae
88  * callback, and then emit the perfetto event at the "end" event based
89  * on previously recorded timestamp/data.  This struct is where we can
90  * accumulate that state.
91  */
92 struct fd_perfetto_state {
93    uint64_t start_ts[NUM_STAGES];
94 
95    /*
96     * Surface state for the renderpass:
97     */
98    uint32_t submit_id;
99    enum pipe_format cbuf0_format : 16;
100    enum pipe_format zs_format : 16;
101    uint16_t width;
102    uint16_t height;
103    uint8_t mrts;
104    uint8_t samples;
105    uint16_t nbins;
106    uint16_t binw;
107    uint16_t binh;
108    // TODO # of draws and possibly estimated cost might be useful addition..
109 };
110 
111 void fd_perfetto_init(void);
112 
113 struct fd_context;
114 void fd_perfetto_submit(struct fd_context *ctx);
115 
116 #endif
117 
118 #ifdef __cplusplus
119 }
120 #endif
121 
122 #endif /* FREEDRENO_PERFETTO_H_ */
123