~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/gallium/drivers/freedreno/freedreno_perfetto.h

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
   // TODO add the rest
46
 
 
47
 
   NUM_STAGES
48
 
};
49
 
 
50
 
static const struct {
51
 
   const char *name;
52
 
   const char *desc;
53
 
} stages[] = {
54
 
   [SURFACE_STAGE_ID] = {"Surface"},
55
 
   [BINNING_STAGE_ID] = {"Binning", "Perform Visibility pass and determine target bins"},
56
 
   [GMEM_STAGE_ID]    = {"Render", "Rendering to GMEM"},
57
 
   [BYPASS_STAGE_ID]  = {"Render", "Rendering to system memory"},
58
 
   [BLIT_STAGE_ID]    = {"Blit", "Performing a Blit operation"},
59
 
   [COMPUTE_STAGE_ID] = {"Compute", "Compute job"},
60
 
   [CLEAR_RESTORE_STAGE_ID] = {"Clear/Restore", "Clear (sysmem) or per-tile clear or restore (GMEM)"},
61
 
   [RESOLVE_STAGE_ID] = {"Resolve", "Per tile resolve (GMEM to system memory"},
62
 
   // TODO add the rest
63
 
};
64
 
 
65
 
/**
66
 
 * Queue-id's
67
 
 */
68
 
enum {
69
 
   DEFAULT_HW_QUEUE_ID,
70
 
};
71
 
 
72
 
static const struct {
73
 
   const char *name;
74
 
   const char *desc;
75
 
} queues[] = {
76
 
   [DEFAULT_HW_QUEUE_ID] = {"GPU Queue 0", "Default Adreno Hardware Queue"},
77
 
};
78
 
 
79
 
/**
80
 
 * The u_trace tracepoints which are used to capture GPU timestamps and
81
 
 * trigger perfetto events tend to come in begin/end pairs (ie. start
82
 
 * and end of binning pass, etc), but perfetto wants one event for the
83
 
 * whole pass.  So we need to buffer up some state at the "begin" trae
84
 
 * callback, and then emit the perfetto event at the "end" event based
85
 
 * on previously recorded timestamp/data.  This struct is where we can
86
 
 * accumulate that state.
87
 
 */
88
 
struct fd_perfetto_state {
89
 
   uint64_t start_ts[NUM_STAGES];
90
 
 
91
 
   /*
92
 
    * Surface state for the renderpass:
93
 
    */
94
 
   uint32_t submit_id;
95
 
   enum pipe_format cbuf0_format : 16;
96
 
   enum pipe_format zs_format : 16;
97
 
   uint16_t width;
98
 
   uint16_t height;
99
 
   uint8_t mrts;
100
 
   uint8_t samples;
101
 
   uint16_t nbins;
102
 
   uint16_t binw;
103
 
   uint16_t binh;
104
 
   // TODO # of draws and possibly estimated cost might be useful addition..
105
 
};
106
 
 
107
 
void fd_perfetto_init(void);
108
 
 
109
 
struct fd_context;
110
 
void fd_perfetto_submit(struct fd_context *ctx);
111
 
 
112
 
#endif
113
 
 
114
 
#ifdef __cplusplus
115
 
}
116
 
#endif
117
 
 
118
 
#endif /* FREEDRENO_PERFETTO_H_ */