Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/iris/iris_context.h
4565 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 IRIS_CONTEXT_H
24
#define IRIS_CONTEXT_H
25
26
#include "pipe/p_context.h"
27
#include "pipe/p_state.h"
28
#include "util/set.h"
29
#include "util/slab.h"
30
#include "util/u_debug.h"
31
#include "util/u_threaded_context.h"
32
#include "intel/blorp/blorp.h"
33
#include "intel/dev/intel_debug.h"
34
#include "intel/common/intel_l3_config.h"
35
#include "intel/compiler/brw_compiler.h"
36
#include "iris_batch.h"
37
#include "iris_binder.h"
38
#include "iris_fence.h"
39
#include "iris_resource.h"
40
#include "iris_screen.h"
41
42
struct iris_bo;
43
struct iris_context;
44
struct blorp_batch;
45
struct blorp_params;
46
47
#define IRIS_MAX_TEXTURE_BUFFER_SIZE (1 << 27)
48
#define IRIS_MAX_TEXTURE_SAMPLERS 32
49
/* IRIS_MAX_ABOS and IRIS_MAX_SSBOS must be the same. */
50
#define IRIS_MAX_ABOS 16
51
#define IRIS_MAX_SSBOS 16
52
#define IRIS_MAX_VIEWPORTS 16
53
#define IRIS_MAX_CLIP_PLANES 8
54
#define IRIS_MAX_GLOBAL_BINDINGS 32
55
56
enum iris_param_domain {
57
BRW_PARAM_DOMAIN_BUILTIN = 0,
58
BRW_PARAM_DOMAIN_IMAGE,
59
};
60
61
enum {
62
DRI_CONF_BO_REUSE_DISABLED,
63
DRI_CONF_BO_REUSE_ALL
64
};
65
66
#define BRW_PARAM(domain, val) (BRW_PARAM_DOMAIN_##domain << 24 | (val))
67
#define BRW_PARAM_DOMAIN(param) ((uint32_t)(param) >> 24)
68
#define BRW_PARAM_VALUE(param) ((uint32_t)(param) & 0x00ffffff)
69
#define BRW_PARAM_IMAGE(idx, offset) BRW_PARAM(IMAGE, ((idx) << 8) | (offset))
70
#define BRW_PARAM_IMAGE_IDX(value) (BRW_PARAM_VALUE(value) >> 8)
71
#define BRW_PARAM_IMAGE_OFFSET(value)(BRW_PARAM_VALUE(value) & 0xf)
72
73
/**
74
* Dirty flags. When state changes, we flag some combination of these
75
* to indicate that particular GPU commands need to be re-emitted.
76
*
77
* Each bit typically corresponds to a single 3DSTATE_* command packet, but
78
* in rare cases they map to a group of related packets that need to be
79
* emitted together.
80
*
81
* See iris_upload_render_state().
82
*/
83
#define IRIS_DIRTY_COLOR_CALC_STATE (1ull << 0)
84
#define IRIS_DIRTY_POLYGON_STIPPLE (1ull << 1)
85
#define IRIS_DIRTY_SCISSOR_RECT (1ull << 2)
86
#define IRIS_DIRTY_WM_DEPTH_STENCIL (1ull << 3)
87
#define IRIS_DIRTY_CC_VIEWPORT (1ull << 4)
88
#define IRIS_DIRTY_SF_CL_VIEWPORT (1ull << 5)
89
#define IRIS_DIRTY_PS_BLEND (1ull << 6)
90
#define IRIS_DIRTY_BLEND_STATE (1ull << 7)
91
#define IRIS_DIRTY_RASTER (1ull << 8)
92
#define IRIS_DIRTY_CLIP (1ull << 9)
93
#define IRIS_DIRTY_SBE (1ull << 10)
94
#define IRIS_DIRTY_LINE_STIPPLE (1ull << 11)
95
#define IRIS_DIRTY_VERTEX_ELEMENTS (1ull << 12)
96
#define IRIS_DIRTY_MULTISAMPLE (1ull << 13)
97
#define IRIS_DIRTY_VERTEX_BUFFERS (1ull << 14)
98
#define IRIS_DIRTY_SAMPLE_MASK (1ull << 15)
99
#define IRIS_DIRTY_URB (1ull << 16)
100
#define IRIS_DIRTY_DEPTH_BUFFER (1ull << 17)
101
#define IRIS_DIRTY_WM (1ull << 18)
102
#define IRIS_DIRTY_SO_BUFFERS (1ull << 19)
103
#define IRIS_DIRTY_SO_DECL_LIST (1ull << 20)
104
#define IRIS_DIRTY_STREAMOUT (1ull << 21)
105
#define IRIS_DIRTY_VF_SGVS (1ull << 22)
106
#define IRIS_DIRTY_VF (1ull << 23)
107
#define IRIS_DIRTY_VF_TOPOLOGY (1ull << 24)
108
#define IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES (1ull << 25)
109
#define IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES (1ull << 26)
110
#define IRIS_DIRTY_VF_STATISTICS (1ull << 27)
111
#define IRIS_DIRTY_PMA_FIX (1ull << 28)
112
#define IRIS_DIRTY_DEPTH_BOUNDS (1ull << 29)
113
#define IRIS_DIRTY_RENDER_BUFFER (1ull << 30)
114
#define IRIS_DIRTY_STENCIL_REF (1ull << 31)
115
116
#define IRIS_ALL_DIRTY_FOR_COMPUTE (IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES)
117
118
#define IRIS_ALL_DIRTY_FOR_RENDER (~IRIS_ALL_DIRTY_FOR_COMPUTE)
119
120
/**
121
* Per-stage dirty flags. When state changes, we flag some combination of
122
* these to indicate that particular GPU commands need to be re-emitted.
123
* Unlike the IRIS_DIRTY_* flags these are shader stage-specific and can be
124
* indexed by shifting the mask by the shader stage index.
125
*
126
* See iris_upload_render_state().
127
*/
128
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_VS (1ull << 0)
129
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TCS (1ull << 1)
130
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TES (1ull << 2)
131
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_GS (1ull << 3)
132
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_PS (1ull << 4)
133
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_CS (1ull << 5)
134
#define IRIS_STAGE_DIRTY_UNCOMPILED_VS (1ull << 6)
135
#define IRIS_STAGE_DIRTY_UNCOMPILED_TCS (1ull << 7)
136
#define IRIS_STAGE_DIRTY_UNCOMPILED_TES (1ull << 8)
137
#define IRIS_STAGE_DIRTY_UNCOMPILED_GS (1ull << 9)
138
#define IRIS_STAGE_DIRTY_UNCOMPILED_FS (1ull << 10)
139
#define IRIS_STAGE_DIRTY_UNCOMPILED_CS (1ull << 11)
140
#define IRIS_STAGE_DIRTY_VS (1ull << 12)
141
#define IRIS_STAGE_DIRTY_TCS (1ull << 13)
142
#define IRIS_STAGE_DIRTY_TES (1ull << 14)
143
#define IRIS_STAGE_DIRTY_GS (1ull << 15)
144
#define IRIS_STAGE_DIRTY_FS (1ull << 16)
145
#define IRIS_STAGE_DIRTY_CS (1ull << 17)
146
#define IRIS_SHIFT_FOR_STAGE_DIRTY_CONSTANTS 18
147
#define IRIS_STAGE_DIRTY_CONSTANTS_VS (1ull << 18)
148
#define IRIS_STAGE_DIRTY_CONSTANTS_TCS (1ull << 19)
149
#define IRIS_STAGE_DIRTY_CONSTANTS_TES (1ull << 20)
150
#define IRIS_STAGE_DIRTY_CONSTANTS_GS (1ull << 21)
151
#define IRIS_STAGE_DIRTY_CONSTANTS_FS (1ull << 22)
152
#define IRIS_STAGE_DIRTY_CONSTANTS_CS (1ull << 23)
153
#define IRIS_STAGE_DIRTY_BINDINGS_VS (1ull << 24)
154
#define IRIS_STAGE_DIRTY_BINDINGS_TCS (1ull << 25)
155
#define IRIS_STAGE_DIRTY_BINDINGS_TES (1ull << 26)
156
#define IRIS_STAGE_DIRTY_BINDINGS_GS (1ull << 27)
157
#define IRIS_STAGE_DIRTY_BINDINGS_FS (1ull << 28)
158
#define IRIS_STAGE_DIRTY_BINDINGS_CS (1ull << 29)
159
160
#define IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE (IRIS_STAGE_DIRTY_CS | \
161
IRIS_STAGE_DIRTY_SAMPLER_STATES_CS | \
162
IRIS_STAGE_DIRTY_UNCOMPILED_CS | \
163
IRIS_STAGE_DIRTY_CONSTANTS_CS | \
164
IRIS_STAGE_DIRTY_BINDINGS_CS)
165
166
#define IRIS_ALL_STAGE_DIRTY_FOR_RENDER (~IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE)
167
168
#define IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER (IRIS_STAGE_DIRTY_BINDINGS_VS | \
169
IRIS_STAGE_DIRTY_BINDINGS_TCS | \
170
IRIS_STAGE_DIRTY_BINDINGS_TES | \
171
IRIS_STAGE_DIRTY_BINDINGS_GS | \
172
IRIS_STAGE_DIRTY_BINDINGS_FS)
173
174
#define IRIS_ALL_STAGE_DIRTY_BINDINGS (IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER | \
175
IRIS_STAGE_DIRTY_BINDINGS_CS)
176
177
/**
178
* Non-orthogonal state (NOS) dependency flags.
179
*
180
* Shader programs may depend on non-orthogonal state. These flags are
181
* used to indicate that a shader's key depends on the state provided by
182
* a certain Gallium CSO. Changing any CSOs marked as a dependency will
183
* cause the driver to re-compute the shader key, possibly triggering a
184
* shader recompile.
185
*/
186
enum iris_nos_dep {
187
IRIS_NOS_FRAMEBUFFER,
188
IRIS_NOS_DEPTH_STENCIL_ALPHA,
189
IRIS_NOS_RASTERIZER,
190
IRIS_NOS_BLEND,
191
IRIS_NOS_LAST_VUE_MAP,
192
193
IRIS_NOS_COUNT,
194
};
195
196
/** @{
197
*
198
* Program cache keys for state based recompiles.
199
*/
200
201
struct iris_base_prog_key {
202
unsigned program_string_id;
203
};
204
205
struct iris_vue_prog_key {
206
struct iris_base_prog_key base;
207
208
unsigned nr_userclip_plane_consts:4;
209
};
210
211
struct iris_vs_prog_key {
212
struct iris_vue_prog_key vue;
213
};
214
215
struct iris_tcs_prog_key {
216
struct iris_vue_prog_key vue;
217
218
uint16_t tes_primitive_mode;
219
220
uint8_t input_vertices;
221
222
bool quads_workaround;
223
224
/** A bitfield of per-patch outputs written. */
225
uint32_t patch_outputs_written;
226
227
/** A bitfield of per-vertex outputs written. */
228
uint64_t outputs_written;
229
};
230
231
struct iris_tes_prog_key {
232
struct iris_vue_prog_key vue;
233
234
/** A bitfield of per-patch inputs read. */
235
uint32_t patch_inputs_read;
236
237
/** A bitfield of per-vertex inputs read. */
238
uint64_t inputs_read;
239
};
240
241
struct iris_gs_prog_key {
242
struct iris_vue_prog_key vue;
243
};
244
245
struct iris_fs_prog_key {
246
struct iris_base_prog_key base;
247
248
unsigned nr_color_regions:5;
249
bool flat_shade:1;
250
bool alpha_test_replicate_alpha:1;
251
bool alpha_to_coverage:1;
252
bool clamp_fragment_color:1;
253
bool persample_interp:1;
254
bool multisample_fbo:1;
255
bool force_dual_color_blend:1;
256
bool coherent_fb_fetch:1;
257
258
uint8_t color_outputs_valid;
259
uint64_t input_slots_valid;
260
};
261
262
struct iris_cs_prog_key {
263
struct iris_base_prog_key base;
264
};
265
266
union iris_any_prog_key {
267
struct iris_base_prog_key base;
268
struct iris_vue_prog_key vue;
269
struct iris_vs_prog_key vs;
270
struct iris_tcs_prog_key tcs;
271
struct iris_tes_prog_key tes;
272
struct iris_gs_prog_key gs;
273
struct iris_fs_prog_key fs;
274
struct iris_cs_prog_key cs;
275
};
276
277
/** @} */
278
279
struct iris_depth_stencil_alpha_state;
280
281
/**
282
* Cache IDs for the in-memory program cache (ice->shaders.cache).
283
*/
284
enum iris_program_cache_id {
285
IRIS_CACHE_VS = MESA_SHADER_VERTEX,
286
IRIS_CACHE_TCS = MESA_SHADER_TESS_CTRL,
287
IRIS_CACHE_TES = MESA_SHADER_TESS_EVAL,
288
IRIS_CACHE_GS = MESA_SHADER_GEOMETRY,
289
IRIS_CACHE_FS = MESA_SHADER_FRAGMENT,
290
IRIS_CACHE_CS = MESA_SHADER_COMPUTE,
291
IRIS_CACHE_BLORP,
292
};
293
294
/** @{
295
*
296
* Defines for PIPE_CONTROL operations, which trigger cache flushes,
297
* synchronization, pipelined memory writes, and so on.
298
*
299
* The bits here are not the actual hardware values. The actual fields
300
* move between various generations, so we just have flags for each
301
* potential operation, and use genxml to encode the actual packet.
302
*/
303
enum pipe_control_flags
304
{
305
PIPE_CONTROL_FLUSH_LLC = (1 << 1),
306
PIPE_CONTROL_LRI_POST_SYNC_OP = (1 << 2),
307
PIPE_CONTROL_STORE_DATA_INDEX = (1 << 3),
308
PIPE_CONTROL_CS_STALL = (1 << 4),
309
PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET = (1 << 5),
310
PIPE_CONTROL_SYNC_GFDT = (1 << 6),
311
PIPE_CONTROL_TLB_INVALIDATE = (1 << 7),
312
PIPE_CONTROL_MEDIA_STATE_CLEAR = (1 << 8),
313
PIPE_CONTROL_WRITE_IMMEDIATE = (1 << 9),
314
PIPE_CONTROL_WRITE_DEPTH_COUNT = (1 << 10),
315
PIPE_CONTROL_WRITE_TIMESTAMP = (1 << 11),
316
PIPE_CONTROL_DEPTH_STALL = (1 << 12),
317
PIPE_CONTROL_RENDER_TARGET_FLUSH = (1 << 13),
318
PIPE_CONTROL_INSTRUCTION_INVALIDATE = (1 << 14),
319
PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE = (1 << 15),
320
PIPE_CONTROL_INDIRECT_STATE_POINTERS_DISABLE = (1 << 16),
321
PIPE_CONTROL_NOTIFY_ENABLE = (1 << 17),
322
PIPE_CONTROL_FLUSH_ENABLE = (1 << 18),
323
PIPE_CONTROL_DATA_CACHE_FLUSH = (1 << 19),
324
PIPE_CONTROL_VF_CACHE_INVALIDATE = (1 << 20),
325
PIPE_CONTROL_CONST_CACHE_INVALIDATE = (1 << 21),
326
PIPE_CONTROL_STATE_CACHE_INVALIDATE = (1 << 22),
327
PIPE_CONTROL_STALL_AT_SCOREBOARD = (1 << 23),
328
PIPE_CONTROL_DEPTH_CACHE_FLUSH = (1 << 24),
329
PIPE_CONTROL_TILE_CACHE_FLUSH = (1 << 25),
330
PIPE_CONTROL_FLUSH_HDC = (1 << 26),
331
};
332
333
#define PIPE_CONTROL_CACHE_FLUSH_BITS \
334
(PIPE_CONTROL_DEPTH_CACHE_FLUSH | \
335
PIPE_CONTROL_DATA_CACHE_FLUSH | \
336
PIPE_CONTROL_TILE_CACHE_FLUSH | \
337
PIPE_CONTROL_RENDER_TARGET_FLUSH)
338
339
#define PIPE_CONTROL_CACHE_INVALIDATE_BITS \
340
(PIPE_CONTROL_STATE_CACHE_INVALIDATE | \
341
PIPE_CONTROL_CONST_CACHE_INVALIDATE | \
342
PIPE_CONTROL_VF_CACHE_INVALIDATE | \
343
PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | \
344
PIPE_CONTROL_INSTRUCTION_INVALIDATE)
345
346
enum iris_predicate_state {
347
/* The first two states are used if we can determine whether to draw
348
* without having to look at the values in the query object buffer. This
349
* will happen if there is no conditional render in progress, if the query
350
* object is already completed or if something else has already added
351
* samples to the preliminary result.
352
*/
353
IRIS_PREDICATE_STATE_RENDER,
354
IRIS_PREDICATE_STATE_DONT_RENDER,
355
356
/* In this case whether to draw or not depends on the result of an
357
* MI_PREDICATE command so the predicate enable bit needs to be checked.
358
*/
359
IRIS_PREDICATE_STATE_USE_BIT,
360
};
361
362
/** @} */
363
364
/**
365
* An uncompiled, API-facing shader. This is the Gallium CSO for shaders.
366
* It primarily contains the NIR for the shader.
367
*
368
* Each API-facing shader can be compiled into multiple shader variants,
369
* based on non-orthogonal state dependencies, recorded in the shader key.
370
*
371
* See iris_compiled_shader, which represents a compiled shader variant.
372
*/
373
struct iris_uncompiled_shader {
374
struct nir_shader *nir;
375
376
struct pipe_stream_output_info stream_output;
377
378
/* A SHA1 of the serialized NIR for the disk cache. */
379
unsigned char nir_sha1[20];
380
381
unsigned program_id;
382
383
/** Bitfield of (1 << IRIS_NOS_*) flags. */
384
unsigned nos;
385
386
/** Have any shader variants been compiled yet? */
387
bool compiled_once;
388
389
/** Should we use ALT mode for math? Useful for ARB programs. */
390
bool use_alt_mode;
391
392
bool needs_edge_flag;
393
394
/* Whether shader uses atomic operations. */
395
bool uses_atomic_load_store;
396
397
/** Size (in bytes) of the kernel input data */
398
unsigned kernel_input_size;
399
400
/** Size (in bytes) of the local (shared) data passed as kernel inputs */
401
unsigned kernel_shared_size;
402
403
/** List of iris_compiled_shader variants */
404
struct list_head variants;
405
406
/** Lock for the variants list */
407
simple_mtx_t lock;
408
};
409
410
enum iris_surface_group {
411
IRIS_SURFACE_GROUP_RENDER_TARGET,
412
IRIS_SURFACE_GROUP_RENDER_TARGET_READ,
413
IRIS_SURFACE_GROUP_CS_WORK_GROUPS,
414
IRIS_SURFACE_GROUP_TEXTURE,
415
IRIS_SURFACE_GROUP_IMAGE,
416
IRIS_SURFACE_GROUP_UBO,
417
IRIS_SURFACE_GROUP_SSBO,
418
419
IRIS_SURFACE_GROUP_COUNT,
420
};
421
422
enum {
423
/* Invalid value for a binding table index. */
424
IRIS_SURFACE_NOT_USED = 0xa0a0a0a0,
425
};
426
427
struct iris_binding_table {
428
uint32_t size_bytes;
429
430
/** Number of surfaces in each group, before compacting. */
431
uint32_t sizes[IRIS_SURFACE_GROUP_COUNT];
432
433
/** Initial offset of each group. */
434
uint32_t offsets[IRIS_SURFACE_GROUP_COUNT];
435
436
/** Mask of surfaces used in each group. */
437
uint64_t used_mask[IRIS_SURFACE_GROUP_COUNT];
438
};
439
440
/**
441
* A compiled shader variant, containing a pointer to the GPU assembly,
442
* as well as program data and other packets needed by state upload.
443
*
444
* There can be several iris_compiled_shader variants per API-level shader
445
* (iris_uncompiled_shader), due to state-based recompiles (brw_*_prog_key).
446
*/
447
struct iris_compiled_shader {
448
struct pipe_reference ref;
449
450
/** Link in the iris_uncompiled_shader::variants list */
451
struct list_head link;
452
453
/** Key for this variant (but not for BLORP programs) */
454
union iris_any_prog_key key;
455
456
/** Reference to the uploaded assembly. */
457
struct iris_state_ref assembly;
458
459
/** Pointer to the assembly in the BO's map. */
460
void *map;
461
462
/** The program data (owned by the program cache hash table) */
463
struct brw_stage_prog_data *prog_data;
464
465
/** A list of system values to be uploaded as uniforms. */
466
enum brw_param_builtin *system_values;
467
unsigned num_system_values;
468
469
/** Size (in bytes) of the kernel input data */
470
unsigned kernel_input_size;
471
472
/** Number of constbufs expected by the shader. */
473
unsigned num_cbufs;
474
475
/**
476
* Derived 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets
477
* (the VUE-based information for transform feedback outputs).
478
*/
479
uint32_t *streamout;
480
481
struct iris_binding_table bt;
482
483
/**
484
* Shader packets and other data derived from prog_data. These must be
485
* completely determined from prog_data.
486
*/
487
uint8_t derived_data[0];
488
};
489
490
/**
491
* API context state that is replicated per shader stage.
492
*/
493
struct iris_shader_state {
494
/** Uniform Buffers */
495
struct pipe_shader_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS];
496
struct iris_state_ref constbuf_surf_state[PIPE_MAX_CONSTANT_BUFFERS];
497
498
bool sysvals_need_upload;
499
500
/** Shader Storage Buffers */
501
struct pipe_shader_buffer ssbo[PIPE_MAX_SHADER_BUFFERS];
502
struct iris_state_ref ssbo_surf_state[PIPE_MAX_SHADER_BUFFERS];
503
504
/** Shader Storage Images (image load store) */
505
struct iris_image_view image[PIPE_MAX_SHADER_IMAGES];
506
507
struct iris_state_ref sampler_table;
508
struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS];
509
struct iris_sampler_view *textures[IRIS_MAX_TEXTURE_SAMPLERS];
510
511
/** Bitfield of which constant buffers are bound (non-null). */
512
uint32_t bound_cbufs;
513
514
/** Bitfield of which image views are bound (non-null). */
515
uint32_t bound_image_views;
516
517
/** Bitfield of which sampler views are bound (non-null). */
518
uint32_t bound_sampler_views;
519
520
/** Bitfield of which shader storage buffers are bound (non-null). */
521
uint32_t bound_ssbos;
522
523
/** Bitfield of which shader storage buffers are writable. */
524
uint32_t writable_ssbos;
525
};
526
527
/**
528
* Gallium CSO for stream output (transform feedback) targets.
529
*/
530
struct iris_stream_output_target {
531
struct pipe_stream_output_target base;
532
533
/** Storage holding the offset where we're writing in the buffer */
534
struct iris_state_ref offset;
535
536
/** Stride (bytes-per-vertex) during this transform feedback operation */
537
uint16_t stride;
538
539
/** Does the next 3DSTATE_SO_BUFFER need to zero the offsets? */
540
bool zero_offset;
541
};
542
543
/**
544
* A pool containing SAMPLER_BORDER_COLOR_STATE entries.
545
*
546
* See iris_border_color.c for more information.
547
*/
548
struct iris_border_color_pool {
549
struct iris_bo *bo;
550
void *map;
551
unsigned insert_point;
552
553
/** Map from border colors to offsets in the buffer. */
554
struct hash_table *ht;
555
};
556
557
/**
558
* The API context (derived from pipe_context).
559
*
560
* Most driver state is tracked here.
561
*/
562
struct iris_context {
563
struct pipe_context ctx;
564
struct threaded_context *thrctx;
565
566
/** A debug callback for KHR_debug output. */
567
struct pipe_debug_callback dbg;
568
569
/** A device reset status callback for notifying that the GPU is hosed. */
570
struct pipe_device_reset_callback reset;
571
572
/** A set of dmabuf resources dirtied beyond their default aux-states. */
573
struct set *dirty_dmabufs;
574
575
/** Slab allocator for iris_transfer_map objects. */
576
struct slab_child_pool transfer_pool;
577
578
/** Slab allocator for threaded_context's iris_transfer_map objects */
579
struct slab_child_pool transfer_pool_unsync;
580
581
struct blorp_context blorp;
582
583
struct iris_batch batches[IRIS_BATCH_COUNT];
584
585
struct u_upload_mgr *query_buffer_uploader;
586
587
struct {
588
struct {
589
/**
590
* Either the value of BaseVertex for indexed draw calls or the value
591
* of the argument <first> for non-indexed draw calls.
592
*/
593
int firstvertex;
594
int baseinstance;
595
} params;
596
597
/**
598
* Are the above values the ones stored in the draw_params buffer?
599
* If so, we can compare them against new values to see if anything
600
* changed. If not, we need to assume they changed.
601
*/
602
bool params_valid;
603
604
/**
605
* Resource and offset that stores draw_parameters from the indirect
606
* buffer or to the buffer that stures the previous values for non
607
* indirect draws.
608
*/
609
struct iris_state_ref draw_params;
610
611
struct {
612
/**
613
* The value of DrawID. This always comes in from it's own vertex
614
* buffer since it's not part of the indirect draw parameters.
615
*/
616
int drawid;
617
618
/**
619
* Stores if an indexed or non-indexed draw (~0/0). Useful to
620
* calculate BaseVertex as an AND of firstvertex and is_indexed_draw.
621
*/
622
int is_indexed_draw;
623
} derived_params;
624
625
/**
626
* Resource and offset used for GL_ARB_shader_draw_parameters which
627
* contains parameters that are not present in the indirect buffer as
628
* drawid and is_indexed_draw. They will go in their own vertex element.
629
*/
630
struct iris_state_ref derived_draw_params;
631
} draw;
632
633
struct {
634
struct iris_uncompiled_shader *uncompiled[MESA_SHADER_STAGES];
635
struct iris_compiled_shader *prog[MESA_SHADER_STAGES];
636
struct iris_compiled_shader *last_vue_shader;
637
struct {
638
unsigned size[4];
639
unsigned entries[4];
640
unsigned start[4];
641
bool constrained;
642
} urb;
643
644
/** Uploader for shader assembly from the driver thread */
645
struct u_upload_mgr *uploader_driver;
646
/** Uploader for shader assembly from the threaded context */
647
struct u_upload_mgr *uploader_unsync;
648
struct hash_table *cache;
649
650
/** Is a GS or TES outputting points or lines? */
651
bool output_topology_is_points_or_lines;
652
653
/**
654
* Scratch buffers for various sizes and stages.
655
*
656
* Indexed by the "Per-Thread Scratch Space" field's 4-bit encoding,
657
* and shader stage.
658
*/
659
struct iris_bo *scratch_bos[1 << 4][MESA_SHADER_STAGES];
660
661
/**
662
* Scratch buffer surface states on Gfx12.5+
663
*/
664
struct iris_state_ref scratch_surfs[1 << 4];
665
} shaders;
666
667
struct intel_perf_context *perf_ctx;
668
669
/** Frame number for debug prints */
670
uint32_t frame;
671
672
struct {
673
uint64_t dirty;
674
uint64_t stage_dirty;
675
uint64_t stage_dirty_for_nos[IRIS_NOS_COUNT];
676
677
unsigned num_viewports;
678
unsigned sample_mask;
679
struct iris_blend_state *cso_blend;
680
struct iris_rasterizer_state *cso_rast;
681
struct iris_depth_stencil_alpha_state *cso_zsa;
682
struct iris_vertex_element_state *cso_vertex_elements;
683
struct pipe_blend_color blend_color;
684
struct pipe_poly_stipple poly_stipple;
685
struct pipe_viewport_state viewports[IRIS_MAX_VIEWPORTS];
686
struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS];
687
struct pipe_stencil_ref stencil_ref;
688
struct pipe_framebuffer_state framebuffer;
689
struct pipe_clip_state clip_planes;
690
691
float default_outer_level[4];
692
float default_inner_level[2];
693
694
/** Bitfield of which vertex buffers are bound (non-null). */
695
uint64_t bound_vertex_buffers;
696
697
bool primitive_restart;
698
unsigned cut_index;
699
enum pipe_prim_type prim_mode:8;
700
bool prim_is_points_or_lines;
701
uint8_t vertices_per_patch;
702
703
bool window_space_position;
704
705
/** The last compute group size */
706
uint32_t last_block[3];
707
708
/** The last compute grid size */
709
uint32_t last_grid[3];
710
/** Reference to the BO containing the compute grid size */
711
struct iris_state_ref grid_size;
712
/** Reference to the SURFACE_STATE for the compute grid resource */
713
struct iris_state_ref grid_surf_state;
714
715
/**
716
* Array of aux usages for drawing, altered to account for any
717
* self-dependencies from resources bound for sampling and rendering.
718
*/
719
enum isl_aux_usage draw_aux_usage[BRW_MAX_DRAW_BUFFERS];
720
721
/** Aux usage of the fb's depth buffer (which may or may not exist). */
722
enum isl_aux_usage hiz_usage;
723
724
enum intel_urb_deref_block_size urb_deref_block_size;
725
726
/** Are depth writes enabled? (Depth buffer may or may not exist.) */
727
bool depth_writes_enabled;
728
729
/** Are stencil writes enabled? (Stencil buffer may or may not exist.) */
730
bool stencil_writes_enabled;
731
732
/** GenX-specific current state */
733
struct iris_genx_state *genx;
734
735
struct iris_shader_state shaders[MESA_SHADER_STAGES];
736
737
/** Do vertex shader uses shader draw parameters ? */
738
bool vs_uses_draw_params;
739
bool vs_uses_derived_draw_params;
740
bool vs_needs_sgvs_element;
741
742
/** Do vertex shader uses edge flag ? */
743
bool vs_needs_edge_flag;
744
745
/** Do any samplers need border color? One bit per shader stage. */
746
uint8_t need_border_colors;
747
748
/** Global resource bindings */
749
struct pipe_resource *global_bindings[IRIS_MAX_GLOBAL_BINDINGS];
750
751
struct pipe_stream_output_target *so_target[PIPE_MAX_SO_BUFFERS];
752
bool streamout_active;
753
754
bool statistics_counters_enabled;
755
756
/** Current conditional rendering mode */
757
enum iris_predicate_state predicate;
758
759
/**
760
* Query BO with a MI_PREDICATE_RESULT snapshot calculated on the
761
* render context that needs to be uploaded to the compute context.
762
*/
763
struct iris_bo *compute_predicate;
764
765
/** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */
766
bool prims_generated_query_active;
767
768
/** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */
769
uint32_t *streamout;
770
771
/** The SURFACE_STATE for a 1x1x1 null surface. */
772
struct iris_state_ref unbound_tex;
773
774
/** The SURFACE_STATE for a framebuffer-sized null surface. */
775
struct iris_state_ref null_fb;
776
777
struct u_upload_mgr *surface_uploader;
778
struct u_upload_mgr *bindless_uploader;
779
struct u_upload_mgr *dynamic_uploader;
780
781
struct iris_binder binder;
782
783
struct iris_border_color_pool border_color_pool;
784
785
/** The high 16-bits of the last VBO/index buffer addresses */
786
uint16_t last_vbo_high_bits[33];
787
uint16_t last_index_bo_high_bits;
788
789
/**
790
* Resources containing streamed state which our render context
791
* currently points to. Used to re-add these to the validation
792
* list when we start a new batch and haven't resubmitted commands.
793
*/
794
struct {
795
struct pipe_resource *cc_vp;
796
struct pipe_resource *sf_cl_vp;
797
struct pipe_resource *color_calc;
798
struct pipe_resource *scissor;
799
struct pipe_resource *blend;
800
struct pipe_resource *index_buffer;
801
struct pipe_resource *cs_thread_ids;
802
struct pipe_resource *cs_desc;
803
} last_res;
804
805
/** Records the size of variable-length state for INTEL_DEBUG=bat */
806
struct hash_table_u64 *sizes;
807
808
/** Last rendering scale argument provided to genX(emit_hashing_mode). */
809
unsigned current_hash_scale;
810
} state;
811
};
812
813
#define perf_debug(dbg, ...) do { \
814
if (INTEL_DEBUG & DEBUG_PERF) \
815
dbg_printf(__VA_ARGS__); \
816
if (unlikely(dbg)) \
817
pipe_debug_message(dbg, PERF_INFO, __VA_ARGS__); \
818
} while(0)
819
820
struct pipe_context *
821
iris_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
822
823
void iris_lost_context_state(struct iris_batch *batch);
824
825
void iris_mark_dirty_dmabuf(struct iris_context *ice,
826
struct pipe_resource *res);
827
void iris_flush_dirty_dmabufs(struct iris_context *ice);
828
829
void iris_init_blit_functions(struct pipe_context *ctx);
830
void iris_init_clear_functions(struct pipe_context *ctx);
831
void iris_init_program_functions(struct pipe_context *ctx);
832
void iris_init_resource_functions(struct pipe_context *ctx);
833
void iris_init_perfquery_functions(struct pipe_context *ctx);
834
void iris_update_compiled_shaders(struct iris_context *ice);
835
void iris_update_compiled_compute_shader(struct iris_context *ice);
836
void iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data,
837
unsigned threads,
838
uint32_t *dst);
839
840
841
/* iris_blit.c */
842
void iris_blorp_surf_for_resource(struct isl_device *isl_dev,
843
struct blorp_surf *surf,
844
struct pipe_resource *p_res,
845
enum isl_aux_usage aux_usage,
846
unsigned level,
847
bool is_render_target);
848
void iris_copy_region(struct blorp_context *blorp,
849
struct iris_batch *batch,
850
struct pipe_resource *dst,
851
unsigned dst_level,
852
unsigned dstx, unsigned dsty, unsigned dstz,
853
struct pipe_resource *src,
854
unsigned src_level,
855
const struct pipe_box *src_box);
856
857
/* iris_draw.c */
858
859
void iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
860
unsigned drawid_offset,
861
const struct pipe_draw_indirect_info *indirect,
862
const struct pipe_draw_start_count_bias *draws,
863
unsigned num_draws);
864
void iris_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
865
866
/* iris_pipe_control.c */
867
868
void iris_emit_pipe_control_flush(struct iris_batch *batch,
869
const char *reason, uint32_t flags);
870
void iris_emit_pipe_control_write(struct iris_batch *batch,
871
const char *reason, uint32_t flags,
872
struct iris_bo *bo, uint32_t offset,
873
uint64_t imm);
874
void iris_emit_end_of_pipe_sync(struct iris_batch *batch,
875
const char *reason, uint32_t flags);
876
void iris_emit_buffer_barrier_for(struct iris_batch *batch,
877
struct iris_bo *bo,
878
enum iris_domain access);
879
void iris_flush_all_caches(struct iris_batch *batch);
880
881
#define iris_handle_always_flush_cache(batch) \
882
if (unlikely(batch->screen->driconf.always_flush_cache)) \
883
iris_flush_all_caches(batch);
884
885
void iris_init_flush_functions(struct pipe_context *ctx);
886
887
/* iris_border_color.c */
888
889
void iris_init_border_color_pool(struct iris_context *ice);
890
void iris_destroy_border_color_pool(struct iris_context *ice);
891
void iris_border_color_pool_reserve(struct iris_context *ice, unsigned count);
892
uint32_t iris_upload_border_color(struct iris_context *ice,
893
union pipe_color_union *color);
894
895
/* iris_program.c */
896
void iris_upload_ubo_ssbo_surf_state(struct iris_context *ice,
897
struct pipe_shader_buffer *buf,
898
struct iris_state_ref *surf_state,
899
isl_surf_usage_flags_t usage);
900
const struct shader_info *iris_get_shader_info(const struct iris_context *ice,
901
gl_shader_stage stage);
902
struct iris_bo *iris_get_scratch_space(struct iris_context *ice,
903
unsigned per_thread_scratch,
904
gl_shader_stage stage);
905
const struct iris_state_ref *iris_get_scratch_surf(struct iris_context *ice,
906
unsigned per_thread_scratch);
907
uint32_t iris_group_index_to_bti(const struct iris_binding_table *bt,
908
enum iris_surface_group group,
909
uint32_t index);
910
uint32_t iris_bti_to_group_index(const struct iris_binding_table *bt,
911
enum iris_surface_group group,
912
uint32_t bti);
913
914
/* iris_disk_cache.c */
915
916
void iris_disk_cache_store(struct disk_cache *cache,
917
const struct iris_uncompiled_shader *ish,
918
const struct iris_compiled_shader *shader,
919
const void *prog_key,
920
uint32_t prog_key_size);
921
struct iris_compiled_shader *
922
iris_disk_cache_retrieve(struct iris_screen *screen,
923
struct u_upload_mgr *uploader,
924
struct iris_uncompiled_shader *ish,
925
const void *prog_key,
926
uint32_t prog_key_size);
927
928
/* iris_program_cache.c */
929
930
void iris_init_program_cache(struct iris_context *ice);
931
void iris_destroy_program_cache(struct iris_context *ice);
932
struct iris_compiled_shader *iris_find_cached_shader(struct iris_context *ice,
933
enum iris_program_cache_id,
934
uint32_t key_size,
935
const void *key);
936
struct iris_compiled_shader *iris_upload_shader(struct iris_screen *screen,
937
struct iris_uncompiled_shader *,
938
struct hash_table *driver_ht,
939
struct u_upload_mgr *uploader,
940
enum iris_program_cache_id,
941
uint32_t key_size,
942
const void *key,
943
const void *assembly,
944
struct brw_stage_prog_data *,
945
uint32_t *streamout,
946
enum brw_param_builtin *sysv,
947
unsigned num_system_values,
948
unsigned kernel_input_size,
949
unsigned num_cbufs,
950
const struct iris_binding_table *bt);
951
void iris_delete_shader_variant(struct iris_compiled_shader *shader);
952
953
static inline void
954
iris_shader_variant_reference(struct iris_compiled_shader **dst,
955
struct iris_compiled_shader *src)
956
{
957
struct iris_compiled_shader *old_dst = *dst;
958
959
if (pipe_reference(old_dst ? &old_dst->ref: NULL, src ? &src->ref : NULL))
960
iris_delete_shader_variant(old_dst);
961
962
*dst = src;
963
}
964
965
bool iris_blorp_lookup_shader(struct blorp_batch *blorp_batch,
966
const void *key,
967
uint32_t key_size,
968
uint32_t *kernel_out,
969
void *prog_data_out);
970
bool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage,
971
const void *key, uint32_t key_size,
972
const void *kernel, uint32_t kernel_size,
973
const struct brw_stage_prog_data *prog_data,
974
uint32_t prog_data_size,
975
uint32_t *kernel_out,
976
void *prog_data_out);
977
978
/* iris_resolve.c */
979
980
void iris_predraw_resolve_inputs(struct iris_context *ice,
981
struct iris_batch *batch,
982
bool *draw_aux_buffer_disabled,
983
gl_shader_stage stage,
984
bool consider_framebuffer);
985
void iris_predraw_resolve_framebuffer(struct iris_context *ice,
986
struct iris_batch *batch,
987
bool *draw_aux_buffer_disabled);
988
void iris_postdraw_update_resolve_tracking(struct iris_context *ice,
989
struct iris_batch *batch);
990
void iris_cache_flush_for_render(struct iris_batch *batch,
991
struct iris_bo *bo,
992
enum isl_aux_usage aux_usage);
993
int iris_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
994
struct pipe_driver_query_info *info);
995
int iris_get_driver_query_group_info(struct pipe_screen *pscreen,
996
unsigned index,
997
struct pipe_driver_query_group_info *info);
998
999
/* iris_state.c */
1000
void gfx9_toggle_preemption(struct iris_context *ice,
1001
struct iris_batch *batch,
1002
const struct pipe_draw_info *draw);
1003
1004
1005
1006
#ifdef genX
1007
# include "iris_genx_protos.h"
1008
#else
1009
# define genX(x) gfx4_##x
1010
# include "iris_genx_protos.h"
1011
# undef genX
1012
# define genX(x) gfx5_##x
1013
# include "iris_genx_protos.h"
1014
# undef genX
1015
# define genX(x) gfx6_##x
1016
# include "iris_genx_protos.h"
1017
# undef genX
1018
# define genX(x) gfx7_##x
1019
# include "iris_genx_protos.h"
1020
# undef genX
1021
# define genX(x) gfx75_##x
1022
# include "iris_genx_protos.h"
1023
# undef genX
1024
# define genX(x) gfx8_##x
1025
# include "iris_genx_protos.h"
1026
# undef genX
1027
# define genX(x) gfx9_##x
1028
# include "iris_genx_protos.h"
1029
# undef genX
1030
# define genX(x) gfx11_##x
1031
# include "iris_genx_protos.h"
1032
# undef genX
1033
# define genX(x) gfx12_##x
1034
# include "iris_genx_protos.h"
1035
# undef genX
1036
# define genX(x) gfx125_##x
1037
# include "iris_genx_protos.h"
1038
# undef genX
1039
#endif
1040
1041
#endif
1042
1043