2 * Copyright 2012 Advanced Micro Devices, Inc.
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:
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
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.
30 #include "pipebuffer/pb_slab.h"
31 #include "util/u_blitter.h"
33 #define SI_NUM_GRAPHICS_SHADERS (PIPE_SHADER_TESS_EVAL+1)
34 #define SI_NUM_SHADERS (PIPE_SHADER_COMPUTE+1)
36 #define SI_NUM_VERTEX_BUFFERS SI_MAX_ATTRIBS
37 #define SI_NUM_SAMPLERS 32 /* OpenGL textures units per shader */
38 #define SI_NUM_CONST_BUFFERS 16
39 #define SI_NUM_IMAGES 16
40 #define SI_NUM_SHADER_BUFFERS 16
44 struct si_shader_ctx_state
;
45 struct si_shader_selector
;
49 struct si_state_blend
{
50 struct si_pm4_state pm4
;
51 uint32_t cb_target_mask
;
52 /* Set 0xf or 0x0 (4 bits) per render target if the following is
53 * true. ANDed with spi_shader_col_format.
55 unsigned cb_target_enabled_4bit
;
56 unsigned blend_enable_4bit
;
57 unsigned need_src_alpha_4bit
;
58 unsigned commutative_4bit
;
59 bool alpha_to_coverage
:1;
61 bool dual_src_blend
:1;
62 bool logicop_enable
:1;
65 struct si_state_rasterizer
{
66 struct si_pm4_state pm4
;
67 /* poly offset states for 16-bit, 24-bit, and 32-bit zbuffers */
68 struct si_pm4_state
*pm4_poly_offset
;
69 unsigned pa_sc_line_stipple
;
70 unsigned pa_cl_clip_cntl
;
73 unsigned sprite_coord_enable
:8;
74 unsigned clip_plane_enable
:8;
75 unsigned half_pixel_center
:1;
77 unsigned flatshade_first
:1;
79 unsigned multisample_enable
:1;
80 unsigned force_persample_interp
:1;
81 unsigned line_stipple_enable
:1;
82 unsigned poly_stipple_enable
:1;
83 unsigned line_smooth
:1;
84 unsigned poly_smooth
:1;
85 unsigned uses_poly_offset
:1;
86 unsigned clamp_fragment_color
:1;
87 unsigned clamp_vertex_color
:1;
88 unsigned rasterizer_discard
:1;
89 unsigned scissor_enable
:1;
90 unsigned clip_halfz
:1;
91 unsigned cull_front
:1;
93 unsigned depth_clamp_any
:1;
94 unsigned provoking_vertex_first
:1;
97 struct si_dsa_stencil_ref_part
{
102 struct si_dsa_order_invariance
{
103 /** Whether the final result in Z/S buffers is guaranteed to be
104 * invariant under changes to the order in which fragments arrive. */
107 /** Whether the set of fragments that pass the combined Z/S test is
108 * guaranteed to be invariant under changes to the order in which
109 * fragments arrive. */
112 /** Whether the last fragment that passes the combined Z/S test at each
113 * sample is guaranteed to be invariant under changes to the order in
114 * which fragments arrive. */
118 struct si_state_dsa
{
119 struct si_pm4_state pm4
;
120 struct si_dsa_stencil_ref_part stencil_ref
;
122 /* 0 = without stencil buffer, 1 = when both Z and S buffers are present */
123 struct si_dsa_order_invariance order_invariance
[2];
126 bool depth_enabled
:1;
127 bool depth_write_enabled
:1;
128 bool stencil_enabled
:1;
129 bool stencil_write_enabled
:1;
134 struct si_stencil_ref
{
135 struct pipe_stencil_ref state
;
136 struct si_dsa_stencil_ref_part dsa_part
;
139 struct si_vertex_elements
141 struct si_resource
*instance_divisor_factor_buffer
;
142 uint32_t rsrc_word3
[SI_MAX_ATTRIBS
];
143 uint16_t src_offset
[SI_MAX_ATTRIBS
];
144 uint8_t fix_fetch
[SI_MAX_ATTRIBS
];
145 uint8_t format_size
[SI_MAX_ATTRIBS
];
146 uint8_t vertex_buffer_index
[SI_MAX_ATTRIBS
];
148 /* Bitmask of elements that always need a fixup to be applied. */
149 uint16_t fix_fetch_always
;
151 /* Bitmask of elements whose fetch should always be opencoded. */
152 uint16_t fix_fetch_opencode
;
154 /* Bitmask of elements which need to be opencoded if the vertex buffer
156 uint16_t fix_fetch_unaligned
;
158 /* For elements in fix_fetch_unaligned: whether the effective
159 * element load size as seen by the hardware is a dword (as opposed
162 uint16_t hw_load_is_dword
;
164 /* Bitmask of vertex buffers requiring alignment check */
165 uint16_t vb_alignment_check_mask
;
168 bool uses_instance_divisors
;
170 uint16_t first_vb_use_mask
;
171 /* Vertex buffer descriptor list size aligned for optimal prefetch. */
172 uint16_t desc_list_byte_size
;
173 uint16_t instance_divisor_is_one
; /* bitmask of inputs */
174 uint16_t instance_divisor_is_fetched
; /* bitmask of inputs */
179 struct si_state_blend
*blend
;
180 struct si_state_rasterizer
*rasterizer
;
181 struct si_state_dsa
*dsa
;
182 struct si_pm4_state
*poly_offset
;
183 struct si_pm4_state
*ls
;
184 struct si_pm4_state
*hs
;
185 struct si_pm4_state
*es
;
186 struct si_pm4_state
*gs
;
187 struct si_pm4_state
*vgt_shader_config
;
188 struct si_pm4_state
*vs
;
189 struct si_pm4_state
*ps
;
191 struct si_pm4_state
*array
[0];
194 #define SI_STATE_IDX(name) \
195 (offsetof(union si_state, named.name) / sizeof(struct si_pm4_state *))
196 #define SI_STATE_BIT(name) (1 << SI_STATE_IDX(name))
197 #define SI_NUM_STATES (sizeof(union si_state) / sizeof(struct si_pm4_state *))
199 static inline unsigned si_states_that_always_roll_context(void)
201 return (SI_STATE_BIT(blend
) |
202 SI_STATE_BIT(rasterizer
) |
204 SI_STATE_BIT(poly_offset
) |
205 SI_STATE_BIT(vgt_shader_config
));
208 union si_state_atoms
{
210 /* The order matters. */
211 struct si_atom render_cond
;
212 struct si_atom streamout_begin
;
213 struct si_atom streamout_enable
; /* must be after streamout_begin */
214 struct si_atom framebuffer
;
215 struct si_atom msaa_sample_locs
;
216 struct si_atom db_render_state
;
217 struct si_atom dpbb_state
;
218 struct si_atom msaa_config
;
219 struct si_atom sample_mask
;
220 struct si_atom cb_render_state
;
221 struct si_atom blend_color
;
222 struct si_atom clip_regs
;
223 struct si_atom clip_state
;
224 struct si_atom shader_pointers
;
225 struct si_atom guardband
;
226 struct si_atom scissors
;
227 struct si_atom viewports
;
228 struct si_atom stencil_ref
;
229 struct si_atom spi_map
;
230 struct si_atom scratch_state
;
231 struct si_atom window_rectangles
;
232 struct si_atom shader_query
;
234 struct si_atom array
[0];
237 #define SI_ATOM_BIT(name) (1 << (offsetof(union si_state_atoms, s.name) / \
238 sizeof(struct si_atom)))
239 #define SI_NUM_ATOMS (sizeof(union si_state_atoms)/sizeof(struct si_atom*))
241 static inline unsigned si_atoms_that_always_roll_context(void)
243 return (SI_ATOM_BIT(streamout_begin
) |
244 SI_ATOM_BIT(streamout_enable
) |
245 SI_ATOM_BIT(framebuffer
) |
246 SI_ATOM_BIT(msaa_sample_locs
) |
247 SI_ATOM_BIT(sample_mask
) |
248 SI_ATOM_BIT(blend_color
) |
249 SI_ATOM_BIT(clip_state
) |
250 SI_ATOM_BIT(scissors
) |
251 SI_ATOM_BIT(viewports
) |
252 SI_ATOM_BIT(stencil_ref
) |
253 SI_ATOM_BIT(scratch_state
) |
254 SI_ATOM_BIT(window_rectangles
));
257 struct si_shader_data
{
258 uint32_t sh_base
[SI_NUM_SHADERS
];
261 /* The list of registers whose emitted values are remembered by si_context. */
262 enum si_tracked_reg
{
263 SI_TRACKED_DB_RENDER_CONTROL
, /* 2 consecutive registers */
264 SI_TRACKED_DB_COUNT_CONTROL
,
266 SI_TRACKED_DB_RENDER_OVERRIDE2
,
267 SI_TRACKED_DB_SHADER_CONTROL
,
269 SI_TRACKED_CB_TARGET_MASK
,
270 SI_TRACKED_CB_DCC_CONTROL
,
272 SI_TRACKED_SX_PS_DOWNCONVERT
, /* 3 consecutive registers */
273 SI_TRACKED_SX_BLEND_OPT_EPSILON
,
274 SI_TRACKED_SX_BLEND_OPT_CONTROL
,
276 SI_TRACKED_PA_SC_LINE_CNTL
, /* 2 consecutive registers */
277 SI_TRACKED_PA_SC_AA_CONFIG
,
280 SI_TRACKED_PA_SC_MODE_CNTL_1
,
282 SI_TRACKED_PA_SU_PRIM_FILTER_CNTL
,
283 SI_TRACKED_PA_SU_SMALL_PRIM_FILTER_CNTL
,
285 SI_TRACKED_PA_CL_VS_OUT_CNTL
,
286 SI_TRACKED_PA_CL_CLIP_CNTL
,
288 SI_TRACKED_PA_SC_BINNER_CNTL_0
,
289 SI_TRACKED_DB_DFSM_CONTROL
,
291 SI_TRACKED_PA_CL_GB_VERT_CLIP_ADJ
, /* 4 consecutive registers */
292 SI_TRACKED_PA_CL_GB_VERT_DISC_ADJ
,
293 SI_TRACKED_PA_CL_GB_HORZ_CLIP_ADJ
,
294 SI_TRACKED_PA_CL_GB_HORZ_DISC_ADJ
,
296 SI_TRACKED_PA_SU_HARDWARE_SCREEN_OFFSET
,
297 SI_TRACKED_PA_SU_VTX_CNTL
,
299 SI_TRACKED_PA_SC_CLIPRECT_RULE
,
301 SI_TRACKED_VGT_ESGS_RING_ITEMSIZE
,
303 SI_TRACKED_VGT_GSVS_RING_OFFSET_1
, /* 3 consecutive registers */
304 SI_TRACKED_VGT_GSVS_RING_OFFSET_2
,
305 SI_TRACKED_VGT_GSVS_RING_OFFSET_3
,
307 SI_TRACKED_VGT_GSVS_RING_ITEMSIZE
,
308 SI_TRACKED_VGT_GS_MAX_VERT_OUT
,
310 SI_TRACKED_VGT_GS_VERT_ITEMSIZE
, /* 4 consecutive registers */
311 SI_TRACKED_VGT_GS_VERT_ITEMSIZE_1
,
312 SI_TRACKED_VGT_GS_VERT_ITEMSIZE_2
,
313 SI_TRACKED_VGT_GS_VERT_ITEMSIZE_3
,
315 SI_TRACKED_VGT_GS_INSTANCE_CNT
,
316 SI_TRACKED_VGT_GS_ONCHIP_CNTL
,
317 SI_TRACKED_VGT_GS_MAX_PRIMS_PER_SUBGROUP
,
318 SI_TRACKED_VGT_GS_MODE
,
319 SI_TRACKED_VGT_PRIMITIVEID_EN
,
320 SI_TRACKED_VGT_REUSE_OFF
,
321 SI_TRACKED_SPI_VS_OUT_CONFIG
,
322 SI_TRACKED_PA_CL_VTE_CNTL
,
323 SI_TRACKED_PA_CL_NGG_CNTL
,
324 SI_TRACKED_GE_MAX_OUTPUT_PER_SUBGROUP
,
325 SI_TRACKED_GE_NGG_SUBGRP_CNTL
,
327 SI_TRACKED_SPI_SHADER_IDX_FORMAT
, /* 2 consecutive registers */
328 SI_TRACKED_SPI_SHADER_POS_FORMAT
,
330 SI_TRACKED_SPI_PS_INPUT_ENA
, /* 2 consecutive registers */
331 SI_TRACKED_SPI_PS_INPUT_ADDR
,
333 SI_TRACKED_SPI_BARYC_CNTL
,
334 SI_TRACKED_SPI_PS_IN_CONTROL
,
336 SI_TRACKED_SPI_SHADER_Z_FORMAT
, /* 2 consecutive registers */
337 SI_TRACKED_SPI_SHADER_COL_FORMAT
,
339 SI_TRACKED_CB_SHADER_MASK
,
340 SI_TRACKED_VGT_TF_PARAM
,
341 SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL
,
346 struct si_tracked_regs
{
348 uint32_t reg_value
[SI_NUM_TRACKED_REGS
];
349 uint32_t spi_ps_input_cntl
[32];
352 /* Private read-write buffer slots. */
359 SI_VS_STREAMOUT_BUF0
,
360 SI_VS_STREAMOUT_BUF1
,
361 SI_VS_STREAMOUT_BUF2
,
362 SI_VS_STREAMOUT_BUF3
,
364 SI_HS_CONST_DEFAULT_TESS_LEVELS
,
365 SI_VS_CONST_INSTANCE_DIVISORS
,
366 SI_VS_CONST_CLIP_PLANES
,
367 SI_PS_CONST_POLY_STIPPLE
,
368 SI_PS_CONST_SAMPLE_POSITIONS
,
370 /* Image descriptor of color buffer 0 for KHR_blend_equation_advanced. */
371 SI_PS_IMAGE_COLORBUF0
,
372 SI_PS_IMAGE_COLORBUF0_HI
,
373 SI_PS_IMAGE_COLORBUF0_FMASK
,
374 SI_PS_IMAGE_COLORBUF0_FMASK_HI
,
381 /* Indices into sctx->descriptors, laid out so that gfx and compute pipelines
385 * 1 - vertex const and shader buffers
386 * 2 - vertex samplers and images
387 * 3 - fragment const and shader buffer
389 * 11 - compute const and shader buffers
390 * 12 - compute samplers and images
393 SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS
,
394 SI_SHADER_DESCS_SAMPLERS_AND_IMAGES
,
398 #define SI_DESCS_RW_BUFFERS 0
399 #define SI_DESCS_FIRST_SHADER 1
400 #define SI_DESCS_FIRST_COMPUTE (SI_DESCS_FIRST_SHADER + \
401 PIPE_SHADER_COMPUTE * SI_NUM_SHADER_DESCS)
402 #define SI_NUM_DESCS (SI_DESCS_FIRST_SHADER + \
403 SI_NUM_SHADERS * SI_NUM_SHADER_DESCS)
405 #define SI_DESCS_SHADER_MASK(name) \
406 u_bit_consecutive(SI_DESCS_FIRST_SHADER + \
407 PIPE_SHADER_##name * SI_NUM_SHADER_DESCS, \
410 static inline unsigned
411 si_const_and_shader_buffer_descriptors_idx(unsigned shader
)
413 return SI_DESCS_FIRST_SHADER
+ shader
* SI_NUM_SHADER_DESCS
+
414 SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS
;
417 static inline unsigned
418 si_sampler_and_image_descriptors_idx(unsigned shader
)
420 return SI_DESCS_FIRST_SHADER
+ shader
* SI_NUM_SHADER_DESCS
+
421 SI_SHADER_DESCS_SAMPLERS_AND_IMAGES
;
424 /* This represents descriptors in memory, such as buffer resources,
425 * image resources, and sampler states.
427 struct si_descriptors
{
428 /* The list of descriptors in malloc'd memory. */
430 /* The list in mapped GPU memory. */
433 /* The buffer where the descriptors have been uploaded. */
434 struct si_resource
*buffer
;
435 uint64_t gpu_address
;
437 /* The maximum number of descriptors. */
438 uint32_t num_elements
;
440 /* Slots that are used by currently-bound shaders.
441 * It determines which slots are uploaded.
443 uint32_t first_active_slot
;
444 uint32_t num_active_slots
;
446 /* The SH register offset relative to USER_DATA*_0 where the pointer
447 * to the descriptor array will be stored. */
448 short shader_userdata_offset
;
449 /* The size of one descriptor. */
450 ubyte element_dw_size
;
451 /* If there is only one slot enabled, bind it directly instead of
452 * uploading descriptors. -1 if disabled. */
453 signed char slot_index_to_bind_directly
;
456 struct si_buffer_resources
{
457 struct pipe_resource
**buffers
; /* this has num_buffers elements */
458 unsigned *offsets
; /* this has num_buffers elements */
460 enum radeon_bo_priority priority
:6;
461 enum radeon_bo_priority priority_constbuf
:6;
463 /* The i-th bit is set if that element is enabled (non-NULL resource). */
464 unsigned enabled_mask
;
465 unsigned writable_mask
;
468 #define si_pm4_state_changed(sctx, member) \
469 ((sctx)->queued.named.member != (sctx)->emitted.named.member)
471 #define si_pm4_state_enabled_and_changed(sctx, member) \
472 ((sctx)->queued.named.member && si_pm4_state_changed(sctx, member))
474 #define si_pm4_bind_state(sctx, member, value) \
476 (sctx)->queued.named.member = (value); \
477 (sctx)->dirty_states |= SI_STATE_BIT(member); \
480 #define si_pm4_delete_state(sctx, member, value) \
482 if ((sctx)->queued.named.member == (value)) { \
483 (sctx)->queued.named.member = NULL; \
485 si_pm4_free_state(sctx, (struct si_pm4_state *)(value), \
486 SI_STATE_IDX(member)); \
489 /* si_descriptors.c */
490 void si_set_mutable_tex_desc_fields(struct si_screen
*sscreen
,
491 struct si_texture
*tex
,
492 const struct legacy_surf_level
*base_level_info
,
493 unsigned base_level
, unsigned first_level
,
494 unsigned block_width
, bool is_stencil
,
496 void si_update_ps_colorbuf0_slot(struct si_context
*sctx
);
497 void si_get_pipe_constant_buffer(struct si_context
*sctx
, uint shader
,
498 uint slot
, struct pipe_constant_buffer
*cbuf
);
499 void si_get_shader_buffers(struct si_context
*sctx
,
500 enum pipe_shader_type shader
,
501 uint start_slot
, uint count
,
502 struct pipe_shader_buffer
*sbuf
);
503 void si_set_ring_buffer(struct si_context
*sctx
, uint slot
,
504 struct pipe_resource
*buffer
,
505 unsigned stride
, unsigned num_records
,
506 bool add_tid
, bool swizzle
,
507 unsigned element_size
, unsigned index_stride
, uint64_t offset
);
508 void si_init_all_descriptors(struct si_context
*sctx
);
509 bool si_upload_vertex_buffer_descriptors(struct si_context
*sctx
);
510 bool si_upload_graphics_shader_descriptors(struct si_context
*sctx
);
511 bool si_upload_compute_shader_descriptors(struct si_context
*sctx
);
512 void si_release_all_descriptors(struct si_context
*sctx
);
513 void si_gfx_resources_add_all_to_bo_list(struct si_context
*sctx
);
514 void si_compute_resources_add_all_to_bo_list(struct si_context
*sctx
);
515 void si_all_descriptors_begin_new_cs(struct si_context
*sctx
);
516 void si_upload_const_buffer(struct si_context
*sctx
, struct si_resource
**buf
,
517 const uint8_t *ptr
, unsigned size
, uint32_t *const_offset
);
518 void si_update_all_texture_descriptors(struct si_context
*sctx
);
519 void si_shader_change_notify(struct si_context
*sctx
);
520 void si_update_needs_color_decompress_masks(struct si_context
*sctx
);
521 void si_emit_graphics_shader_pointers(struct si_context
*sctx
);
522 void si_emit_compute_shader_pointers(struct si_context
*sctx
);
523 void si_set_rw_buffer(struct si_context
*sctx
,
524 uint slot
, const struct pipe_constant_buffer
*input
);
525 void si_set_rw_shader_buffer(struct si_context
*sctx
, uint slot
,
526 const struct pipe_shader_buffer
*sbuffer
);
527 void si_set_active_descriptors(struct si_context
*sctx
, unsigned desc_idx
,
528 uint64_t new_active_mask
);
529 void si_set_active_descriptors_for_shader(struct si_context
*sctx
,
530 struct si_shader_selector
*sel
);
531 bool si_bindless_descriptor_can_reclaim_slab(void *priv
,
532 struct pb_slab_entry
*entry
);
533 struct pb_slab
*si_bindless_descriptor_slab_alloc(void *priv
, unsigned heap
,
535 unsigned group_index
);
536 void si_bindless_descriptor_slab_free(void *priv
, struct pb_slab
*pslab
);
537 void si_rebind_buffer(struct si_context
*sctx
, struct pipe_resource
*buf
);
539 void si_init_state_compute_functions(struct si_context
*sctx
);
540 void si_init_state_functions(struct si_context
*sctx
);
541 void si_init_screen_state_functions(struct si_screen
*sscreen
);
543 si_make_buffer_descriptor(struct si_screen
*screen
, struct si_resource
*buf
,
544 enum pipe_format format
,
545 unsigned offset
, unsigned size
,
547 struct pipe_sampler_view
*
548 si_create_sampler_view_custom(struct pipe_context
*ctx
,
549 struct pipe_resource
*texture
,
550 const struct pipe_sampler_view
*state
,
551 unsigned width0
, unsigned height0
,
552 unsigned force_level
);
553 void si_update_fb_dirtiness_after_rendering(struct si_context
*sctx
);
554 void si_update_ps_iter_samples(struct si_context
*sctx
);
555 void si_save_qbo_state(struct si_context
*sctx
, struct si_qbo_state
*st
);
556 void si_restore_qbo_state(struct si_context
*sctx
, struct si_qbo_state
*st
);
557 void si_set_occlusion_query_state(struct si_context
*sctx
,
558 bool old_perfect_enable
);
560 struct si_fast_udiv_info32
{
561 unsigned multiplier
; /* the "magic number" multiplier */
562 unsigned pre_shift
; /* shift for the dividend before multiplying */
563 unsigned post_shift
; /* shift for the dividend after multiplying */
564 int increment
; /* 0 or 1; if set then increment the numerator, using one of
565 the two strategies */
568 struct si_fast_udiv_info32
569 si_compute_fast_udiv_info32(uint32_t D
, unsigned num_bits
);
571 /* si_state_binning.c */
572 void si_emit_dpbb_state(struct si_context
*sctx
);
574 /* si_state_shaders.c */
575 void *si_get_ir_binary(struct si_shader_selector
*sel
);
576 bool si_shader_cache_load_shader(struct si_screen
*sscreen
, void *ir_binary
,
577 struct si_shader
*shader
);
578 bool si_shader_cache_insert_shader(struct si_screen
*sscreen
, void *ir_binary
,
579 struct si_shader
*shader
,
580 bool insert_into_disk_cache
);
581 bool si_update_shaders(struct si_context
*sctx
);
582 void si_init_shader_functions(struct si_context
*sctx
);
583 bool si_init_shader_cache(struct si_screen
*sscreen
);
584 void si_destroy_shader_cache(struct si_screen
*sscreen
);
585 void si_schedule_initial_compile(struct si_context
*sctx
, unsigned processor
,
586 struct util_queue_fence
*ready_fence
,
587 struct si_compiler_ctx_state
*compiler_ctx_state
,
588 void *job
, util_queue_execute_func execute
);
589 void si_get_active_slot_masks(const struct tgsi_shader_info
*info
,
590 uint32_t *const_and_shader_buffers
,
591 uint64_t *samplers_and_images
);
592 int si_shader_select_with_key(struct si_screen
*sscreen
,
593 struct si_shader_ctx_state
*state
,
594 struct si_compiler_ctx_state
*compiler_state
,
595 struct si_shader_key
*key
,
597 bool optimized_or_none
);
598 void si_shader_selector_key_vs(struct si_context
*sctx
,
599 struct si_shader_selector
*vs
,
600 struct si_shader_key
*key
,
601 struct si_vs_prolog_bits
*prolog_key
);
602 unsigned si_get_input_prim(const struct si_shader_selector
*gs
);
604 /* si_state_draw.c */
605 void si_emit_surface_sync(struct si_context
*sctx
, struct radeon_cmdbuf
*cs
,
606 unsigned cp_coher_cntl
);
607 void si_prim_discard_signal_next_compute_ib_start(struct si_context
*sctx
);
608 void gfx10_emit_cache_flush(struct si_context
*sctx
);
609 void si_emit_cache_flush(struct si_context
*sctx
);
610 void si_trace_emit(struct si_context
*sctx
);
611 void si_init_draw_functions(struct si_context
*sctx
);
613 /* si_state_msaa.c */
614 void si_init_msaa_functions(struct si_context
*sctx
);
615 void si_emit_sample_locations(struct radeon_cmdbuf
*cs
, int nr_samples
);
617 /* si_state_streamout.c */
618 void si_streamout_buffers_dirty(struct si_context
*sctx
);
619 void si_emit_streamout_end(struct si_context
*sctx
);
620 void si_update_prims_generated_query_state(struct si_context
*sctx
,
621 unsigned type
, int diff
);
622 void si_init_streamout_functions(struct si_context
*sctx
);
625 static inline unsigned si_get_constbuf_slot(unsigned slot
)
627 /* Constant buffers are in slots [16..31], ascending */
628 return SI_NUM_SHADER_BUFFERS
+ slot
;
631 static inline unsigned si_get_shaderbuf_slot(unsigned slot
)
633 /* shader buffers are in slots [15..0], descending */
634 return SI_NUM_SHADER_BUFFERS
- 1 - slot
;
637 static inline unsigned si_get_sampler_slot(unsigned slot
)
639 /* samplers are in slots [8..39], ascending */
640 return SI_NUM_IMAGES
/ 2 + slot
;
643 static inline unsigned si_get_image_slot(unsigned slot
)
645 /* images are in slots [15..0] (sampler slots [7..0]), descending */
646 return SI_NUM_IMAGES
- 1 - slot
;