Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/crocus/crocus_screen.h
4570 views
1
/*
2
* Copyright © 2017 Intel Corporation
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
* on the rights to use, copy, modify, merge, publish, distribute, sub
8
* license, and/or sell copies of the Software, and to permit persons to whom
9
* the 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 NON-INFRINGEMENT. IN NO EVENT SHALL
18
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21
* USE OR OTHER DEALINGS IN THE SOFTWARE.
22
*/
23
#ifndef CROCUS_SCREEN_H
24
#define CROCUS_SCREEN_H
25
26
#include "pipe/p_screen.h"
27
#include "pipe/p_state.h"
28
#include "frontend/drm_driver.h"
29
#include "util/disk_cache.h"
30
#include "util/slab.h"
31
#include "util/u_screen.h"
32
#include "intel/dev/intel_device_info.h"
33
#include "intel/isl/isl.h"
34
#include "crocus_bufmgr.h"
35
#include "compiler/shader_enums.h"
36
37
struct crocus_monitor_config;
38
struct crocus_resource;
39
struct crocus_context;
40
struct crocus_sampler_state;
41
struct brw_vue_map;
42
struct brw_tcs_prog_key;
43
struct brw_tes_prog_key;
44
struct brw_cs_prog_key;
45
struct brw_wm_prog_key;
46
struct brw_vs_prog_key;
47
struct brw_gs_prog_key;
48
struct shader_info;
49
50
#define READ_ONCE(x) (*(volatile __typeof__(x) *)&(x))
51
#define WRITE_ONCE(x, v) *(volatile __typeof__(x) *)&(x) = (v)
52
53
#define CROCUS_MAX_TEXTURE_SAMPLERS 32
54
#define CROCUS_MAX_SOL_BUFFERS 4
55
#define CROCUS_MAP_BUFFER_ALIGNMENT 64
56
57
58
/**
59
* Virtual table for generation-specific (genxml) function calls.
60
*/
61
struct crocus_vtable {
62
void (*destroy_state)(struct crocus_context *ice);
63
void (*init_render_context)(struct crocus_batch *batch);
64
void (*init_compute_context)(struct crocus_batch *batch);
65
void (*upload_render_state)(struct crocus_context *ice,
66
struct crocus_batch *batch,
67
const struct pipe_draw_info *draw,
68
unsigned drawid_offset,
69
const struct pipe_draw_indirect_info *indirect,
70
const struct pipe_draw_start_count_bias *sc);
71
void (*update_surface_base_address)(struct crocus_batch *batch);
72
73
void (*upload_compute_state)(struct crocus_context *ice,
74
struct crocus_batch *batch,
75
const struct pipe_grid_info *grid);
76
void (*rebind_buffer)(struct crocus_context *ice,
77
struct crocus_resource *res);
78
void (*resolve_conditional_render)(struct crocus_context *ice);
79
void (*emit_compute_predicate)(struct crocus_batch *batch);
80
void (*load_register_reg32)(struct crocus_batch *batch, uint32_t dst,
81
uint32_t src);
82
void (*load_register_reg64)(struct crocus_batch *batch, uint32_t dst,
83
uint32_t src);
84
void (*load_register_imm32)(struct crocus_batch *batch, uint32_t reg,
85
uint32_t val);
86
void (*load_register_imm64)(struct crocus_batch *batch, uint32_t reg,
87
uint64_t val);
88
void (*load_register_mem32)(struct crocus_batch *batch, uint32_t reg,
89
struct crocus_bo *bo, uint32_t offset);
90
void (*load_register_mem64)(struct crocus_batch *batch, uint32_t reg,
91
struct crocus_bo *bo, uint32_t offset);
92
void (*store_register_mem32)(struct crocus_batch *batch, uint32_t reg,
93
struct crocus_bo *bo, uint32_t offset,
94
bool predicated);
95
void (*store_register_mem64)(struct crocus_batch *batch, uint32_t reg,
96
struct crocus_bo *bo, uint32_t offset,
97
bool predicated);
98
void (*store_data_imm32)(struct crocus_batch *batch,
99
struct crocus_bo *bo, uint32_t offset,
100
uint32_t value);
101
void (*store_data_imm64)(struct crocus_batch *batch,
102
struct crocus_bo *bo, uint32_t offset,
103
uint64_t value);
104
void (*copy_mem_mem)(struct crocus_batch *batch,
105
struct crocus_bo *dst_bo, uint32_t dst_offset,
106
struct crocus_bo *src_bo, uint32_t src_offset,
107
unsigned bytes);
108
void (*emit_raw_pipe_control)(struct crocus_batch *batch,
109
const char *reason, uint32_t flags,
110
struct crocus_bo *bo, uint32_t offset,
111
uint64_t imm);
112
113
void (*emit_mi_report_perf_count)(struct crocus_batch *batch,
114
struct crocus_bo *bo,
115
uint32_t offset_in_bytes,
116
uint32_t report_id);
117
118
uint32_t *(*create_so_decl_list)(const struct pipe_stream_output_info *sol,
119
const struct brw_vue_map *vue_map);
120
void (*populate_vs_key)(const struct crocus_context *ice,
121
const struct shader_info *info,
122
gl_shader_stage last_stage,
123
struct brw_vs_prog_key *key);
124
void (*populate_tcs_key)(const struct crocus_context *ice,
125
struct brw_tcs_prog_key *key);
126
void (*populate_tes_key)(const struct crocus_context *ice,
127
const struct shader_info *info,
128
gl_shader_stage last_stage,
129
struct brw_tes_prog_key *key);
130
void (*populate_gs_key)(const struct crocus_context *ice,
131
const struct shader_info *info,
132
gl_shader_stage last_stage,
133
struct brw_gs_prog_key *key);
134
void (*populate_fs_key)(const struct crocus_context *ice,
135
const struct shader_info *info,
136
struct brw_wm_prog_key *key);
137
void (*populate_cs_key)(const struct crocus_context *ice,
138
struct brw_cs_prog_key *key);
139
void (*fill_clamp_mask)(const struct crocus_sampler_state *state,
140
int s,
141
uint32_t *clamp_mask);
142
void (*lost_genx_state)(struct crocus_context *ice, struct crocus_batch *batch);
143
144
void (*finish_batch)(struct crocus_batch *batch); /* haswell only */
145
146
void (*upload_urb_fence)(struct crocus_batch *batch); /* gen4/5 only */
147
148
bool (*blit_blt)(struct crocus_batch *batch,
149
const struct pipe_blit_info *info);
150
bool (*copy_region_blt)(struct crocus_batch *batch,
151
struct crocus_resource *dst,
152
unsigned dst_level,
153
unsigned dstx, unsigned dsty, unsigned dstz,
154
struct crocus_resource *src,
155
unsigned src_level,
156
const struct pipe_box *src_box);
157
bool (*calculate_urb_fence)(struct crocus_batch *batch, unsigned csize,
158
unsigned vsize, unsigned sfsize);
159
void (*batch_reset_dirty)(struct crocus_batch *batch);
160
unsigned (*translate_prim_type)(enum pipe_prim_type prim, uint8_t verts_per_patch);
161
162
void (*update_so_strides)(struct crocus_context *ice,
163
uint16_t *strides);
164
165
uint32_t (*get_so_offset)(struct pipe_stream_output_target *tgt);
166
};
167
168
struct crocus_screen {
169
struct pipe_screen base;
170
171
uint32_t refcount;
172
173
/** Global slab allocator for crocus_transfer_map objects */
174
struct slab_parent_pool transfer_pool;
175
176
/** drm device file descriptor, shared with bufmgr, do not close. */
177
int fd;
178
179
/**
180
* drm device file descriptor to used for window system integration, owned
181
* by iris_screen, can be a different DRM instance than fd.
182
*/
183
int winsys_fd;
184
185
/** PCI ID for our GPU device */
186
int pci_id;
187
188
bool no_hw;
189
190
struct crocus_vtable vtbl;
191
192
/** Global program_string_id counter (see get_program_string_id()) */
193
unsigned program_id;
194
195
/** Precompile shaders at link time? (Can be disabled for debugging.) */
196
bool precompile;
197
198
/** driconf options and application workarounds */
199
struct {
200
/** Dual color blend by location instead of index (for broken apps) */
201
bool dual_color_blend_by_location;
202
bool disable_throttling;
203
bool always_flush_cache;
204
} driconf;
205
206
unsigned subslice_total;
207
208
uint64_t aperture_bytes;
209
210
struct intel_device_info devinfo;
211
struct isl_device isl_dev;
212
struct crocus_bufmgr *bufmgr;
213
struct brw_compiler *compiler;
214
struct crocus_monitor_config *monitor_cfg;
215
bool has_swizzling;
216
217
const struct intel_l3_config *l3_config_3d;
218
const struct intel_l3_config *l3_config_cs;
219
220
struct disk_cache *disk_cache;
221
};
222
223
struct pipe_screen *
224
crocus_screen_create(int fd, const struct pipe_screen_config *config);
225
226
void crocus_screen_destroy(struct crocus_screen *screen);
227
228
UNUSED static inline struct pipe_screen *
229
crocus_pscreen_ref(struct pipe_screen *pscreen)
230
{
231
struct crocus_screen *screen = (struct crocus_screen *) pscreen;
232
233
p_atomic_inc(&screen->refcount);
234
return pscreen;
235
}
236
237
UNUSED static inline void
238
crocus_pscreen_unref(struct pipe_screen *pscreen)
239
{
240
struct crocus_screen *screen = (struct crocus_screen *) pscreen;
241
242
if (p_atomic_dec_zero(&screen->refcount))
243
crocus_screen_destroy(screen);
244
}
245
246
bool
247
crocus_is_format_supported(struct pipe_screen *pscreen,
248
enum pipe_format format,
249
enum pipe_texture_target target,
250
unsigned sample_count,
251
unsigned storage_sample_count,
252
unsigned usage);
253
254
void crocus_disk_cache_init(struct crocus_screen *screen);
255
256
#endif
257
258