2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
3 * Copyright 2018 Advanced Micro Devices, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * on the rights to use, copy, modify, merge, publish, distribute, sub
10 * license, and/or sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
23 * USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "si_shader.h"
30 #include "util/u_dynarray.h"
31 #include "util/u_idalloc.h"
33 #ifdef PIPE_ARCH_BIG_ENDIAN
34 #define SI_BIG_ENDIAN 1
36 #define SI_BIG_ENDIAN 0
39 #define ATI_VENDOR_ID 0x1002
41 #define SI_NOT_QUERY 0xffffffff
43 /* The base vertex and primitive restart can be any number, but we must pick
44 * one which will mean "unknown" for the purpose of state tracking and
45 * the number shouldn't be a commonly-used one. */
46 #define SI_BASE_VERTEX_UNKNOWN INT_MIN
47 #define SI_RESTART_INDEX_UNKNOWN INT_MIN
48 #define SI_NUM_SMOOTH_AA_SAMPLES 8
49 #define SI_GS_PER_ES 128
50 /* Alignment for optimal CP DMA performance. */
51 #define SI_CPDMA_ALIGNMENT 32
53 /* Pipeline & streamout query controls. */
54 #define SI_CONTEXT_START_PIPELINE_STATS (1 << 0)
55 #define SI_CONTEXT_STOP_PIPELINE_STATS (1 << 1)
56 #define SI_CONTEXT_FLUSH_FOR_RENDER_COND (1 << 2)
57 /* Instruction cache. */
58 #define SI_CONTEXT_INV_ICACHE (1 << 3)
59 /* SMEM L1, other names: KCACHE, constant cache, DCACHE, data cache */
60 #define SI_CONTEXT_INV_SMEM_L1 (1 << 4)
61 /* VMEM L1 can optionally be bypassed (GLC=1). Other names: TC L1 */
62 #define SI_CONTEXT_INV_VMEM_L1 (1 << 5)
63 /* Used by everything except CB/DB, can be bypassed (SLC=1). Other names: TC L2 */
64 #define SI_CONTEXT_INV_GLOBAL_L2 (1 << 6)
65 /* Write dirty L2 lines back to memory (shader and CP DMA stores), but don't
66 * invalidate L2. SI-CIK can't do it, so they will do complete invalidation. */
67 #define SI_CONTEXT_WRITEBACK_GLOBAL_L2 (1 << 7)
68 /* Writeback & invalidate the L2 metadata cache. It can only be coupled with
69 * a CB or DB flush. */
70 #define SI_CONTEXT_INV_L2_METADATA (1 << 8)
71 /* Framebuffer caches. */
72 #define SI_CONTEXT_FLUSH_AND_INV_DB (1 << 9)
73 #define SI_CONTEXT_FLUSH_AND_INV_DB_META (1 << 10)
74 #define SI_CONTEXT_FLUSH_AND_INV_CB (1 << 11)
75 /* Engine synchronization. */
76 #define SI_CONTEXT_VS_PARTIAL_FLUSH (1 << 12)
77 #define SI_CONTEXT_PS_PARTIAL_FLUSH (1 << 13)
78 #define SI_CONTEXT_CS_PARTIAL_FLUSH (1 << 14)
79 #define SI_CONTEXT_VGT_FLUSH (1 << 15)
80 #define SI_CONTEXT_VGT_STREAMOUT_SYNC (1 << 16)
82 #define SI_PREFETCH_VBO_DESCRIPTORS (1 << 0)
83 #define SI_PREFETCH_LS (1 << 1)
84 #define SI_PREFETCH_HS (1 << 2)
85 #define SI_PREFETCH_ES (1 << 3)
86 #define SI_PREFETCH_GS (1 << 4)
87 #define SI_PREFETCH_VS (1 << 5)
88 #define SI_PREFETCH_PS (1 << 6)
90 #define SI_MAX_BORDER_COLORS 4096
91 #define SI_MAX_VIEWPORTS 16
93 #define SI_MAP_BUFFER_ALIGNMENT 64
94 #define SI_MAX_VARIABLE_THREADS_PER_BLOCK 1024
96 #define SI_RESOURCE_FLAG_TRANSFER (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
97 #define SI_RESOURCE_FLAG_FLUSHED_DEPTH (PIPE_RESOURCE_FLAG_DRV_PRIV << 1)
98 #define SI_RESOURCE_FLAG_FORCE_TILING (PIPE_RESOURCE_FLAG_DRV_PRIV << 2)
99 #define SI_RESOURCE_FLAG_DISABLE_DCC (PIPE_RESOURCE_FLAG_DRV_PRIV << 3)
100 #define SI_RESOURCE_FLAG_UNMAPPABLE (PIPE_RESOURCE_FLAG_DRV_PRIV << 4)
101 #define SI_RESOURCE_FLAG_READ_ONLY (PIPE_RESOURCE_FLAG_DRV_PRIV << 5)
102 #define SI_RESOURCE_FLAG_32BIT (PIPE_RESOURCE_FLAG_DRV_PRIV << 6)
106 /* Shader logging options: */
107 DBG_VS
= PIPE_SHADER_VERTEX
,
108 DBG_PS
= PIPE_SHADER_FRAGMENT
,
109 DBG_GS
= PIPE_SHADER_GEOMETRY
,
110 DBG_TCS
= PIPE_SHADER_TESS_CTRL
,
111 DBG_TES
= PIPE_SHADER_TESS_EVAL
,
112 DBG_CS
= PIPE_SHADER_COMPUTE
,
118 /* Shader compiler options the shader cache should be aware of: */
119 DBG_FS_CORRECT_DERIVS_AFTER_KILL
,
123 /* Shader compiler options (with no effect on the shader cache): */
126 DBG_MONOLITHIC_SHADERS
,
129 /* Information logging options: */
135 /* Driver options: */
142 /* 3D engine options: */
163 DBG_TEST_VMFAULT_SDMA
,
164 DBG_TEST_VMFAULT_SHADER
,
167 #define DBG_ALL_SHADERS (((1 << (DBG_CS + 1)) - 1))
168 #define DBG(name) (1ull << DBG_##name)
172 struct u_suballocator
;
175 struct pipe_screen b
;
176 struct radeon_winsys
*ws
;
177 struct disk_cache
*disk_shader_cache
;
179 struct radeon_info info
;
180 uint64_t debug_flags
;
181 char renderer_string
[100];
183 unsigned gs_table_depth
;
184 unsigned tess_offchip_block_dw_size
;
185 unsigned tess_offchip_ring_size
;
186 unsigned tess_factor_ring_size
;
187 unsigned vgt_hs_offchip_param
;
188 bool has_clear_state
;
189 bool has_distributed_tess
;
190 bool has_draw_indirect_multi
;
191 bool has_out_of_order_rast
;
192 bool assume_no_z_fights
;
193 bool commutative_blend_add
;
194 bool clear_db_cache_before_clear
;
195 bool has_msaa_sample_loc_bug
;
196 bool has_ls_vgpr_init_bug
;
199 bool llvm_has_working_vgpr_indexing
;
201 /* Whether shaders are monolithic (1-part) or separate (3-part). */
202 bool use_monolithic_shaders
;
204 bool has_rbplus
; /* if RB+ registers exist */
205 bool rbplus_allowed
; /* if RB+ is allowed */
206 bool dcc_msaa_allowed
;
207 bool cpdma_prefetch_writes_memory
;
209 struct slab_parent_pool pool_transfers
;
211 /* Texture filter settings. */
212 int force_aniso
; /* -1 = disabled */
214 /* Auxiliary context. Mainly used to initialize resources.
215 * It must be locked prior to using and flushed before unlocking. */
216 struct pipe_context
*aux_context
;
217 mtx_t aux_context_lock
;
219 /* This must be in the screen, because UE4 uses one context for
220 * compilation and another one for rendering.
222 unsigned num_compilations
;
223 /* Along with ST_DEBUG=precompile, this should show if applications
224 * are loading shaders on demand. This is a monotonic counter.
226 unsigned num_shaders_created
;
227 unsigned num_shader_cache_hits
;
229 /* GPU load thread. */
230 mtx_t gpu_load_mutex
;
231 thrd_t gpu_load_thread
;
232 union si_mmio_counters mmio_counters
;
233 volatile unsigned gpu_load_stop_thread
; /* bool */
235 /* Performance counters. */
236 struct si_perfcounters
*perfcounters
;
238 /* If pipe_screen wants to recompute and re-emit the framebuffer,
239 * sampler, and image states of all contexts, it should atomically
242 * Each context will compare this with its own last known value of
243 * the counter before drawing and re-emit the states accordingly.
245 unsigned dirty_tex_counter
;
247 /* Atomically increment this counter when an existing texture's
248 * metadata is enabled or disabled in a way that requires changing
249 * contexts' compressed texture binding masks.
251 unsigned compressed_colortex_counter
;
254 /* Context flags to set so that all writes from earlier jobs
255 * in the CP are seen by L2 clients.
259 /* Context flags to set so that all writes from earlier jobs
260 * that end in L2 are seen by CP.
265 mtx_t shader_parts_mutex
;
266 struct si_shader_part
*vs_prologs
;
267 struct si_shader_part
*tcs_epilogs
;
268 struct si_shader_part
*gs_prologs
;
269 struct si_shader_part
*ps_prologs
;
270 struct si_shader_part
*ps_epilogs
;
272 /* Shader cache in memory.
274 * Design & limitations:
275 * - The shader cache is per screen (= per process), never saved to
276 * disk, and skips redundant shader compilations from TGSI to bytecode.
277 * - It can only be used with one-variant-per-shader support, in which
278 * case only the main (typically middle) part of shaders is cached.
279 * - Only VS, TCS, TES, PS are cached, out of which only the hw VS
280 * variants of VS and TES are cached, so LS and ES aren't.
281 * - GS and CS aren't cached, but it's certainly possible to cache
284 mtx_t shader_cache_mutex
;
285 struct hash_table
*shader_cache
;
287 /* Shader compiler queue for multithreaded compilation. */
288 struct util_queue shader_compiler_queue
;
289 /* Use at most 3 normal compiler threads on quadcore and better.
290 * Hyperthreaded CPUs report the number of threads, but we want
291 * the number of cores. */
292 LLVMTargetMachineRef tm
[3]; /* used by the queue only */
294 struct util_queue shader_compiler_queue_low_priority
;
295 /* Use at most 2 low priority threads on quadcore and better.
296 * We want to minimize the impact on multithreaded Mesa. */
297 LLVMTargetMachineRef tm_low_priority
[2]; /* at most 2 threads */
300 struct si_blend_color
{
301 struct r600_atom atom
;
302 struct pipe_blend_color state
;
306 struct si_sampler_view
{
307 struct pipe_sampler_view base
;
308 /* [0..7] = image descriptor
309 * [4..7] = buffer descriptor */
311 uint32_t fmask_state
[8];
312 const struct legacy_surf_level
*base_level_info
;
315 bool is_stencil_sampler
;
317 bool dcc_incompatible
;
320 #define SI_SAMPLER_STATE_MAGIC 0x34f1c35a
322 struct si_sampler_state
{
327 uint32_t integer_val
[4];
328 uint32_t upgraded_depth_val
[4];
331 struct si_cs_shader_state
{
332 struct si_compute
*program
;
333 struct si_compute
*emitted_program
;
340 struct pipe_sampler_view
*views
[SI_NUM_SAMPLERS
];
341 struct si_sampler_state
*sampler_states
[SI_NUM_SAMPLERS
];
343 /* The i-th bit is set if that element is enabled (non-NULL resource). */
344 unsigned enabled_mask
;
345 uint32_t needs_depth_decompress_mask
;
346 uint32_t needs_color_decompress_mask
;
350 struct pipe_image_view views
[SI_NUM_IMAGES
];
351 uint32_t needs_color_decompress_mask
;
352 unsigned enabled_mask
;
355 struct si_framebuffer
{
356 struct r600_atom atom
;
357 struct pipe_framebuffer_state state
;
358 unsigned colorbuf_enabled_4bit
;
359 unsigned spi_shader_col_format
;
360 unsigned spi_shader_col_format_alpha
;
361 unsigned spi_shader_col_format_blend
;
362 unsigned spi_shader_col_format_blend_alpha
;
363 ubyte nr_samples
:5; /* at most 16xAA */
364 ubyte log_samples
:3; /* at most 4 = 16xAA */
365 ubyte compressed_cb_mask
;
366 ubyte uncompressed_cb_mask
;
368 ubyte color_is_int10
;
372 bool CB_has_shader_readable_metadata
;
373 bool DB_has_shader_readable_metadata
;
376 struct si_signed_scissor
{
384 struct r600_atom atom
;
386 struct pipe_scissor_state states
[SI_MAX_VIEWPORTS
];
389 struct si_viewports
{
390 struct r600_atom atom
;
392 unsigned depth_range_dirty_mask
;
393 struct pipe_viewport_state states
[SI_MAX_VIEWPORTS
];
394 struct si_signed_scissor as_scissor
[SI_MAX_VIEWPORTS
];
397 struct si_clip_state
{
398 struct r600_atom atom
;
399 struct pipe_clip_state state
;
403 struct si_sample_locs
{
404 struct r600_atom atom
;
408 struct si_sample_mask
{
409 struct r600_atom atom
;
410 uint16_t sample_mask
;
413 struct si_streamout_target
{
414 struct pipe_stream_output_target b
;
416 /* The buffer where BUFFER_FILLED_SIZE is stored. */
417 struct r600_resource
*buf_filled_size
;
418 unsigned buf_filled_size_offset
;
419 bool buf_filled_size_valid
;
421 unsigned stride_in_dw
;
424 struct si_streamout
{
425 struct r600_atom begin_atom
;
428 unsigned enabled_mask
;
429 unsigned num_targets
;
430 struct si_streamout_target
*targets
[PIPE_MAX_SO_BUFFERS
];
432 unsigned append_bitmask
;
435 /* External state which comes from the vertex shader,
436 * it must be set explicitly when binding a shader. */
437 uint16_t *stride_in_dw
;
438 unsigned enabled_stream_buffers_mask
; /* stream0 buffers0-3 in 4 LSB */
440 /* The state of VGT_STRMOUT_BUFFER_(CONFIG|EN). */
441 unsigned hw_enabled_mask
;
443 /* The state of VGT_STRMOUT_(CONFIG|EN). */
444 struct r600_atom enable_atom
;
445 bool streamout_enabled
;
446 bool prims_gen_query_enabled
;
447 int num_prims_gen_queries
;
450 /* A shader state consists of the shader selector, which is a constant state
451 * object shared by multiple contexts and shouldn't be modified, and
452 * the current shader variant selected for this context.
454 struct si_shader_ctx_state
{
455 struct si_shader_selector
*cso
;
456 struct si_shader
*current
;
459 #define SI_NUM_VGT_PARAM_KEY_BITS 12
460 #define SI_NUM_VGT_PARAM_STATES (1 << SI_NUM_VGT_PARAM_KEY_BITS)
462 /* The IA_MULTI_VGT_PARAM key used to index the table of precomputed values.
463 * Some fields are set by state-change calls, most are set by draw_vbo.
465 union si_vgt_param_key
{
467 #ifdef PIPE_ARCH_LITTLE_ENDIAN
469 unsigned uses_instancing
:1;
470 unsigned multi_instances_smaller_than_primgroup
:1;
471 unsigned primitive_restart
:1;
472 unsigned count_from_stream_output
:1;
473 unsigned line_stipple_enabled
:1;
474 unsigned uses_tess
:1;
475 unsigned tess_uses_prim_id
:1;
477 unsigned _pad
:32 - SI_NUM_VGT_PARAM_KEY_BITS
;
478 #else /* PIPE_ARCH_BIG_ENDIAN */
479 unsigned _pad
:32 - SI_NUM_VGT_PARAM_KEY_BITS
;
481 unsigned tess_uses_prim_id
:1;
482 unsigned uses_tess
:1;
483 unsigned line_stipple_enabled
:1;
484 unsigned count_from_stream_output
:1;
485 unsigned primitive_restart
:1;
486 unsigned multi_instances_smaller_than_primgroup
:1;
487 unsigned uses_instancing
:1;
494 struct si_texture_handle
498 struct pipe_sampler_view
*view
;
499 struct si_sampler_state sstate
;
502 struct si_image_handle
506 struct pipe_image_view view
;
510 struct pipe_reference reference
;
511 struct si_context
*ctx
;
512 struct radeon_saved_cs gfx
;
513 struct r600_resource
*trace_buf
;
516 unsigned gfx_last_dw
;
522 struct pipe_context b
; /* base class */
524 enum radeon_family family
;
525 enum chip_class chip_class
;
527 struct radeon_winsys
*ws
;
528 struct radeon_winsys_ctx
*ctx
;
529 struct radeon_winsys_cs
*gfx_cs
;
530 struct radeon_winsys_cs
*dma_cs
;
531 struct pipe_fence_handle
*last_gfx_fence
;
532 struct pipe_fence_handle
*last_sdma_fence
;
533 struct r600_resource
*eop_bug_scratch
;
534 struct u_upload_mgr
*cached_gtt_allocator
;
535 struct threaded_context
*tc
;
536 struct u_suballocator
*allocator_zeroed_memory
;
537 struct slab_child_pool pool_transfers
;
538 struct slab_child_pool pool_transfers_unsync
; /* for threaded_context */
539 struct pipe_device_reset_callback device_reset_callback
;
540 struct u_log_context
*log
;
541 void *query_result_shader
;
542 struct blitter_context
*blitter
;
543 void *custom_dsa_flush
;
544 void *custom_blend_resolve
;
545 void *custom_blend_fmask_decompress
;
546 void *custom_blend_eliminate_fastclear
;
547 void *custom_blend_dcc_decompress
;
549 void *vs_blit_pos_layered
;
551 void *vs_blit_color_layered
;
552 void *vs_blit_texcoord
;
553 struct si_screen
*screen
;
554 struct pipe_debug_callback debug
;
555 LLVMTargetMachineRef tm
; /* only non-threaded compilation */
556 struct si_shader_ctx_state fixed_func_tcs_shader
;
557 struct r600_resource
*wait_mem_scratch
;
558 unsigned wait_mem_number
;
559 uint16_t prefetch_L2_mask
;
561 bool gfx_flush_in_progress
:1;
562 bool compute_is_busy
:1;
564 unsigned num_gfx_cs_flushes
;
565 unsigned initial_gfx_cs_size
;
566 unsigned gpu_reset_counter
;
567 unsigned last_dirty_tex_counter
;
568 unsigned last_compressed_colortex_counter
;
569 unsigned last_num_draw_calls
;
570 unsigned flags
; /* flush flags */
571 /* Current unaccounted memory usage. */
575 /* Atoms (direct states). */
576 union si_state_atoms atoms
;
577 unsigned dirty_atoms
; /* mask */
578 /* PM4 states (precomputed immutable states) */
579 unsigned dirty_states
;
580 union si_state queued
;
581 union si_state emitted
;
583 /* Atom declarations. */
584 struct si_framebuffer framebuffer
;
585 struct si_sample_locs msaa_sample_locs
;
586 struct r600_atom db_render_state
;
587 struct r600_atom dpbb_state
;
588 struct r600_atom msaa_config
;
589 struct si_sample_mask sample_mask
;
590 struct r600_atom cb_render_state
;
591 unsigned last_cb_target_mask
;
592 struct si_blend_color blend_color
;
593 struct r600_atom clip_regs
;
594 struct si_clip_state clip_state
;
595 struct si_shader_data shader_pointers
;
596 struct si_stencil_ref stencil_ref
;
597 struct r600_atom spi_map
;
598 struct si_scissors scissors
;
599 struct si_streamout streamout
;
600 struct si_viewports viewports
;
602 /* Precomputed states. */
603 struct si_pm4_state
*init_config
;
604 struct si_pm4_state
*init_config_gs_rings
;
605 bool init_config_has_vgt_flush
;
606 struct si_pm4_state
*vgt_shader_config
[4];
609 struct si_shader_ctx_state ps_shader
;
610 struct si_shader_ctx_state gs_shader
;
611 struct si_shader_ctx_state vs_shader
;
612 struct si_shader_ctx_state tcs_shader
;
613 struct si_shader_ctx_state tes_shader
;
614 struct si_cs_shader_state cs_shader_state
;
616 /* shader information */
617 struct si_vertex_elements
*vertex_elements
;
618 unsigned sprite_coord_enable
;
620 bool do_update_shaders
;
622 /* vertex buffer descriptors */
623 uint32_t *vb_descriptors_gpu_list
;
624 struct r600_resource
*vb_descriptors_buffer
;
625 unsigned vb_descriptors_offset
;
627 /* shader descriptors */
628 struct si_descriptors descriptors
[SI_NUM_DESCS
];
629 unsigned descriptors_dirty
;
630 unsigned shader_pointers_dirty
;
631 unsigned shader_needs_decompress_mask
;
632 struct si_buffer_resources rw_buffers
;
633 struct si_buffer_resources const_and_shader_buffers
[SI_NUM_SHADERS
];
634 struct si_samplers samplers
[SI_NUM_SHADERS
];
635 struct si_images images
[SI_NUM_SHADERS
];
637 /* other shader resources */
638 struct pipe_constant_buffer null_const_buf
; /* used for set_constant_buffer(NULL) on CIK */
639 struct pipe_resource
*esgs_ring
;
640 struct pipe_resource
*gsvs_ring
;
641 struct pipe_resource
*tess_rings
;
642 union pipe_color_union
*border_color_table
; /* in CPU memory, any endian */
643 struct r600_resource
*border_color_buffer
;
644 union pipe_color_union
*border_color_map
; /* in VRAM (slow access), little endian */
645 unsigned border_color_count
;
646 unsigned num_vs_blit_sgprs
;
647 uint32_t vs_blit_sh_data
[SI_VS_BLIT_SGPRS_POS_TEXCOORD
];
649 /* Vertex and index buffers. */
650 bool vertex_buffers_dirty
;
651 bool vertex_buffer_pointer_dirty
;
652 struct pipe_vertex_buffer vertex_buffer
[SI_NUM_VERTEX_BUFFERS
];
654 /* MSAA config state. */
656 bool ps_uses_fbfetch
;
657 bool smoothing_enabled
;
659 /* DB render state. */
660 unsigned ps_db_shader_control
;
661 unsigned dbcb_copy_sample
;
662 bool dbcb_depth_copy_enabled
:1;
663 bool dbcb_stencil_copy_enabled
:1;
664 bool db_flush_depth_inplace
:1;
665 bool db_flush_stencil_inplace
:1;
666 bool db_depth_clear
:1;
667 bool db_depth_disable_expclear
:1;
668 bool db_stencil_clear
:1;
669 bool db_stencil_disable_expclear
:1;
670 bool occlusion_queries_disabled
:1;
671 bool generate_mipmap_for_depth
:1;
673 /* Emitted draw state. */
674 bool gs_tri_strip_adj_fix
:1;
677 int last_base_vertex
;
678 int last_start_instance
;
680 int last_sh_base_reg
;
681 int last_primitive_restart_en
;
682 int last_restart_index
;
683 int last_gs_out_prim
;
685 int last_multi_vgt_param
;
687 unsigned last_sc_line_stipple
;
688 unsigned current_vs_state
;
689 unsigned last_vs_state
;
690 enum pipe_prim_type current_rast_prim
; /* primitive type after TES, GS */
693 struct r600_atom scratch_state
;
694 struct r600_resource
*scratch_buffer
;
695 unsigned scratch_waves
;
696 unsigned spi_tmpring_size
;
698 struct r600_resource
*compute_scratch_buffer
;
700 /* Emitted derived tessellation state. */
701 /* Local shader (VS), or HS if LS-HS are merged. */
702 struct si_shader
*last_ls
;
703 struct si_shader_selector
*last_tcs
;
704 int last_num_tcs_input_cp
;
705 int last_tes_sh_base
;
706 bool last_tess_uses_primid
;
707 unsigned last_num_patches
;
711 struct si_saved_cs
*current_saved_cs
;
712 uint64_t dmesg_timestamp
;
713 unsigned apitrace_call_number
;
716 bool need_check_render_feedback
;
717 bool decompression_enabled
;
719 bool vs_writes_viewport_index
;
720 bool vs_disables_clipping_viewport
;
722 /* Precomputed IA_MULTI_VGT_PARAM */
723 union si_vgt_param_key ia_multi_vgt_param_key
;
724 unsigned ia_multi_vgt_param
[SI_NUM_VGT_PARAM_STATES
];
726 /* Bindless descriptors. */
727 struct si_descriptors bindless_descriptors
;
728 struct util_idalloc bindless_used_slots
;
729 unsigned num_bindless_descriptors
;
730 bool bindless_descriptors_dirty
;
731 bool graphics_bindless_pointer_dirty
;
732 bool compute_bindless_pointer_dirty
;
734 /* Allocated bindless handles */
735 struct hash_table
*tex_handles
;
736 struct hash_table
*img_handles
;
738 /* Resident bindless handles */
739 struct util_dynarray resident_tex_handles
;
740 struct util_dynarray resident_img_handles
;
742 /* Resident bindless handles which need decompression */
743 struct util_dynarray resident_tex_needs_color_decompress
;
744 struct util_dynarray resident_img_needs_color_decompress
;
745 struct util_dynarray resident_tex_needs_depth_decompress
;
748 bool uses_bindless_samplers
;
749 bool uses_bindless_images
;
751 /* MSAA sample locations.
752 * The first index is the sample index.
753 * The second index is the coordinate: X, Y. */
754 float sample_locations_1x
[1][2];
755 float sample_locations_2x
[2][2];
756 float sample_locations_4x
[4][2];
757 float sample_locations_8x
[8][2];
758 float sample_locations_16x
[16][2];
761 unsigned num_draw_calls
;
762 unsigned num_decompress_calls
;
763 unsigned num_mrt_draw_calls
;
764 unsigned num_prim_restart_calls
;
765 unsigned num_spill_draw_calls
;
766 unsigned num_compute_calls
;
767 unsigned num_spill_compute_calls
;
768 unsigned num_dma_calls
;
769 unsigned num_cp_dma_calls
;
770 unsigned num_vs_flushes
;
771 unsigned num_ps_flushes
;
772 unsigned num_cs_flushes
;
773 unsigned num_cb_cache_flushes
;
774 unsigned num_db_cache_flushes
;
775 unsigned num_L2_invalidates
;
776 unsigned num_L2_writebacks
;
777 unsigned num_resident_handles
;
778 uint64_t num_alloc_tex_transfer_bytes
;
779 unsigned last_tex_ps_draw_ratio
; /* for query */
782 /* Maintain the list of active queries for pausing between IBs. */
783 int num_occlusion_queries
;
784 int num_perfect_occlusion_queries
;
785 struct list_head active_queries
;
786 unsigned num_cs_dw_queries_suspend
;
788 /* Render condition. */
789 struct r600_atom render_cond_atom
;
790 struct pipe_query
*render_cond
;
791 unsigned render_cond_mode
;
792 bool render_cond_invert
;
793 bool render_cond_force_off
; /* for u_blitter */
795 /* Statistics gathering for the DCC enablement heuristic. It can't be
796 * in r600_texture because r600_texture can be shared by multiple
797 * contexts. This is for back buffers only. We shouldn't get too many
800 * X11 DRI3 rotates among a finite set of back buffers. They should
801 * all fit in this array. If they don't, separate DCC might never be
802 * enabled by DCC stat gathering.
805 struct r600_texture
*tex
;
806 /* Query queue: 0 = usually active, 1 = waiting, 2 = readback. */
807 struct pipe_query
*ps_stats
[3];
808 /* If all slots are used and another slot is needed,
809 * the least recently used slot is evicted based on this. */
810 int64_t last_use_timestamp
;
814 /* Copy one resource to another using async DMA. */
815 void (*dma_copy
)(struct pipe_context
*ctx
,
816 struct pipe_resource
*dst
,
818 unsigned dst_x
, unsigned dst_y
, unsigned dst_z
,
819 struct pipe_resource
*src
,
821 const struct pipe_box
*src_box
);
823 void (*dma_clear_buffer
)(struct si_context
*sctx
, struct pipe_resource
*dst
,
824 uint64_t offset
, uint64_t size
, unsigned value
);
828 void cik_init_sdma_functions(struct si_context
*sctx
);
831 enum si_blitter_op
/* bitmask */
833 SI_SAVE_TEXTURES
= 1,
834 SI_SAVE_FRAMEBUFFER
= 2,
835 SI_SAVE_FRAGMENT_STATE
= 4,
836 SI_DISABLE_RENDER_COND
= 8,
839 void si_blitter_begin(struct si_context
*sctx
, enum si_blitter_op op
);
840 void si_blitter_end(struct si_context
*sctx
);
841 void si_init_blit_functions(struct si_context
*sctx
);
842 void si_decompress_textures(struct si_context
*sctx
, unsigned shader_mask
);
843 void si_resource_copy_region(struct pipe_context
*ctx
,
844 struct pipe_resource
*dst
,
846 unsigned dstx
, unsigned dsty
, unsigned dstz
,
847 struct pipe_resource
*src
,
849 const struct pipe_box
*src_box
);
850 void si_decompress_dcc(struct si_context
*sctx
, struct r600_texture
*rtex
);
851 void si_blit_decompress_depth(struct pipe_context
*ctx
,
852 struct r600_texture
*texture
,
853 struct r600_texture
*staging
,
854 unsigned first_level
, unsigned last_level
,
855 unsigned first_layer
, unsigned last_layer
,
856 unsigned first_sample
, unsigned last_sample
);
859 bool si_rings_is_buffer_referenced(struct si_context
*sctx
,
860 struct pb_buffer
*buf
,
861 enum radeon_bo_usage usage
);
862 void *si_buffer_map_sync_with_rings(struct si_context
*sctx
,
863 struct r600_resource
*resource
,
865 void si_init_resource_fields(struct si_screen
*sscreen
,
866 struct r600_resource
*res
,
867 uint64_t size
, unsigned alignment
);
868 bool si_alloc_resource(struct si_screen
*sscreen
,
869 struct r600_resource
*res
);
870 struct pipe_resource
*si_aligned_buffer_create(struct pipe_screen
*screen
,
875 void si_replace_buffer_storage(struct pipe_context
*ctx
,
876 struct pipe_resource
*dst
,
877 struct pipe_resource
*src
);
878 void si_init_screen_buffer_functions(struct si_screen
*sscreen
);
879 void si_init_buffer_functions(struct si_context
*sctx
);
882 void vi_dcc_clear_level(struct si_context
*sctx
,
883 struct r600_texture
*rtex
,
884 unsigned level
, unsigned clear_value
);
885 void si_init_clear_functions(struct si_context
*sctx
);
888 #define SI_CPDMA_SKIP_CHECK_CS_SPACE (1 << 0) /* don't call need_cs_space */
889 #define SI_CPDMA_SKIP_SYNC_AFTER (1 << 1) /* don't wait for DMA after the copy */
890 #define SI_CPDMA_SKIP_SYNC_BEFORE (1 << 2) /* don't wait for DMA before the copy (RAW hazards) */
891 #define SI_CPDMA_SKIP_GFX_SYNC (1 << 3) /* don't flush caches and don't wait for PS/CS */
892 #define SI_CPDMA_SKIP_BO_LIST_UPDATE (1 << 4) /* don't update the BO list */
893 #define SI_CPDMA_SKIP_ALL (SI_CPDMA_SKIP_CHECK_CS_SPACE | \
894 SI_CPDMA_SKIP_SYNC_AFTER | \
895 SI_CPDMA_SKIP_SYNC_BEFORE | \
896 SI_CPDMA_SKIP_GFX_SYNC | \
897 SI_CPDMA_SKIP_BO_LIST_UPDATE)
900 SI_COHERENCY_NONE
, /* no cache flushes needed */
902 SI_COHERENCY_CB_META
,
905 void si_cp_dma_wait_for_idle(struct si_context
*sctx
);
906 void si_clear_buffer(struct si_context
*sctx
, struct pipe_resource
*dst
,
907 uint64_t offset
, uint64_t size
, unsigned value
,
908 enum si_coherency coher
);
909 void si_copy_buffer(struct si_context
*sctx
,
910 struct pipe_resource
*dst
, struct pipe_resource
*src
,
911 uint64_t dst_offset
, uint64_t src_offset
, unsigned size
,
912 unsigned user_flags
);
913 void cik_prefetch_TC_L2_async(struct si_context
*sctx
, struct pipe_resource
*buf
,
914 uint64_t offset
, unsigned size
);
915 void cik_emit_prefetch_L2(struct si_context
*sctx
, bool vertex_stage_only
);
916 void si_init_cp_dma_functions(struct si_context
*sctx
);
919 void si_save_cs(struct radeon_winsys
*ws
, struct radeon_winsys_cs
*cs
,
920 struct radeon_saved_cs
*saved
, bool get_buffer_list
);
921 void si_clear_saved_cs(struct radeon_saved_cs
*saved
);
922 void si_destroy_saved_cs(struct si_saved_cs
*scs
);
923 void si_auto_log_cs(void *data
, struct u_log_context
*log
);
924 void si_log_hw_flush(struct si_context
*sctx
);
925 void si_log_draw_state(struct si_context
*sctx
, struct u_log_context
*log
);
926 void si_log_compute_state(struct si_context
*sctx
, struct u_log_context
*log
);
927 void si_init_debug_functions(struct si_context
*sctx
);
928 void si_check_vm_faults(struct si_context
*sctx
,
929 struct radeon_saved_cs
*saved
, enum ring_type ring
);
930 bool si_replace_shader(unsigned num
, struct ac_shader_binary
*binary
);
933 void si_init_dma_functions(struct si_context
*sctx
);
936 void si_need_dma_space(struct si_context
*ctx
, unsigned num_dw
,
937 struct r600_resource
*dst
, struct r600_resource
*src
);
938 void si_flush_dma_cs(struct si_context
*ctx
, unsigned flags
,
939 struct pipe_fence_handle
**fence
);
940 void si_screen_clear_buffer(struct si_screen
*sscreen
, struct pipe_resource
*dst
,
941 uint64_t offset
, uint64_t size
, unsigned value
);
944 void si_gfx_write_event_eop(struct si_context
*ctx
,
945 unsigned event
, unsigned event_flags
,
947 struct r600_resource
*buf
, uint64_t va
,
948 uint32_t new_fence
, unsigned query_type
);
949 unsigned si_gfx_write_fence_dwords(struct si_screen
*screen
);
950 void si_gfx_wait_fence(struct si_context
*ctx
,
951 uint64_t va
, uint32_t ref
, uint32_t mask
);
952 void si_init_fence_functions(struct si_context
*ctx
);
953 void si_init_screen_fence_functions(struct si_screen
*screen
);
954 struct pipe_fence_handle
*si_create_fence(struct pipe_context
*ctx
,
955 struct tc_unflushed_batch_token
*tc_token
);
958 const char *si_get_family_name(const struct si_screen
*sscreen
);
959 void si_init_screen_get_functions(struct si_screen
*sscreen
);
962 void si_flush_gfx_cs(struct si_context
*ctx
, unsigned flags
,
963 struct pipe_fence_handle
**fence
);
964 void si_begin_new_gfx_cs(struct si_context
*ctx
);
965 void si_need_gfx_cs_space(struct si_context
*ctx
);
967 /* r600_gpu_load.c */
968 void si_gpu_load_kill_thread(struct si_screen
*sscreen
);
969 uint64_t si_begin_counter(struct si_screen
*sscreen
, unsigned type
);
970 unsigned si_end_counter(struct si_screen
*sscreen
, unsigned type
,
974 void si_init_compute_functions(struct si_context
*sctx
);
976 /* si_perfcounters.c */
977 void si_init_perfcounters(struct si_screen
*screen
);
980 bool si_check_device_reset(struct si_context
*sctx
);
983 void si_init_screen_query_functions(struct si_screen
*sscreen
);
984 void si_init_query_functions(struct si_context
*sctx
);
985 void si_suspend_queries(struct si_context
*sctx
);
986 void si_resume_queries(struct si_context
*sctx
);
989 void si_test_dma(struct si_screen
*sscreen
);
992 struct pipe_video_codec
*si_uvd_create_decoder(struct pipe_context
*context
,
993 const struct pipe_video_codec
*templ
);
995 struct pipe_video_buffer
*si_video_buffer_create(struct pipe_context
*pipe
,
996 const struct pipe_video_buffer
*tmpl
);
999 void si_update_vs_viewport_state(struct si_context
*ctx
);
1000 void si_init_viewport_functions(struct si_context
*ctx
);
1002 /* r600_texture.c */
1003 bool si_prepare_for_dma_blit(struct si_context
*sctx
,
1004 struct r600_texture
*rdst
,
1005 unsigned dst_level
, unsigned dstx
,
1006 unsigned dsty
, unsigned dstz
,
1007 struct r600_texture
*rsrc
,
1009 const struct pipe_box
*src_box
);
1010 void si_texture_get_fmask_info(struct si_screen
*sscreen
,
1011 struct r600_texture
*rtex
,
1012 unsigned nr_samples
,
1013 struct r600_fmask_info
*out
);
1014 void si_texture_get_cmask_info(struct si_screen
*sscreen
,
1015 struct r600_texture
*rtex
,
1016 struct r600_cmask_info
*out
);
1017 void si_eliminate_fast_color_clear(struct si_context
*sctx
,
1018 struct r600_texture
*rtex
);
1019 void si_texture_discard_cmask(struct si_screen
*sscreen
,
1020 struct r600_texture
*rtex
);
1021 bool si_init_flushed_depth_texture(struct pipe_context
*ctx
,
1022 struct pipe_resource
*texture
,
1023 struct r600_texture
**staging
);
1024 void si_print_texture_info(struct si_screen
*sscreen
,
1025 struct r600_texture
*rtex
, struct u_log_context
*log
);
1026 struct pipe_resource
*si_texture_create(struct pipe_screen
*screen
,
1027 const struct pipe_resource
*templ
);
1028 bool vi_dcc_formats_compatible(enum pipe_format format1
,
1029 enum pipe_format format2
);
1030 bool vi_dcc_formats_are_incompatible(struct pipe_resource
*tex
,
1032 enum pipe_format view_format
);
1033 void vi_disable_dcc_if_incompatible_format(struct si_context
*sctx
,
1034 struct pipe_resource
*tex
,
1036 enum pipe_format view_format
);
1037 struct pipe_surface
*si_create_surface_custom(struct pipe_context
*pipe
,
1038 struct pipe_resource
*texture
,
1039 const struct pipe_surface
*templ
,
1040 unsigned width0
, unsigned height0
,
1041 unsigned width
, unsigned height
);
1042 unsigned si_translate_colorswap(enum pipe_format format
, bool do_endian_swap
);
1043 void vi_separate_dcc_try_enable(struct si_context
*sctx
,
1044 struct r600_texture
*tex
);
1045 void vi_separate_dcc_start_query(struct si_context
*sctx
,
1046 struct r600_texture
*tex
);
1047 void vi_separate_dcc_stop_query(struct si_context
*sctx
,
1048 struct r600_texture
*tex
);
1049 void vi_separate_dcc_process_and_reset_stats(struct pipe_context
*ctx
,
1050 struct r600_texture
*tex
);
1051 bool si_texture_disable_dcc(struct si_context
*sctx
,
1052 struct r600_texture
*rtex
);
1053 void si_init_screen_texture_functions(struct si_screen
*sscreen
);
1054 void si_init_context_texture_functions(struct si_context
*sctx
);
1062 si_context_add_resource_size(struct si_context
*sctx
, struct pipe_resource
*r
)
1064 struct r600_resource
*res
= (struct r600_resource
*)r
;
1067 /* Add memory usage for need_gfx_cs_space */
1068 sctx
->vram
+= res
->vram_usage
;
1069 sctx
->gtt
+= res
->gart_usage
;
1074 si_invalidate_draw_sh_constants(struct si_context
*sctx
)
1076 sctx
->last_base_vertex
= SI_BASE_VERTEX_UNKNOWN
;
1080 si_set_atom_dirty(struct si_context
*sctx
,
1081 struct r600_atom
*atom
, bool dirty
)
1083 unsigned bit
= 1 << atom
->id
;
1086 sctx
->dirty_atoms
|= bit
;
1088 sctx
->dirty_atoms
&= ~bit
;
1092 si_is_atom_dirty(struct si_context
*sctx
,
1093 struct r600_atom
*atom
)
1095 unsigned bit
= 1 << atom
->id
;
1097 return sctx
->dirty_atoms
& bit
;
1101 si_mark_atom_dirty(struct si_context
*sctx
,
1102 struct r600_atom
*atom
)
1104 si_set_atom_dirty(sctx
, atom
, true);
1107 static inline struct si_shader_ctx_state
*si_get_vs(struct si_context
*sctx
)
1109 if (sctx
->gs_shader
.cso
)
1110 return &sctx
->gs_shader
;
1111 if (sctx
->tes_shader
.cso
)
1112 return &sctx
->tes_shader
;
1114 return &sctx
->vs_shader
;
1117 static inline struct tgsi_shader_info
*si_get_vs_info(struct si_context
*sctx
)
1119 struct si_shader_ctx_state
*vs
= si_get_vs(sctx
);
1121 return vs
->cso
? &vs
->cso
->info
: NULL
;
1124 static inline struct si_shader
* si_get_vs_state(struct si_context
*sctx
)
1126 if (sctx
->gs_shader
.cso
)
1127 return sctx
->gs_shader
.cso
->gs_copy_shader
;
1129 struct si_shader_ctx_state
*vs
= si_get_vs(sctx
);
1130 return vs
->current
? vs
->current
: NULL
;
1133 static inline bool si_can_dump_shader(struct si_screen
*sscreen
,
1136 return sscreen
->debug_flags
& (1 << processor
);
1139 static inline bool si_extra_shader_checks(struct si_screen
*sscreen
,
1142 return (sscreen
->debug_flags
& DBG(CHECK_IR
)) ||
1143 si_can_dump_shader(sscreen
, processor
);
1146 static inline bool si_get_strmout_en(struct si_context
*sctx
)
1148 return sctx
->streamout
.streamout_enabled
||
1149 sctx
->streamout
.prims_gen_query_enabled
;
1152 static inline unsigned
1153 si_optimal_tcc_alignment(struct si_context
*sctx
, unsigned upload_size
)
1155 unsigned alignment
, tcc_cache_line_size
;
1157 /* If the upload size is less than the cache line size (e.g. 16, 32),
1158 * the whole thing will fit into a cache line if we align it to its size.
1159 * The idea is that multiple small uploads can share a cache line.
1160 * If the upload size is greater, align it to the cache line size.
1162 alignment
= util_next_power_of_two(upload_size
);
1163 tcc_cache_line_size
= sctx
->screen
->info
.tcc_cache_line_size
;
1164 return MIN2(alignment
, tcc_cache_line_size
);
1168 si_saved_cs_reference(struct si_saved_cs
**dst
, struct si_saved_cs
*src
)
1170 if (pipe_reference(&(*dst
)->reference
, &src
->reference
))
1171 si_destroy_saved_cs(*dst
);
1177 si_make_CB_shader_coherent(struct si_context
*sctx
, unsigned num_samples
,
1178 bool shaders_read_metadata
)
1180 sctx
->flags
|= SI_CONTEXT_FLUSH_AND_INV_CB
|
1181 SI_CONTEXT_INV_VMEM_L1
;
1183 if (sctx
->chip_class
>= GFX9
) {
1184 /* Single-sample color is coherent with shaders on GFX9, but
1185 * L2 metadata must be flushed if shaders read metadata.
1188 if (num_samples
>= 2)
1189 sctx
->flags
|= SI_CONTEXT_INV_GLOBAL_L2
;
1190 else if (shaders_read_metadata
)
1191 sctx
->flags
|= SI_CONTEXT_INV_L2_METADATA
;
1194 sctx
->flags
|= SI_CONTEXT_INV_GLOBAL_L2
;
1199 si_make_DB_shader_coherent(struct si_context
*sctx
, unsigned num_samples
,
1200 bool include_stencil
, bool shaders_read_metadata
)
1202 sctx
->flags
|= SI_CONTEXT_FLUSH_AND_INV_DB
|
1203 SI_CONTEXT_INV_VMEM_L1
;
1205 if (sctx
->chip_class
>= GFX9
) {
1206 /* Single-sample depth (not stencil) is coherent with shaders
1207 * on GFX9, but L2 metadata must be flushed if shaders read
1210 if (num_samples
>= 2 || include_stencil
)
1211 sctx
->flags
|= SI_CONTEXT_INV_GLOBAL_L2
;
1212 else if (shaders_read_metadata
)
1213 sctx
->flags
|= SI_CONTEXT_INV_L2_METADATA
;
1216 sctx
->flags
|= SI_CONTEXT_INV_GLOBAL_L2
;
1221 si_can_sample_zs(struct r600_texture
*tex
, bool stencil_sampler
)
1223 return (stencil_sampler
&& tex
->can_sample_s
) ||
1224 (!stencil_sampler
&& tex
->can_sample_z
);
1228 si_htile_enabled(struct r600_texture
*tex
, unsigned level
)
1230 return tex
->htile_offset
&& level
== 0;
1234 vi_tc_compat_htile_enabled(struct r600_texture
*tex
, unsigned level
)
1236 assert(!tex
->tc_compatible_htile
|| tex
->htile_offset
);
1237 return tex
->tc_compatible_htile
&& level
== 0;
1240 static inline unsigned si_get_ps_iter_samples(struct si_context
*sctx
)
1242 if (sctx
->ps_uses_fbfetch
)
1243 return sctx
->framebuffer
.nr_samples
;
1245 return sctx
->ps_iter_samples
;
1248 static inline unsigned si_get_total_colormask(struct si_context
*sctx
)
1250 if (sctx
->queued
.named
.rasterizer
->rasterizer_discard
)
1253 struct si_shader_selector
*ps
= sctx
->ps_shader
.cso
;
1257 unsigned colormask
= sctx
->framebuffer
.colorbuf_enabled_4bit
&
1258 sctx
->queued
.named
.blend
->cb_target_mask
;
1260 if (!ps
->info
.properties
[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
])
1261 colormask
&= ps
->colors_written_4bit
;
1262 else if (!ps
->colors_written_4bit
)
1263 colormask
= 0; /* color0 writes all cbufs, but it's not written */
1269 * Return true if there is enough memory in VRAM and GTT for the buffers
1272 * \param vram VRAM memory size not added to the buffer list yet
1273 * \param gtt GTT memory size not added to the buffer list yet
1276 radeon_cs_memory_below_limit(struct si_screen
*screen
,
1277 struct radeon_winsys_cs
*cs
,
1278 uint64_t vram
, uint64_t gtt
)
1280 vram
+= cs
->used_vram
;
1281 gtt
+= cs
->used_gart
;
1283 /* Anything that goes above the VRAM size should go to GTT. */
1284 if (vram
> screen
->info
.vram_size
)
1285 gtt
+= vram
- screen
->info
.vram_size
;
1287 /* Now we just need to check if we have enough GTT. */
1288 return gtt
< screen
->info
.gart_size
* 0.7;
1292 * Add a buffer to the buffer list for the given command stream (CS).
1294 * All buffers used by a CS must be added to the list. This tells the kernel
1295 * driver which buffers are used by GPU commands. Other buffers can
1296 * be swapped out (not accessible) during execution.
1298 * The buffer list becomes empty after every context flush and must be
1301 static inline void radeon_add_to_buffer_list(struct si_context
*sctx
,
1302 struct radeon_winsys_cs
*cs
,
1303 struct r600_resource
*rbo
,
1304 enum radeon_bo_usage usage
,
1305 enum radeon_bo_priority priority
)
1308 sctx
->ws
->cs_add_buffer(
1310 (enum radeon_bo_usage
)(usage
| RADEON_USAGE_SYNCHRONIZED
),
1311 rbo
->domains
, priority
);
1315 * Same as above, but also checks memory usage and flushes the context
1318 * When this SHOULD NOT be used:
1320 * - if si_context_add_resource_size has been called for the buffer
1321 * followed by *_need_cs_space for checking the memory usage
1323 * - if si_need_dma_space has been called for the buffer
1325 * - when emitting state packets and draw packets (because preceding packets
1326 * can't be re-emitted at that point)
1328 * - if shader resource "enabled_mask" is not up-to-date or there is
1329 * a different constraint disallowing a context flush
1332 radeon_add_to_gfx_buffer_list_check_mem(struct si_context
*sctx
,
1333 struct r600_resource
*rbo
,
1334 enum radeon_bo_usage usage
,
1335 enum radeon_bo_priority priority
,
1339 !radeon_cs_memory_below_limit(sctx
->screen
, sctx
->gfx_cs
,
1340 sctx
->vram
+ rbo
->vram_usage
,
1341 sctx
->gtt
+ rbo
->gart_usage
))
1342 si_flush_gfx_cs(sctx
, PIPE_FLUSH_ASYNC
, NULL
);
1344 radeon_add_to_buffer_list(sctx
, sctx
->gfx_cs
, rbo
, usage
, priority
);
1347 #define PRINT_ERR(fmt, args...) \
1348 fprintf(stderr, "EE %s:%d %s - " fmt, __FILE__, __LINE__, __func__, ##args)