Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_query.h
4570 views
1
/*
2
* Copyright (C) 2013 Rob Clark <[email protected]>
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
* Authors:
24
* Rob Clark <[email protected]>
25
*/
26
27
#ifndef FREEDRENO_QUERY_H_
28
#define FREEDRENO_QUERY_H_
29
30
#include "pipe/p_context.h"
31
32
#include "util/u_threaded_context.h"
33
34
#include "freedreno_util.h"
35
36
struct fd_context;
37
struct fd_query;
38
39
struct fd_query_funcs {
40
void (*destroy_query)(struct fd_context *ctx, struct fd_query *q) dt;
41
void (*begin_query)(struct fd_context *ctx, struct fd_query *q) dt;
42
void (*end_query)(struct fd_context *ctx, struct fd_query *q) dt;
43
bool (*get_query_result)(struct fd_context *ctx, struct fd_query *q,
44
bool wait, union pipe_query_result *result);
45
};
46
47
struct fd_query {
48
struct threaded_query base;
49
50
const struct fd_query_funcs *funcs;
51
int type;
52
unsigned index;
53
};
54
55
static inline struct fd_query *
56
fd_query(struct pipe_query *pq)
57
{
58
return (struct fd_query *)pq;
59
}
60
61
#define FD_QUERY_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0)
62
#define FD_QUERY_BATCH_TOTAL \
63
(PIPE_QUERY_DRIVER_SPECIFIC + 1) /* total # of batches (submits) */
64
#define FD_QUERY_BATCH_SYSMEM \
65
(PIPE_QUERY_DRIVER_SPECIFIC + \
66
2) /* batches using system memory (GMEM bypass) */
67
#define FD_QUERY_BATCH_GMEM \
68
(PIPE_QUERY_DRIVER_SPECIFIC + 3) /* batches using GMEM */
69
#define FD_QUERY_BATCH_NONDRAW \
70
(PIPE_QUERY_DRIVER_SPECIFIC + 4) /* compute/blit batches */
71
#define FD_QUERY_BATCH_RESTORE \
72
(PIPE_QUERY_DRIVER_SPECIFIC + 5) /* batches requiring GMEM restore */
73
#define FD_QUERY_STAGING_UPLOADS \
74
(PIPE_QUERY_DRIVER_SPECIFIC + \
75
6) /* texture/buffer uploads using staging blit */
76
#define FD_QUERY_SHADOW_UPLOADS \
77
(PIPE_QUERY_DRIVER_SPECIFIC + \
78
7) /* texture/buffer uploads that shadowed rsc */
79
#define FD_QUERY_VS_REGS \
80
(PIPE_QUERY_DRIVER_SPECIFIC + \
81
8) /* avg # of VS registers (scaled up by 100x) */
82
#define FD_QUERY_FS_REGS \
83
(PIPE_QUERY_DRIVER_SPECIFIC + \
84
9) /* avg # of VS registers (scaled up by 100x) */
85
/* insert any new non-perfcntr queries here, the first perfcntr index
86
* needs to come last!
87
*/
88
#define FD_QUERY_FIRST_PERFCNTR (PIPE_QUERY_DRIVER_SPECIFIC + 10)
89
90
void fd_query_screen_init(struct pipe_screen *pscreen);
91
void fd_query_context_init(struct pipe_context *pctx);
92
93
static inline bool
94
skip_begin_query(int type)
95
{
96
switch (type) {
97
case PIPE_QUERY_TIMESTAMP:
98
case PIPE_QUERY_GPU_FINISHED:
99
return true;
100
default:
101
return false;
102
}
103
}
104
105
/* maps query_type to sample provider idx: */
106
static inline int
107
pidx(unsigned query_type)
108
{
109
switch (query_type) {
110
case PIPE_QUERY_OCCLUSION_COUNTER:
111
return 0;
112
case PIPE_QUERY_OCCLUSION_PREDICATE:
113
return 1;
114
case PIPE_QUERY_OCCLUSION_PREDICATE_CONSERVATIVE:
115
return 2;
116
/* TODO currently queries only emitted in main pass (not in binning pass)..
117
* which is fine for occlusion query, but pretty much not anything else.
118
*/
119
case PIPE_QUERY_TIME_ELAPSED:
120
return 3;
121
case PIPE_QUERY_TIMESTAMP:
122
return 4;
123
124
case PIPE_QUERY_PRIMITIVES_GENERATED:
125
return 5;
126
case PIPE_QUERY_PRIMITIVES_EMITTED:
127
return 6;
128
129
default:
130
return -1;
131
}
132
}
133
134
#endif /* FREEDRENO_QUERY_H_ */
135
136