Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/freedreno/freedreno_screen.h
4570 views
1
/*
2
* Copyright (C) 2012 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_SCREEN_H_
28
#define FREEDRENO_SCREEN_H_
29
30
#include "common/freedreno_dev_info.h"
31
#include "drm/freedreno_drmif.h"
32
#include "drm/freedreno_ringbuffer.h"
33
#include "perfcntrs/freedreno_perfcntr.h"
34
35
#include "pipe/p_screen.h"
36
#include "renderonly/renderonly.h"
37
#include "util/debug.h"
38
#include "util/simple_mtx.h"
39
#include "util/slab.h"
40
#include "util/u_idalloc.h"
41
#include "util/u_memory.h"
42
#include "util/u_queue.h"
43
44
#include "freedreno_batch_cache.h"
45
#include "freedreno_gmem.h"
46
#include "freedreno_util.h"
47
48
struct fd_bo;
49
50
/* Potential reasons for needing to skip bypass path and use GMEM, the
51
* generation backend can override this with screen->gmem_reason_mask
52
*/
53
enum fd_gmem_reason {
54
FD_GMEM_CLEARS_DEPTH_STENCIL = BIT(0),
55
FD_GMEM_DEPTH_ENABLED = BIT(1),
56
FD_GMEM_STENCIL_ENABLED = BIT(2),
57
FD_GMEM_BLEND_ENABLED = BIT(3),
58
FD_GMEM_LOGICOP_ENABLED = BIT(4),
59
FD_GMEM_FB_READ = BIT(5),
60
};
61
62
struct fd_screen {
63
struct pipe_screen base;
64
65
struct list_head context_list;
66
67
simple_mtx_t lock;
68
69
/* it would be tempting to use pipe_reference here, but that
70
* really doesn't work well if it isn't the first member of
71
* the struct, so not quite so awesome to be adding refcnting
72
* further down the inheritance hierarchy:
73
*/
74
int refcnt;
75
76
/* place for winsys to stash it's own stuff: */
77
void *winsys_priv;
78
79
struct slab_parent_pool transfer_pool;
80
81
uint64_t gmem_base;
82
uint32_t gmemsize_bytes;
83
uint32_t device_id;
84
uint32_t gpu_id; /* 220, 305, etc */
85
uint32_t chip_id; /* coreid:8 majorrev:8 minorrev:8 patch:8 */
86
uint32_t max_freq;
87
uint32_t ram_size;
88
uint32_t max_rts; /* max # of render targets */
89
uint32_t priority_mask;
90
bool has_timestamp;
91
bool has_robustness;
92
bool has_syncobj;
93
94
const struct fd_dev_info *info;
95
uint32_t ccu_offset_gmem;
96
uint32_t ccu_offset_bypass;
97
98
/* Bitmask of gmem_reasons that do not force GMEM path over bypass
99
* for current generation.
100
*/
101
enum fd_gmem_reason gmem_reason_mask;
102
103
unsigned num_perfcntr_groups;
104
const struct fd_perfcntr_group *perfcntr_groups;
105
106
/* generated at startup from the perfcntr groups: */
107
unsigned num_perfcntr_queries;
108
struct pipe_driver_query_info *perfcntr_queries;
109
110
void *compiler; /* currently unused for a2xx */
111
struct util_queue compile_queue; /* currently unused for a2xx */
112
113
struct fd_device *dev;
114
115
/* NOTE: we still need a pipe associated with the screen in a few
116
* places, like screen->get_timestamp(). For anything context
117
* related, use ctx->pipe instead.
118
*/
119
struct fd_pipe *pipe;
120
121
uint32_t (*setup_slices)(struct fd_resource *rsc);
122
unsigned (*tile_mode)(const struct pipe_resource *prsc);
123
int (*layout_resource_for_modifier)(struct fd_resource *rsc,
124
uint64_t modifier);
125
126
/* indirect-branch emit: */
127
void (*emit_ib)(struct fd_ringbuffer *ring, struct fd_ringbuffer *target);
128
129
/* simple gpu "memcpy": */
130
void (*mem_to_mem)(struct fd_ringbuffer *ring, struct pipe_resource *dst,
131
unsigned dst_off, struct pipe_resource *src,
132
unsigned src_off, unsigned sizedwords);
133
134
int64_t cpu_gpu_time_delta;
135
136
struct fd_batch_cache batch_cache;
137
struct fd_gmem_cache gmem_cache;
138
139
bool reorder;
140
141
uint16_t rsc_seqno;
142
uint16_t ctx_seqno;
143
struct util_idalloc_mt buffer_ids;
144
145
unsigned num_supported_modifiers;
146
const uint64_t *supported_modifiers;
147
148
struct renderonly *ro;
149
};
150
151
static inline struct fd_screen *
152
fd_screen(struct pipe_screen *pscreen)
153
{
154
return (struct fd_screen *)pscreen;
155
}
156
157
static inline void
158
fd_screen_lock(struct fd_screen *screen)
159
{
160
simple_mtx_lock(&screen->lock);
161
}
162
163
static inline void
164
fd_screen_unlock(struct fd_screen *screen)
165
{
166
simple_mtx_unlock(&screen->lock);
167
}
168
169
static inline void
170
fd_screen_assert_locked(struct fd_screen *screen)
171
{
172
simple_mtx_assert_locked(&screen->lock);
173
}
174
175
bool fd_screen_bo_get_handle(struct pipe_screen *pscreen, struct fd_bo *bo,
176
struct renderonly_scanout *scanout,
177
unsigned stride, struct winsys_handle *whandle);
178
struct fd_bo *fd_screen_bo_from_handle(struct pipe_screen *pscreen,
179
struct winsys_handle *whandle);
180
181
struct pipe_screen *fd_screen_create(struct fd_device *dev,
182
struct renderonly *ro);
183
184
static inline boolean
185
is_a20x(struct fd_screen *screen)
186
{
187
return (screen->gpu_id >= 200) && (screen->gpu_id < 210);
188
}
189
190
static inline boolean
191
is_a2xx(struct fd_screen *screen)
192
{
193
return (screen->gpu_id >= 200) && (screen->gpu_id < 300);
194
}
195
196
/* is a3xx patch revision 0? */
197
/* TODO a306.0 probably doesn't need this.. be more clever?? */
198
static inline boolean
199
is_a3xx_p0(struct fd_screen *screen)
200
{
201
return (screen->chip_id & 0xff0000ff) == 0x03000000;
202
}
203
204
static inline boolean
205
is_a3xx(struct fd_screen *screen)
206
{
207
return (screen->gpu_id >= 300) && (screen->gpu_id < 400);
208
}
209
210
static inline boolean
211
is_a4xx(struct fd_screen *screen)
212
{
213
return (screen->gpu_id >= 400) && (screen->gpu_id < 500);
214
}
215
216
static inline boolean
217
is_a5xx(struct fd_screen *screen)
218
{
219
return (screen->gpu_id >= 500) && (screen->gpu_id < 600);
220
}
221
222
static inline boolean
223
is_a6xx(struct fd_screen *screen)
224
{
225
return (screen->gpu_id >= 600) && (screen->gpu_id < 700);
226
}
227
228
/* is it using the ir3 compiler (shader isa introduced with a3xx)? */
229
static inline boolean
230
is_ir3(struct fd_screen *screen)
231
{
232
return is_a3xx(screen) || is_a4xx(screen) || is_a5xx(screen) ||
233
is_a6xx(screen);
234
}
235
236
static inline bool
237
has_compute(struct fd_screen *screen)
238
{
239
return is_a5xx(screen) || is_a6xx(screen);
240
}
241
242
#endif /* FREEDRENO_SCREEN_H_ */
243
244