Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/gallium/drivers/radeonsi/si_state.h
4570 views
1
/*
2
* Copyright 2012 Advanced Micro Devices, Inc.
3
* All Rights Reserved.
4
*
5
* Permission is hereby granted, free of charge, to any person obtaining a
6
* copy of this software and associated documentation files (the "Software"),
7
* to deal in the Software without restriction, including without limitation
8
* on the rights to use, copy, modify, merge, publish, distribute, sub
9
* license, and/or sell copies of the Software, and to permit persons to whom
10
* the Software is furnished to do so, subject to the following conditions:
11
*
12
* The above copyright notice and this permission notice (including the next
13
* paragraph) shall be included in all copies or substantial portions of the
14
* Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22
* USE OR OTHER DEALINGS IN THE SOFTWARE.
23
*/
24
25
#ifndef SI_STATE_H
26
#define SI_STATE_H
27
28
#include "pipebuffer/pb_slab.h"
29
#include "si_pm4.h"
30
#include "util/u_blitter.h"
31
32
#ifdef __cplusplus
33
extern "C" {
34
#endif
35
36
#define SI_NUM_GRAPHICS_SHADERS (PIPE_SHADER_TESS_EVAL + 1)
37
#define SI_NUM_SHADERS (PIPE_SHADER_COMPUTE + 1)
38
39
#define SI_NUM_VERTEX_BUFFERS SI_MAX_ATTRIBS
40
#define SI_NUM_SAMPLERS 32 /* OpenGL textures units per shader */
41
#define SI_NUM_CONST_BUFFERS 16
42
#define SI_NUM_IMAGES 16
43
#define SI_NUM_IMAGE_SLOTS (SI_NUM_IMAGES * 2) /* the second half are FMASK slots */
44
#define SI_NUM_SHADER_BUFFERS 32
45
46
struct si_screen;
47
struct si_shader;
48
struct si_shader_ctx_state;
49
struct si_shader_selector;
50
struct si_texture;
51
struct si_qbo_state;
52
53
struct si_state_blend {
54
struct si_pm4_state pm4;
55
uint32_t cb_target_mask;
56
/* Set 0xf or 0x0 (4 bits) per render target if the following is
57
* true. ANDed with spi_shader_col_format.
58
*/
59
unsigned cb_target_enabled_4bit;
60
unsigned blend_enable_4bit;
61
unsigned need_src_alpha_4bit;
62
unsigned commutative_4bit;
63
unsigned dcc_msaa_corruption_4bit;
64
bool alpha_to_coverage : 1;
65
bool alpha_to_one : 1;
66
bool dual_src_blend : 1;
67
bool logicop_enable : 1;
68
bool allows_noop_optimization : 1;
69
};
70
71
struct si_state_rasterizer {
72
struct si_pm4_state pm4;
73
/* poly offset states for 16-bit, 24-bit, and 32-bit zbuffers */
74
struct si_pm4_state *pm4_poly_offset;
75
unsigned pa_sc_line_stipple;
76
unsigned pa_cl_clip_cntl;
77
float line_width;
78
float max_point_size;
79
unsigned ngg_cull_flags : 8;
80
unsigned ngg_cull_flags_y_inverted : 8;
81
unsigned sprite_coord_enable : 8;
82
unsigned clip_plane_enable : 8;
83
unsigned half_pixel_center : 1;
84
unsigned flatshade : 1;
85
unsigned flatshade_first : 1;
86
unsigned two_side : 1;
87
unsigned multisample_enable : 1;
88
unsigned force_persample_interp : 1;
89
unsigned line_stipple_enable : 1;
90
unsigned poly_stipple_enable : 1;
91
unsigned line_smooth : 1;
92
unsigned poly_smooth : 1;
93
unsigned uses_poly_offset : 1;
94
unsigned clamp_fragment_color : 1;
95
unsigned clamp_vertex_color : 1;
96
unsigned rasterizer_discard : 1;
97
unsigned scissor_enable : 1;
98
unsigned clip_halfz : 1;
99
unsigned cull_front : 1;
100
unsigned cull_back : 1;
101
unsigned depth_clamp_any : 1;
102
unsigned provoking_vertex_first : 1;
103
unsigned polygon_mode_enabled : 1;
104
unsigned polygon_mode_is_lines : 1;
105
unsigned polygon_mode_is_points : 1;
106
};
107
108
struct si_dsa_stencil_ref_part {
109
uint8_t valuemask[2];
110
uint8_t writemask[2];
111
};
112
113
struct si_dsa_order_invariance {
114
/** Whether the final result in Z/S buffers is guaranteed to be
115
* invariant under changes to the order in which fragments arrive. */
116
bool zs : 1;
117
118
/** Whether the set of fragments that pass the combined Z/S test is
119
* guaranteed to be invariant under changes to the order in which
120
* fragments arrive. */
121
bool pass_set : 1;
122
123
/** Whether the last fragment that passes the combined Z/S test at each
124
* sample is guaranteed to be invariant under changes to the order in
125
* which fragments arrive. */
126
bool pass_last : 1;
127
};
128
129
struct si_state_dsa {
130
struct si_pm4_state pm4;
131
struct si_dsa_stencil_ref_part stencil_ref;
132
133
/* 0 = without stencil buffer, 1 = when both Z and S buffers are present */
134
struct si_dsa_order_invariance order_invariance[2];
135
136
ubyte alpha_func : 3;
137
bool depth_enabled : 1;
138
bool depth_write_enabled : 1;
139
bool stencil_enabled : 1;
140
bool stencil_write_enabled : 1;
141
bool db_can_write : 1;
142
};
143
144
struct si_stencil_ref {
145
struct pipe_stencil_ref state;
146
struct si_dsa_stencil_ref_part dsa_part;
147
};
148
149
struct si_vertex_elements {
150
struct si_resource *instance_divisor_factor_buffer;
151
uint32_t rsrc_word3[SI_MAX_ATTRIBS];
152
uint16_t src_offset[SI_MAX_ATTRIBS];
153
uint8_t fix_fetch[SI_MAX_ATTRIBS];
154
uint8_t format_size[SI_MAX_ATTRIBS];
155
uint8_t vertex_buffer_index[SI_MAX_ATTRIBS];
156
157
/* Bitmask of elements that always need a fixup to be applied. */
158
uint16_t fix_fetch_always;
159
160
/* Bitmask of elements whose fetch should always be opencoded. */
161
uint16_t fix_fetch_opencode;
162
163
/* Bitmask of elements which need to be opencoded if the vertex buffer
164
* is unaligned. */
165
uint16_t fix_fetch_unaligned;
166
167
/* For elements in fix_fetch_unaligned: whether the effective
168
* element load size as seen by the hardware is a dword (as opposed
169
* to a short).
170
*/
171
uint16_t hw_load_is_dword;
172
173
/* Bitmask of vertex buffers requiring alignment check */
174
uint16_t vb_alignment_check_mask;
175
176
uint8_t count;
177
bool uses_instance_divisors;
178
179
uint16_t first_vb_use_mask;
180
/* Vertex buffer descriptor list size aligned for optimal prefetch. */
181
uint16_t vb_desc_list_alloc_size;
182
uint16_t instance_divisor_is_one; /* bitmask of inputs */
183
uint16_t instance_divisor_is_fetched; /* bitmask of inputs */
184
};
185
186
union si_state {
187
struct si_state_named {
188
struct si_state_blend *blend;
189
struct si_state_rasterizer *rasterizer;
190
struct si_state_dsa *dsa;
191
struct si_pm4_state *poly_offset;
192
struct si_pm4_state *ls;
193
struct si_pm4_state *hs;
194
struct si_pm4_state *es;
195
struct si_pm4_state *gs;
196
struct si_pm4_state *vgt_shader_config;
197
struct si_pm4_state *vs;
198
struct si_pm4_state *ps;
199
} named;
200
struct si_pm4_state *array[sizeof(struct si_state_named) / sizeof(struct si_pm4_state *)];
201
};
202
203
#define SI_STATE_IDX(name) (offsetof(union si_state, named.name) / sizeof(struct si_pm4_state *))
204
#define SI_STATE_BIT(name) (1 << SI_STATE_IDX(name))
205
#define SI_NUM_STATES (sizeof(union si_state) / sizeof(struct si_pm4_state *))
206
207
static inline unsigned si_states_that_always_roll_context(void)
208
{
209
return (SI_STATE_BIT(blend) | SI_STATE_BIT(rasterizer) | SI_STATE_BIT(dsa) |
210
SI_STATE_BIT(poly_offset) | SI_STATE_BIT(vgt_shader_config));
211
}
212
213
union si_state_atoms {
214
struct si_atoms_s {
215
/* The order matters. */
216
struct si_atom render_cond;
217
struct si_atom streamout_begin;
218
struct si_atom streamout_enable; /* must be after streamout_begin */
219
struct si_atom framebuffer;
220
struct si_atom msaa_sample_locs;
221
struct si_atom db_render_state;
222
struct si_atom dpbb_state;
223
struct si_atom msaa_config;
224
struct si_atom sample_mask;
225
struct si_atom cb_render_state;
226
struct si_atom blend_color;
227
struct si_atom clip_regs;
228
struct si_atom clip_state;
229
struct si_atom shader_pointers;
230
struct si_atom guardband;
231
struct si_atom scissors;
232
struct si_atom viewports;
233
struct si_atom stencil_ref;
234
struct si_atom spi_map;
235
struct si_atom scratch_state;
236
struct si_atom window_rectangles;
237
struct si_atom shader_query;
238
struct si_atom ngg_cull_state;
239
} s;
240
struct si_atom array[sizeof(struct si_atoms_s) / sizeof(struct si_atom)];
241
};
242
243
#define SI_ATOM_BIT(name) (1 << (offsetof(union si_state_atoms, s.name) / sizeof(struct si_atom)))
244
#define SI_NUM_ATOMS (sizeof(union si_state_atoms) / sizeof(struct si_atom))
245
246
static inline unsigned si_atoms_that_always_roll_context(void)
247
{
248
return (SI_ATOM_BIT(streamout_begin) | SI_ATOM_BIT(streamout_enable) | SI_ATOM_BIT(framebuffer) |
249
SI_ATOM_BIT(msaa_sample_locs) | SI_ATOM_BIT(sample_mask) | SI_ATOM_BIT(blend_color) |
250
SI_ATOM_BIT(clip_state) | SI_ATOM_BIT(scissors) | SI_ATOM_BIT(viewports) |
251
SI_ATOM_BIT(stencil_ref) | SI_ATOM_BIT(scratch_state) | SI_ATOM_BIT(window_rectangles));
252
}
253
254
struct si_shader_data {
255
uint32_t sh_base[SI_NUM_SHADERS];
256
};
257
258
#define SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK \
259
(S_02881C_USE_VTX_POINT_SIZE(1) | S_02881C_USE_VTX_EDGE_FLAG(1) | \
260
S_02881C_USE_VTX_RENDER_TARGET_INDX(1) | S_02881C_USE_VTX_VIEWPORT_INDX(1) | \
261
S_02881C_VS_OUT_MISC_VEC_ENA(1) | S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(1) | \
262
S_02881C_USE_VTX_VRS_RATE(1))
263
264
/* The list of registers whose emitted values are remembered by si_context. */
265
enum si_tracked_reg
266
{
267
SI_TRACKED_DB_RENDER_CONTROL, /* 2 consecutive registers */
268
SI_TRACKED_DB_COUNT_CONTROL,
269
270
SI_TRACKED_DB_RENDER_OVERRIDE2,
271
SI_TRACKED_DB_SHADER_CONTROL,
272
273
SI_TRACKED_CB_TARGET_MASK,
274
SI_TRACKED_CB_DCC_CONTROL,
275
276
SI_TRACKED_SX_PS_DOWNCONVERT, /* 3 consecutive registers */
277
SI_TRACKED_SX_BLEND_OPT_EPSILON,
278
SI_TRACKED_SX_BLEND_OPT_CONTROL,
279
280
SI_TRACKED_PA_SC_LINE_CNTL, /* 2 consecutive registers */
281
SI_TRACKED_PA_SC_AA_CONFIG,
282
283
SI_TRACKED_DB_EQAA,
284
SI_TRACKED_PA_SC_MODE_CNTL_1,
285
286
SI_TRACKED_PA_SU_PRIM_FILTER_CNTL,
287
SI_TRACKED_PA_SU_SMALL_PRIM_FILTER_CNTL,
288
289
SI_TRACKED_PA_CL_VS_OUT_CNTL__VS, /* set with SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK*/
290
SI_TRACKED_PA_CL_VS_OUT_CNTL__CL, /* set with ~SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK */
291
SI_TRACKED_PA_CL_CLIP_CNTL,
292
293
SI_TRACKED_PA_SC_BINNER_CNTL_0,
294
295
SI_TRACKED_DB_VRS_OVERRIDE_CNTL,
296
297
SI_TRACKED_PA_CL_GB_VERT_CLIP_ADJ, /* 4 consecutive registers */
298
SI_TRACKED_PA_CL_GB_VERT_DISC_ADJ,
299
SI_TRACKED_PA_CL_GB_HORZ_CLIP_ADJ,
300
SI_TRACKED_PA_CL_GB_HORZ_DISC_ADJ,
301
302
SI_TRACKED_PA_SU_HARDWARE_SCREEN_OFFSET,
303
SI_TRACKED_PA_SU_VTX_CNTL,
304
305
SI_TRACKED_PA_SC_CLIPRECT_RULE,
306
307
SI_TRACKED_PA_SC_LINE_STIPPLE,
308
309
SI_TRACKED_VGT_ESGS_RING_ITEMSIZE,
310
311
SI_TRACKED_VGT_GSVS_RING_OFFSET_1, /* 3 consecutive registers */
312
SI_TRACKED_VGT_GSVS_RING_OFFSET_2,
313
SI_TRACKED_VGT_GSVS_RING_OFFSET_3,
314
315
SI_TRACKED_VGT_GSVS_RING_ITEMSIZE,
316
SI_TRACKED_VGT_GS_MAX_VERT_OUT,
317
318
SI_TRACKED_VGT_GS_VERT_ITEMSIZE, /* 4 consecutive registers */
319
SI_TRACKED_VGT_GS_VERT_ITEMSIZE_1,
320
SI_TRACKED_VGT_GS_VERT_ITEMSIZE_2,
321
SI_TRACKED_VGT_GS_VERT_ITEMSIZE_3,
322
323
SI_TRACKED_VGT_GS_INSTANCE_CNT,
324
SI_TRACKED_VGT_GS_ONCHIP_CNTL,
325
SI_TRACKED_VGT_GS_MAX_PRIMS_PER_SUBGROUP,
326
SI_TRACKED_VGT_GS_MODE,
327
SI_TRACKED_VGT_PRIMITIVEID_EN,
328
SI_TRACKED_VGT_REUSE_OFF,
329
SI_TRACKED_SPI_VS_OUT_CONFIG,
330
SI_TRACKED_PA_CL_VTE_CNTL,
331
SI_TRACKED_PA_CL_NGG_CNTL,
332
SI_TRACKED_GE_MAX_OUTPUT_PER_SUBGROUP,
333
SI_TRACKED_GE_NGG_SUBGRP_CNTL,
334
335
SI_TRACKED_SPI_SHADER_IDX_FORMAT, /* 2 consecutive registers */
336
SI_TRACKED_SPI_SHADER_POS_FORMAT,
337
338
SI_TRACKED_SPI_PS_INPUT_ENA, /* 2 consecutive registers */
339
SI_TRACKED_SPI_PS_INPUT_ADDR,
340
341
SI_TRACKED_SPI_BARYC_CNTL,
342
SI_TRACKED_SPI_PS_IN_CONTROL,
343
344
SI_TRACKED_SPI_SHADER_Z_FORMAT, /* 2 consecutive registers */
345
SI_TRACKED_SPI_SHADER_COL_FORMAT,
346
347
SI_TRACKED_CB_SHADER_MASK,
348
SI_TRACKED_VGT_TF_PARAM,
349
SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL,
350
351
SI_TRACKED_GE_PC_ALLOC,
352
353
SI_NUM_TRACKED_REGS,
354
};
355
356
struct si_tracked_regs {
357
uint64_t reg_saved;
358
uint32_t reg_value[SI_NUM_TRACKED_REGS];
359
uint32_t spi_ps_input_cntl[32];
360
};
361
362
/* Private read-write buffer slots. */
363
enum
364
{
365
SI_ES_RING_ESGS,
366
SI_GS_RING_ESGS,
367
368
SI_RING_GSVS,
369
370
SI_VS_STREAMOUT_BUF0,
371
SI_VS_STREAMOUT_BUF1,
372
SI_VS_STREAMOUT_BUF2,
373
SI_VS_STREAMOUT_BUF3,
374
375
SI_HS_CONST_DEFAULT_TESS_LEVELS,
376
SI_VS_CONST_INSTANCE_DIVISORS,
377
SI_VS_CONST_CLIP_PLANES,
378
SI_PS_CONST_POLY_STIPPLE,
379
SI_PS_CONST_SAMPLE_POSITIONS,
380
381
/* Image descriptor of color buffer 0 for KHR_blend_equation_advanced. */
382
SI_PS_IMAGE_COLORBUF0,
383
SI_PS_IMAGE_COLORBUF0_HI,
384
SI_PS_IMAGE_COLORBUF0_FMASK,
385
SI_PS_IMAGE_COLORBUF0_FMASK_HI,
386
387
GFX10_GS_QUERY_BUF,
388
389
SI_NUM_INTERNAL_BINDINGS,
390
};
391
392
/* Indices into sctx->descriptors, laid out so that gfx and compute pipelines
393
* are contiguous:
394
*
395
* 0 - rw buffers
396
* 1 - vertex const and shader buffers
397
* 2 - vertex samplers and images
398
* 3 - fragment const and shader buffer
399
* ...
400
* 11 - compute const and shader buffers
401
* 12 - compute samplers and images
402
*/
403
enum
404
{
405
SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS,
406
SI_SHADER_DESCS_SAMPLERS_AND_IMAGES,
407
SI_NUM_SHADER_DESCS,
408
};
409
410
#define SI_DESCS_INTERNAL 0
411
#define SI_DESCS_FIRST_SHADER 1
412
#define SI_DESCS_FIRST_COMPUTE (SI_DESCS_FIRST_SHADER + PIPE_SHADER_COMPUTE * SI_NUM_SHADER_DESCS)
413
#define SI_NUM_DESCS (SI_DESCS_FIRST_SHADER + SI_NUM_SHADERS * SI_NUM_SHADER_DESCS)
414
415
#define SI_DESCS_SHADER_MASK(name) \
416
u_bit_consecutive(SI_DESCS_FIRST_SHADER + PIPE_SHADER_##name * SI_NUM_SHADER_DESCS, \
417
SI_NUM_SHADER_DESCS)
418
419
static inline unsigned si_const_and_shader_buffer_descriptors_idx(unsigned shader)
420
{
421
return SI_DESCS_FIRST_SHADER + shader * SI_NUM_SHADER_DESCS +
422
SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS;
423
}
424
425
static inline unsigned si_sampler_and_image_descriptors_idx(unsigned shader)
426
{
427
return SI_DESCS_FIRST_SHADER + shader * SI_NUM_SHADER_DESCS +
428
SI_SHADER_DESCS_SAMPLERS_AND_IMAGES;
429
}
430
431
/* This represents descriptors in memory, such as buffer resources,
432
* image resources, and sampler states.
433
*/
434
struct si_descriptors {
435
/* The list of descriptors in malloc'd memory. */
436
uint32_t *list;
437
/* The list in mapped GPU memory. */
438
uint32_t *gpu_list;
439
440
/* The buffer where the descriptors have been uploaded. */
441
struct si_resource *buffer;
442
uint64_t gpu_address;
443
444
/* The maximum number of descriptors. */
445
uint32_t num_elements;
446
447
/* Slots that are used by currently-bound shaders.
448
* It determines which slots are uploaded.
449
*/
450
uint32_t first_active_slot;
451
uint32_t num_active_slots;
452
453
/* The SH register offset relative to USER_DATA*_0 where the pointer
454
* to the descriptor array will be stored. */
455
short shader_userdata_offset;
456
/* The size of one descriptor. */
457
ubyte element_dw_size;
458
/* If there is only one slot enabled, bind it directly instead of
459
* uploading descriptors. -1 if disabled. */
460
signed char slot_index_to_bind_directly;
461
};
462
463
struct si_buffer_resources {
464
struct pipe_resource **buffers; /* this has num_buffers elements */
465
unsigned *offsets; /* this has num_buffers elements */
466
467
enum radeon_bo_priority priority : 6;
468
enum radeon_bo_priority priority_constbuf : 6;
469
470
/* The i-th bit is set if that element is enabled (non-NULL resource). */
471
uint64_t enabled_mask;
472
uint64_t writable_mask;
473
};
474
475
#define si_pm4_state_changed(sctx, member) \
476
((sctx)->queued.named.member != (sctx)->emitted.named.member)
477
478
#define si_pm4_state_enabled_and_changed(sctx, member) \
479
((sctx)->queued.named.member && si_pm4_state_changed(sctx, member))
480
481
#define si_pm4_bind_state(sctx, member, value) \
482
do { \
483
(sctx)->queued.named.member = (value); \
484
if (value && value != (sctx)->emitted.named.member) \
485
(sctx)->dirty_states |= SI_STATE_BIT(member); \
486
else \
487
(sctx)->dirty_states &= ~SI_STATE_BIT(member); \
488
} while (0)
489
490
/* si_descriptors.c */
491
void si_set_mutable_tex_desc_fields(struct si_screen *sscreen, struct si_texture *tex,
492
const struct legacy_surf_level *base_level_info,
493
unsigned base_level, unsigned first_level, unsigned block_width,
494
/* restrict decreases overhead of si_set_sampler_view_desc ~8x. */
495
bool is_stencil, uint16_t access, uint32_t * restrict state);
496
void si_update_ps_colorbuf0_slot(struct si_context *sctx);
497
void si_get_pipe_constant_buffer(struct si_context *sctx, uint shader, uint slot,
498
struct pipe_constant_buffer *cbuf);
499
void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader, uint start_slot,
500
uint count, struct pipe_shader_buffer *sbuf);
501
void si_set_ring_buffer(struct si_context *sctx, uint slot, struct pipe_resource *buffer,
502
unsigned stride, unsigned num_records, bool add_tid, bool swizzle,
503
unsigned element_size, unsigned index_stride, uint64_t offset);
504
void si_init_all_descriptors(struct si_context *sctx);
505
bool si_upload_graphics_shader_descriptors(struct si_context *sctx);
506
bool si_upload_compute_shader_descriptors(struct si_context *sctx);
507
void si_release_all_descriptors(struct si_context *sctx);
508
void si_gfx_resources_add_all_to_bo_list(struct si_context *sctx);
509
void si_compute_resources_add_all_to_bo_list(struct si_context *sctx);
510
bool si_gfx_resources_check_encrypted(struct si_context *sctx);
511
bool si_compute_resources_check_encrypted(struct si_context *sctx);
512
void si_shader_pointers_mark_dirty(struct si_context *sctx);
513
void si_add_all_descriptors_to_bo_list(struct si_context *sctx);
514
void si_update_all_texture_descriptors(struct si_context *sctx);
515
void si_shader_change_notify(struct si_context *sctx);
516
void si_update_needs_color_decompress_masks(struct si_context *sctx);
517
void si_emit_graphics_shader_pointers(struct si_context *sctx);
518
void si_emit_compute_shader_pointers(struct si_context *sctx);
519
void si_set_internal_const_buffer(struct si_context *sctx, uint slot,
520
const struct pipe_constant_buffer *input);
521
void si_set_internal_shader_buffer(struct si_context *sctx, uint slot,
522
const struct pipe_shader_buffer *sbuffer);
523
void si_set_active_descriptors(struct si_context *sctx, unsigned desc_idx,
524
uint64_t new_active_mask);
525
void si_set_active_descriptors_for_shader(struct si_context *sctx, struct si_shader_selector *sel);
526
bool si_bindless_descriptor_can_reclaim_slab(void *priv, struct pb_slab_entry *entry);
527
struct pb_slab *si_bindless_descriptor_slab_alloc(void *priv, unsigned heap, unsigned entry_size,
528
unsigned group_index);
529
void si_bindless_descriptor_slab_free(void *priv, struct pb_slab *pslab);
530
void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf);
531
/* si_state.c */
532
void si_init_state_compute_functions(struct si_context *sctx);
533
void si_init_state_functions(struct si_context *sctx);
534
void si_init_screen_state_functions(struct si_screen *sscreen);
535
void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing);
536
void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,
537
enum pipe_format format, unsigned offset, unsigned size,
538
uint32_t *state);
539
struct pipe_sampler_view *si_create_sampler_view_custom(struct pipe_context *ctx,
540
struct pipe_resource *texture,
541
const struct pipe_sampler_view *state,
542
unsigned width0, unsigned height0,
543
unsigned force_level);
544
void si_update_fb_dirtiness_after_rendering(struct si_context *sctx);
545
void si_mark_display_dcc_dirty(struct si_context *sctx, struct si_texture *tex);
546
void si_update_ps_iter_samples(struct si_context *sctx);
547
void si_save_qbo_state(struct si_context *sctx, struct si_qbo_state *st);
548
void si_restore_qbo_state(struct si_context *sctx, struct si_qbo_state *st);
549
void si_set_occlusion_query_state(struct si_context *sctx, bool old_perfect_enable);
550
551
struct si_fast_udiv_info32 {
552
unsigned multiplier; /* the "magic number" multiplier */
553
unsigned pre_shift; /* shift for the dividend before multiplying */
554
unsigned post_shift; /* shift for the dividend after multiplying */
555
int increment; /* 0 or 1; if set then increment the numerator, using one of
556
the two strategies */
557
};
558
559
struct si_fast_udiv_info32 si_compute_fast_udiv_info32(uint32_t D, unsigned num_bits);
560
561
/* si_state_binning.c */
562
void si_emit_dpbb_state(struct si_context *sctx);
563
564
/* si_state_shaders.c */
565
void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,
566
unsigned char ir_sha1_cache_key[20]);
567
bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],
568
struct si_shader *shader);
569
void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],
570
struct si_shader *shader, bool insert_into_disk_cache);
571
bool si_shader_mem_ordered(struct si_shader *shader);
572
bool si_update_shaders(struct si_context *sctx);
573
void si_init_screen_live_shader_cache(struct si_screen *sscreen);
574
void si_init_shader_functions(struct si_context *sctx);
575
bool si_init_shader_cache(struct si_screen *sscreen);
576
void si_destroy_shader_cache(struct si_screen *sscreen);
577
void si_schedule_initial_compile(struct si_context *sctx, gl_shader_stage stage,
578
struct util_queue_fence *ready_fence,
579
struct si_compiler_ctx_state *compiler_ctx_state, void *job,
580
util_queue_execute_func execute);
581
void si_get_active_slot_masks(const struct si_shader_info *info, uint64_t *const_and_shader_buffers,
582
uint64_t *samplers_and_images);
583
int si_shader_select_with_key(struct si_screen *sscreen, struct si_shader_ctx_state *state,
584
struct si_compiler_ctx_state *compiler_state,
585
struct si_shader_key *key, int thread_index, bool optimized_or_none);
586
void si_shader_selector_key_vs(struct si_context *sctx, struct si_shader_selector *vs,
587
struct si_shader_key *key, struct si_vs_prolog_bits *prolog_key);
588
unsigned si_get_input_prim(const struct si_shader_selector *gs);
589
bool si_update_ngg(struct si_context *sctx);
590
591
/* si_state_draw.c */
592
void si_init_draw_functions_GFX6(struct si_context *sctx);
593
void si_init_draw_functions_GFX7(struct si_context *sctx);
594
void si_init_draw_functions_GFX8(struct si_context *sctx);
595
void si_init_draw_functions_GFX9(struct si_context *sctx);
596
void si_init_draw_functions_GFX10(struct si_context *sctx);
597
void si_init_draw_functions_GFX10_3(struct si_context *sctx);
598
599
/* si_state_msaa.c */
600
void si_init_msaa_functions(struct si_context *sctx);
601
void si_emit_sample_locations(struct radeon_cmdbuf *cs, int nr_samples);
602
603
/* si_state_streamout.c */
604
void si_streamout_buffers_dirty(struct si_context *sctx);
605
void si_emit_streamout_end(struct si_context *sctx);
606
void si_update_prims_generated_query_state(struct si_context *sctx, unsigned type, int diff);
607
void si_init_streamout_functions(struct si_context *sctx);
608
609
static inline unsigned si_get_constbuf_slot(unsigned slot)
610
{
611
/* Constant buffers are in slots [32..47], ascending */
612
return SI_NUM_SHADER_BUFFERS + slot;
613
}
614
615
static inline unsigned si_get_shaderbuf_slot(unsigned slot)
616
{
617
/* shader buffers are in slots [31..0], descending */
618
return SI_NUM_SHADER_BUFFERS - 1 - slot;
619
}
620
621
static inline unsigned si_get_sampler_slot(unsigned slot)
622
{
623
/* 32 samplers are in sampler slots [16..47], 16 dw per slot, ascending */
624
/* those are equivalent to image slots [32..95], 8 dw per slot, ascending */
625
return SI_NUM_IMAGE_SLOTS / 2 + slot;
626
}
627
628
static inline unsigned si_get_image_slot(unsigned slot)
629
{
630
/* image slots are in [31..0] (sampler slots [15..0]), descending */
631
/* images are in slots [31..16], while FMASKs are in slots [15..0] */
632
return SI_NUM_IMAGE_SLOTS - 1 - slot;
633
}
634
635
#ifdef __cplusplus
636
}
637
#endif
638
639
#endif
640
641