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