Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/freedreno/perfcntrs/freedreno_perfcntr.h
4565 views
1
/*
2
* Copyright (C) 2018 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_PERFCNTR_H_
28
#define FREEDRENO_PERFCNTR_H_
29
30
#include "util/macros.h"
31
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
36
/*
37
* Mapping very closely to the AMD_performance_monitor extension, adreno has
38
* groups of performance counters where each group has N counters, which can
39
* select from M different countables (things that can be counted), where
40
* generally M > N.
41
*/
42
43
/* Describes a single counter: */
44
struct fd_perfcntr_counter {
45
/* offset of the select register to choose what to count: */
46
unsigned select_reg;
47
/* offset of the lo/hi 32b to read current counter value: */
48
unsigned counter_reg_lo;
49
unsigned counter_reg_hi;
50
/* Optional, most counters don't have enable/clear registers: */
51
unsigned enable;
52
unsigned clear;
53
};
54
55
enum fd_perfcntr_type {
56
FD_PERFCNTR_TYPE_UINT64,
57
FD_PERFCNTR_TYPE_UINT,
58
FD_PERFCNTR_TYPE_FLOAT,
59
FD_PERFCNTR_TYPE_PERCENTAGE,
60
FD_PERFCNTR_TYPE_BYTES,
61
FD_PERFCNTR_TYPE_MICROSECONDS,
62
FD_PERFCNTR_TYPE_HZ,
63
FD_PERFCNTR_TYPE_DBM,
64
FD_PERFCNTR_TYPE_TEMPERATURE,
65
FD_PERFCNTR_TYPE_VOLTS,
66
FD_PERFCNTR_TYPE_AMPS,
67
FD_PERFCNTR_TYPE_WATTS,
68
};
69
70
/* Whether an average value per frame or a cumulative value should be
71
* displayed.
72
*/
73
enum fd_perfcntr_result_type {
74
FD_PERFCNTR_RESULT_TYPE_AVERAGE,
75
FD_PERFCNTR_RESULT_TYPE_CUMULATIVE,
76
};
77
78
/* Describes a single countable: */
79
struct fd_perfcntr_countable {
80
const char *name;
81
/* selector register enum value to select this countable: */
82
unsigned selector;
83
84
/* description of the countable: */
85
enum fd_perfcntr_type query_type;
86
enum fd_perfcntr_result_type result_type;
87
};
88
89
/* Describes an entire counter group: */
90
struct fd_perfcntr_group {
91
const char *name;
92
unsigned num_counters;
93
const struct fd_perfcntr_counter *counters;
94
unsigned num_countables;
95
const struct fd_perfcntr_countable *countables;
96
};
97
98
const struct fd_perfcntr_group *fd_perfcntrs(unsigned gpu_id, unsigned *count);
99
100
#define COUNTER(_sel, _lo, _hi) { \
101
.select_reg = REG(_sel), .counter_reg_lo = REG(_lo), \
102
.counter_reg_hi = REG(_hi), \
103
}
104
105
#define COUNTER2(_sel, _lo, _hi, _en, _clr) { \
106
.select_reg = REG(_sel), .counter_reg_lo = REG(_lo), \
107
.counter_reg_hi = REG(_hi), .enable = REG(_en), .clear = REG(_clr), \
108
}
109
110
#define COUNTABLE(_selector, _query_type, _result_type) { \
111
.name = #_selector, .selector = _selector, \
112
.query_type = FD_PERFCNTR_TYPE_##_query_type, \
113
.result_type = FD_PERFCNTR_RESULT_TYPE_##_result_type, \
114
}
115
116
#define GROUP(_name, _counters, _countables) { \
117
.name = _name, .num_counters = ARRAY_SIZE(_counters), \
118
.counters = _counters, .num_countables = ARRAY_SIZE(_countables), \
119
.countables = _countables, \
120
}
121
122
#ifdef __cplusplus
123
} /* end of extern "C" */
124
#endif
125
126
#endif /* FREEDRENO_PERFCNTR_H_ */
127
128