Path: blob/21.2-virgl/src/gallium/drivers/radeonsi/si_state.h
4570 views
/*1* Copyright 2012 Advanced Micro Devices, Inc.2* All Rights Reserved.3*4* Permission is hereby granted, free of charge, to any person obtaining a5* copy of this software and associated documentation files (the "Software"),6* to deal in the Software without restriction, including without limitation7* on the rights to use, copy, modify, merge, publish, distribute, sub8* license, and/or sell copies of the Software, and to permit persons to whom9* the Software is furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice (including the next12* paragraph) shall be included in all copies or substantial portions of the13* Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL18* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,19* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR20* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE21* USE OR OTHER DEALINGS IN THE SOFTWARE.22*/2324#ifndef SI_STATE_H25#define SI_STATE_H2627#include "pipebuffer/pb_slab.h"28#include "si_pm4.h"29#include "util/u_blitter.h"3031#ifdef __cplusplus32extern "C" {33#endif3435#define SI_NUM_GRAPHICS_SHADERS (PIPE_SHADER_TESS_EVAL + 1)36#define SI_NUM_SHADERS (PIPE_SHADER_COMPUTE + 1)3738#define SI_NUM_VERTEX_BUFFERS SI_MAX_ATTRIBS39#define SI_NUM_SAMPLERS 32 /* OpenGL textures units per shader */40#define SI_NUM_CONST_BUFFERS 1641#define SI_NUM_IMAGES 1642#define SI_NUM_IMAGE_SLOTS (SI_NUM_IMAGES * 2) /* the second half are FMASK slots */43#define SI_NUM_SHADER_BUFFERS 324445struct si_screen;46struct si_shader;47struct si_shader_ctx_state;48struct si_shader_selector;49struct si_texture;50struct si_qbo_state;5152struct si_state_blend {53struct si_pm4_state pm4;54uint32_t cb_target_mask;55/* Set 0xf or 0x0 (4 bits) per render target if the following is56* true. ANDed with spi_shader_col_format.57*/58unsigned cb_target_enabled_4bit;59unsigned blend_enable_4bit;60unsigned need_src_alpha_4bit;61unsigned commutative_4bit;62unsigned dcc_msaa_corruption_4bit;63bool alpha_to_coverage : 1;64bool alpha_to_one : 1;65bool dual_src_blend : 1;66bool logicop_enable : 1;67bool allows_noop_optimization : 1;68};6970struct si_state_rasterizer {71struct si_pm4_state pm4;72/* poly offset states for 16-bit, 24-bit, and 32-bit zbuffers */73struct si_pm4_state *pm4_poly_offset;74unsigned pa_sc_line_stipple;75unsigned pa_cl_clip_cntl;76float line_width;77float max_point_size;78unsigned ngg_cull_flags : 8;79unsigned ngg_cull_flags_y_inverted : 8;80unsigned sprite_coord_enable : 8;81unsigned clip_plane_enable : 8;82unsigned half_pixel_center : 1;83unsigned flatshade : 1;84unsigned flatshade_first : 1;85unsigned two_side : 1;86unsigned multisample_enable : 1;87unsigned force_persample_interp : 1;88unsigned line_stipple_enable : 1;89unsigned poly_stipple_enable : 1;90unsigned line_smooth : 1;91unsigned poly_smooth : 1;92unsigned uses_poly_offset : 1;93unsigned clamp_fragment_color : 1;94unsigned clamp_vertex_color : 1;95unsigned rasterizer_discard : 1;96unsigned scissor_enable : 1;97unsigned clip_halfz : 1;98unsigned cull_front : 1;99unsigned cull_back : 1;100unsigned depth_clamp_any : 1;101unsigned provoking_vertex_first : 1;102unsigned polygon_mode_enabled : 1;103unsigned polygon_mode_is_lines : 1;104unsigned polygon_mode_is_points : 1;105};106107struct si_dsa_stencil_ref_part {108uint8_t valuemask[2];109uint8_t writemask[2];110};111112struct si_dsa_order_invariance {113/** Whether the final result in Z/S buffers is guaranteed to be114* invariant under changes to the order in which fragments arrive. */115bool zs : 1;116117/** Whether the set of fragments that pass the combined Z/S test is118* guaranteed to be invariant under changes to the order in which119* fragments arrive. */120bool pass_set : 1;121122/** Whether the last fragment that passes the combined Z/S test at each123* sample is guaranteed to be invariant under changes to the order in124* which fragments arrive. */125bool pass_last : 1;126};127128struct si_state_dsa {129struct si_pm4_state pm4;130struct si_dsa_stencil_ref_part stencil_ref;131132/* 0 = without stencil buffer, 1 = when both Z and S buffers are present */133struct si_dsa_order_invariance order_invariance[2];134135ubyte alpha_func : 3;136bool depth_enabled : 1;137bool depth_write_enabled : 1;138bool stencil_enabled : 1;139bool stencil_write_enabled : 1;140bool db_can_write : 1;141};142143struct si_stencil_ref {144struct pipe_stencil_ref state;145struct si_dsa_stencil_ref_part dsa_part;146};147148struct si_vertex_elements {149struct si_resource *instance_divisor_factor_buffer;150uint32_t rsrc_word3[SI_MAX_ATTRIBS];151uint16_t src_offset[SI_MAX_ATTRIBS];152uint8_t fix_fetch[SI_MAX_ATTRIBS];153uint8_t format_size[SI_MAX_ATTRIBS];154uint8_t vertex_buffer_index[SI_MAX_ATTRIBS];155156/* Bitmask of elements that always need a fixup to be applied. */157uint16_t fix_fetch_always;158159/* Bitmask of elements whose fetch should always be opencoded. */160uint16_t fix_fetch_opencode;161162/* Bitmask of elements which need to be opencoded if the vertex buffer163* is unaligned. */164uint16_t fix_fetch_unaligned;165166/* For elements in fix_fetch_unaligned: whether the effective167* element load size as seen by the hardware is a dword (as opposed168* to a short).169*/170uint16_t hw_load_is_dword;171172/* Bitmask of vertex buffers requiring alignment check */173uint16_t vb_alignment_check_mask;174175uint8_t count;176bool uses_instance_divisors;177178uint16_t first_vb_use_mask;179/* Vertex buffer descriptor list size aligned for optimal prefetch. */180uint16_t vb_desc_list_alloc_size;181uint16_t instance_divisor_is_one; /* bitmask of inputs */182uint16_t instance_divisor_is_fetched; /* bitmask of inputs */183};184185union si_state {186struct si_state_named {187struct si_state_blend *blend;188struct si_state_rasterizer *rasterizer;189struct si_state_dsa *dsa;190struct si_pm4_state *poly_offset;191struct si_pm4_state *ls;192struct si_pm4_state *hs;193struct si_pm4_state *es;194struct si_pm4_state *gs;195struct si_pm4_state *vgt_shader_config;196struct si_pm4_state *vs;197struct si_pm4_state *ps;198} named;199struct si_pm4_state *array[sizeof(struct si_state_named) / sizeof(struct si_pm4_state *)];200};201202#define SI_STATE_IDX(name) (offsetof(union si_state, named.name) / sizeof(struct si_pm4_state *))203#define SI_STATE_BIT(name) (1 << SI_STATE_IDX(name))204#define SI_NUM_STATES (sizeof(union si_state) / sizeof(struct si_pm4_state *))205206static inline unsigned si_states_that_always_roll_context(void)207{208return (SI_STATE_BIT(blend) | SI_STATE_BIT(rasterizer) | SI_STATE_BIT(dsa) |209SI_STATE_BIT(poly_offset) | SI_STATE_BIT(vgt_shader_config));210}211212union si_state_atoms {213struct si_atoms_s {214/* The order matters. */215struct si_atom render_cond;216struct si_atom streamout_begin;217struct si_atom streamout_enable; /* must be after streamout_begin */218struct si_atom framebuffer;219struct si_atom msaa_sample_locs;220struct si_atom db_render_state;221struct si_atom dpbb_state;222struct si_atom msaa_config;223struct si_atom sample_mask;224struct si_atom cb_render_state;225struct si_atom blend_color;226struct si_atom clip_regs;227struct si_atom clip_state;228struct si_atom shader_pointers;229struct si_atom guardband;230struct si_atom scissors;231struct si_atom viewports;232struct si_atom stencil_ref;233struct si_atom spi_map;234struct si_atom scratch_state;235struct si_atom window_rectangles;236struct si_atom shader_query;237struct si_atom ngg_cull_state;238} s;239struct si_atom array[sizeof(struct si_atoms_s) / sizeof(struct si_atom)];240};241242#define SI_ATOM_BIT(name) (1 << (offsetof(union si_state_atoms, s.name) / sizeof(struct si_atom)))243#define SI_NUM_ATOMS (sizeof(union si_state_atoms) / sizeof(struct si_atom))244245static inline unsigned si_atoms_that_always_roll_context(void)246{247return (SI_ATOM_BIT(streamout_begin) | SI_ATOM_BIT(streamout_enable) | SI_ATOM_BIT(framebuffer) |248SI_ATOM_BIT(msaa_sample_locs) | SI_ATOM_BIT(sample_mask) | SI_ATOM_BIT(blend_color) |249SI_ATOM_BIT(clip_state) | SI_ATOM_BIT(scissors) | SI_ATOM_BIT(viewports) |250SI_ATOM_BIT(stencil_ref) | SI_ATOM_BIT(scratch_state) | SI_ATOM_BIT(window_rectangles));251}252253struct si_shader_data {254uint32_t sh_base[SI_NUM_SHADERS];255};256257#define SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK \258(S_02881C_USE_VTX_POINT_SIZE(1) | S_02881C_USE_VTX_EDGE_FLAG(1) | \259S_02881C_USE_VTX_RENDER_TARGET_INDX(1) | S_02881C_USE_VTX_VIEWPORT_INDX(1) | \260S_02881C_VS_OUT_MISC_VEC_ENA(1) | S_02881C_VS_OUT_MISC_SIDE_BUS_ENA(1) | \261S_02881C_USE_VTX_VRS_RATE(1))262263/* The list of registers whose emitted values are remembered by si_context. */264enum si_tracked_reg265{266SI_TRACKED_DB_RENDER_CONTROL, /* 2 consecutive registers */267SI_TRACKED_DB_COUNT_CONTROL,268269SI_TRACKED_DB_RENDER_OVERRIDE2,270SI_TRACKED_DB_SHADER_CONTROL,271272SI_TRACKED_CB_TARGET_MASK,273SI_TRACKED_CB_DCC_CONTROL,274275SI_TRACKED_SX_PS_DOWNCONVERT, /* 3 consecutive registers */276SI_TRACKED_SX_BLEND_OPT_EPSILON,277SI_TRACKED_SX_BLEND_OPT_CONTROL,278279SI_TRACKED_PA_SC_LINE_CNTL, /* 2 consecutive registers */280SI_TRACKED_PA_SC_AA_CONFIG,281282SI_TRACKED_DB_EQAA,283SI_TRACKED_PA_SC_MODE_CNTL_1,284285SI_TRACKED_PA_SU_PRIM_FILTER_CNTL,286SI_TRACKED_PA_SU_SMALL_PRIM_FILTER_CNTL,287288SI_TRACKED_PA_CL_VS_OUT_CNTL__VS, /* set with SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK*/289SI_TRACKED_PA_CL_VS_OUT_CNTL__CL, /* set with ~SI_TRACKED_PA_CL_VS_OUT_CNTL__VS_MASK */290SI_TRACKED_PA_CL_CLIP_CNTL,291292SI_TRACKED_PA_SC_BINNER_CNTL_0,293294SI_TRACKED_DB_VRS_OVERRIDE_CNTL,295296SI_TRACKED_PA_CL_GB_VERT_CLIP_ADJ, /* 4 consecutive registers */297SI_TRACKED_PA_CL_GB_VERT_DISC_ADJ,298SI_TRACKED_PA_CL_GB_HORZ_CLIP_ADJ,299SI_TRACKED_PA_CL_GB_HORZ_DISC_ADJ,300301SI_TRACKED_PA_SU_HARDWARE_SCREEN_OFFSET,302SI_TRACKED_PA_SU_VTX_CNTL,303304SI_TRACKED_PA_SC_CLIPRECT_RULE,305306SI_TRACKED_PA_SC_LINE_STIPPLE,307308SI_TRACKED_VGT_ESGS_RING_ITEMSIZE,309310SI_TRACKED_VGT_GSVS_RING_OFFSET_1, /* 3 consecutive registers */311SI_TRACKED_VGT_GSVS_RING_OFFSET_2,312SI_TRACKED_VGT_GSVS_RING_OFFSET_3,313314SI_TRACKED_VGT_GSVS_RING_ITEMSIZE,315SI_TRACKED_VGT_GS_MAX_VERT_OUT,316317SI_TRACKED_VGT_GS_VERT_ITEMSIZE, /* 4 consecutive registers */318SI_TRACKED_VGT_GS_VERT_ITEMSIZE_1,319SI_TRACKED_VGT_GS_VERT_ITEMSIZE_2,320SI_TRACKED_VGT_GS_VERT_ITEMSIZE_3,321322SI_TRACKED_VGT_GS_INSTANCE_CNT,323SI_TRACKED_VGT_GS_ONCHIP_CNTL,324SI_TRACKED_VGT_GS_MAX_PRIMS_PER_SUBGROUP,325SI_TRACKED_VGT_GS_MODE,326SI_TRACKED_VGT_PRIMITIVEID_EN,327SI_TRACKED_VGT_REUSE_OFF,328SI_TRACKED_SPI_VS_OUT_CONFIG,329SI_TRACKED_PA_CL_VTE_CNTL,330SI_TRACKED_PA_CL_NGG_CNTL,331SI_TRACKED_GE_MAX_OUTPUT_PER_SUBGROUP,332SI_TRACKED_GE_NGG_SUBGRP_CNTL,333334SI_TRACKED_SPI_SHADER_IDX_FORMAT, /* 2 consecutive registers */335SI_TRACKED_SPI_SHADER_POS_FORMAT,336337SI_TRACKED_SPI_PS_INPUT_ENA, /* 2 consecutive registers */338SI_TRACKED_SPI_PS_INPUT_ADDR,339340SI_TRACKED_SPI_BARYC_CNTL,341SI_TRACKED_SPI_PS_IN_CONTROL,342343SI_TRACKED_SPI_SHADER_Z_FORMAT, /* 2 consecutive registers */344SI_TRACKED_SPI_SHADER_COL_FORMAT,345346SI_TRACKED_CB_SHADER_MASK,347SI_TRACKED_VGT_TF_PARAM,348SI_TRACKED_VGT_VERTEX_REUSE_BLOCK_CNTL,349350SI_TRACKED_GE_PC_ALLOC,351352SI_NUM_TRACKED_REGS,353};354355struct si_tracked_regs {356uint64_t reg_saved;357uint32_t reg_value[SI_NUM_TRACKED_REGS];358uint32_t spi_ps_input_cntl[32];359};360361/* Private read-write buffer slots. */362enum363{364SI_ES_RING_ESGS,365SI_GS_RING_ESGS,366367SI_RING_GSVS,368369SI_VS_STREAMOUT_BUF0,370SI_VS_STREAMOUT_BUF1,371SI_VS_STREAMOUT_BUF2,372SI_VS_STREAMOUT_BUF3,373374SI_HS_CONST_DEFAULT_TESS_LEVELS,375SI_VS_CONST_INSTANCE_DIVISORS,376SI_VS_CONST_CLIP_PLANES,377SI_PS_CONST_POLY_STIPPLE,378SI_PS_CONST_SAMPLE_POSITIONS,379380/* Image descriptor of color buffer 0 for KHR_blend_equation_advanced. */381SI_PS_IMAGE_COLORBUF0,382SI_PS_IMAGE_COLORBUF0_HI,383SI_PS_IMAGE_COLORBUF0_FMASK,384SI_PS_IMAGE_COLORBUF0_FMASK_HI,385386GFX10_GS_QUERY_BUF,387388SI_NUM_INTERNAL_BINDINGS,389};390391/* Indices into sctx->descriptors, laid out so that gfx and compute pipelines392* are contiguous:393*394* 0 - rw buffers395* 1 - vertex const and shader buffers396* 2 - vertex samplers and images397* 3 - fragment const and shader buffer398* ...399* 11 - compute const and shader buffers400* 12 - compute samplers and images401*/402enum403{404SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS,405SI_SHADER_DESCS_SAMPLERS_AND_IMAGES,406SI_NUM_SHADER_DESCS,407};408409#define SI_DESCS_INTERNAL 0410#define SI_DESCS_FIRST_SHADER 1411#define SI_DESCS_FIRST_COMPUTE (SI_DESCS_FIRST_SHADER + PIPE_SHADER_COMPUTE * SI_NUM_SHADER_DESCS)412#define SI_NUM_DESCS (SI_DESCS_FIRST_SHADER + SI_NUM_SHADERS * SI_NUM_SHADER_DESCS)413414#define SI_DESCS_SHADER_MASK(name) \415u_bit_consecutive(SI_DESCS_FIRST_SHADER + PIPE_SHADER_##name * SI_NUM_SHADER_DESCS, \416SI_NUM_SHADER_DESCS)417418static inline unsigned si_const_and_shader_buffer_descriptors_idx(unsigned shader)419{420return SI_DESCS_FIRST_SHADER + shader * SI_NUM_SHADER_DESCS +421SI_SHADER_DESCS_CONST_AND_SHADER_BUFFERS;422}423424static inline unsigned si_sampler_and_image_descriptors_idx(unsigned shader)425{426return SI_DESCS_FIRST_SHADER + shader * SI_NUM_SHADER_DESCS +427SI_SHADER_DESCS_SAMPLERS_AND_IMAGES;428}429430/* This represents descriptors in memory, such as buffer resources,431* image resources, and sampler states.432*/433struct si_descriptors {434/* The list of descriptors in malloc'd memory. */435uint32_t *list;436/* The list in mapped GPU memory. */437uint32_t *gpu_list;438439/* The buffer where the descriptors have been uploaded. */440struct si_resource *buffer;441uint64_t gpu_address;442443/* The maximum number of descriptors. */444uint32_t num_elements;445446/* Slots that are used by currently-bound shaders.447* It determines which slots are uploaded.448*/449uint32_t first_active_slot;450uint32_t num_active_slots;451452/* The SH register offset relative to USER_DATA*_0 where the pointer453* to the descriptor array will be stored. */454short shader_userdata_offset;455/* The size of one descriptor. */456ubyte element_dw_size;457/* If there is only one slot enabled, bind it directly instead of458* uploading descriptors. -1 if disabled. */459signed char slot_index_to_bind_directly;460};461462struct si_buffer_resources {463struct pipe_resource **buffers; /* this has num_buffers elements */464unsigned *offsets; /* this has num_buffers elements */465466enum radeon_bo_priority priority : 6;467enum radeon_bo_priority priority_constbuf : 6;468469/* The i-th bit is set if that element is enabled (non-NULL resource). */470uint64_t enabled_mask;471uint64_t writable_mask;472};473474#define si_pm4_state_changed(sctx, member) \475((sctx)->queued.named.member != (sctx)->emitted.named.member)476477#define si_pm4_state_enabled_and_changed(sctx, member) \478((sctx)->queued.named.member && si_pm4_state_changed(sctx, member))479480#define si_pm4_bind_state(sctx, member, value) \481do { \482(sctx)->queued.named.member = (value); \483if (value && value != (sctx)->emitted.named.member) \484(sctx)->dirty_states |= SI_STATE_BIT(member); \485else \486(sctx)->dirty_states &= ~SI_STATE_BIT(member); \487} while (0)488489/* si_descriptors.c */490void si_set_mutable_tex_desc_fields(struct si_screen *sscreen, struct si_texture *tex,491const struct legacy_surf_level *base_level_info,492unsigned base_level, unsigned first_level, unsigned block_width,493/* restrict decreases overhead of si_set_sampler_view_desc ~8x. */494bool is_stencil, uint16_t access, uint32_t * restrict state);495void si_update_ps_colorbuf0_slot(struct si_context *sctx);496void si_get_pipe_constant_buffer(struct si_context *sctx, uint shader, uint slot,497struct pipe_constant_buffer *cbuf);498void si_get_shader_buffers(struct si_context *sctx, enum pipe_shader_type shader, uint start_slot,499uint count, struct pipe_shader_buffer *sbuf);500void si_set_ring_buffer(struct si_context *sctx, uint slot, struct pipe_resource *buffer,501unsigned stride, unsigned num_records, bool add_tid, bool swizzle,502unsigned element_size, unsigned index_stride, uint64_t offset);503void si_init_all_descriptors(struct si_context *sctx);504bool si_upload_graphics_shader_descriptors(struct si_context *sctx);505bool si_upload_compute_shader_descriptors(struct si_context *sctx);506void si_release_all_descriptors(struct si_context *sctx);507void si_gfx_resources_add_all_to_bo_list(struct si_context *sctx);508void si_compute_resources_add_all_to_bo_list(struct si_context *sctx);509bool si_gfx_resources_check_encrypted(struct si_context *sctx);510bool si_compute_resources_check_encrypted(struct si_context *sctx);511void si_shader_pointers_mark_dirty(struct si_context *sctx);512void si_add_all_descriptors_to_bo_list(struct si_context *sctx);513void si_update_all_texture_descriptors(struct si_context *sctx);514void si_shader_change_notify(struct si_context *sctx);515void si_update_needs_color_decompress_masks(struct si_context *sctx);516void si_emit_graphics_shader_pointers(struct si_context *sctx);517void si_emit_compute_shader_pointers(struct si_context *sctx);518void si_set_internal_const_buffer(struct si_context *sctx, uint slot,519const struct pipe_constant_buffer *input);520void si_set_internal_shader_buffer(struct si_context *sctx, uint slot,521const struct pipe_shader_buffer *sbuffer);522void si_set_active_descriptors(struct si_context *sctx, unsigned desc_idx,523uint64_t new_active_mask);524void si_set_active_descriptors_for_shader(struct si_context *sctx, struct si_shader_selector *sel);525bool si_bindless_descriptor_can_reclaim_slab(void *priv, struct pb_slab_entry *entry);526struct pb_slab *si_bindless_descriptor_slab_alloc(void *priv, unsigned heap, unsigned entry_size,527unsigned group_index);528void si_bindless_descriptor_slab_free(void *priv, struct pb_slab *pslab);529void si_rebind_buffer(struct si_context *sctx, struct pipe_resource *buf);530/* si_state.c */531void si_init_state_compute_functions(struct si_context *sctx);532void si_init_state_functions(struct si_context *sctx);533void si_init_screen_state_functions(struct si_screen *sscreen);534void si_init_cs_preamble_state(struct si_context *sctx, bool uses_reg_shadowing);535void si_make_buffer_descriptor(struct si_screen *screen, struct si_resource *buf,536enum pipe_format format, unsigned offset, unsigned size,537uint32_t *state);538struct pipe_sampler_view *si_create_sampler_view_custom(struct pipe_context *ctx,539struct pipe_resource *texture,540const struct pipe_sampler_view *state,541unsigned width0, unsigned height0,542unsigned force_level);543void si_update_fb_dirtiness_after_rendering(struct si_context *sctx);544void si_mark_display_dcc_dirty(struct si_context *sctx, struct si_texture *tex);545void si_update_ps_iter_samples(struct si_context *sctx);546void si_save_qbo_state(struct si_context *sctx, struct si_qbo_state *st);547void si_restore_qbo_state(struct si_context *sctx, struct si_qbo_state *st);548void si_set_occlusion_query_state(struct si_context *sctx, bool old_perfect_enable);549550struct si_fast_udiv_info32 {551unsigned multiplier; /* the "magic number" multiplier */552unsigned pre_shift; /* shift for the dividend before multiplying */553unsigned post_shift; /* shift for the dividend after multiplying */554int increment; /* 0 or 1; if set then increment the numerator, using one of555the two strategies */556};557558struct si_fast_udiv_info32 si_compute_fast_udiv_info32(uint32_t D, unsigned num_bits);559560/* si_state_binning.c */561void si_emit_dpbb_state(struct si_context *sctx);562563/* si_state_shaders.c */564void si_get_ir_cache_key(struct si_shader_selector *sel, bool ngg, bool es,565unsigned char ir_sha1_cache_key[20]);566bool si_shader_cache_load_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],567struct si_shader *shader);568void si_shader_cache_insert_shader(struct si_screen *sscreen, unsigned char ir_sha1_cache_key[20],569struct si_shader *shader, bool insert_into_disk_cache);570bool si_shader_mem_ordered(struct si_shader *shader);571bool si_update_shaders(struct si_context *sctx);572void si_init_screen_live_shader_cache(struct si_screen *sscreen);573void si_init_shader_functions(struct si_context *sctx);574bool si_init_shader_cache(struct si_screen *sscreen);575void si_destroy_shader_cache(struct si_screen *sscreen);576void si_schedule_initial_compile(struct si_context *sctx, gl_shader_stage stage,577struct util_queue_fence *ready_fence,578struct si_compiler_ctx_state *compiler_ctx_state, void *job,579util_queue_execute_func execute);580void si_get_active_slot_masks(const struct si_shader_info *info, uint64_t *const_and_shader_buffers,581uint64_t *samplers_and_images);582int si_shader_select_with_key(struct si_screen *sscreen, struct si_shader_ctx_state *state,583struct si_compiler_ctx_state *compiler_state,584struct si_shader_key *key, int thread_index, bool optimized_or_none);585void si_shader_selector_key_vs(struct si_context *sctx, struct si_shader_selector *vs,586struct si_shader_key *key, struct si_vs_prolog_bits *prolog_key);587unsigned si_get_input_prim(const struct si_shader_selector *gs);588bool si_update_ngg(struct si_context *sctx);589590/* si_state_draw.c */591void si_init_draw_functions_GFX6(struct si_context *sctx);592void si_init_draw_functions_GFX7(struct si_context *sctx);593void si_init_draw_functions_GFX8(struct si_context *sctx);594void si_init_draw_functions_GFX9(struct si_context *sctx);595void si_init_draw_functions_GFX10(struct si_context *sctx);596void si_init_draw_functions_GFX10_3(struct si_context *sctx);597598/* si_state_msaa.c */599void si_init_msaa_functions(struct si_context *sctx);600void si_emit_sample_locations(struct radeon_cmdbuf *cs, int nr_samples);601602/* si_state_streamout.c */603void si_streamout_buffers_dirty(struct si_context *sctx);604void si_emit_streamout_end(struct si_context *sctx);605void si_update_prims_generated_query_state(struct si_context *sctx, unsigned type, int diff);606void si_init_streamout_functions(struct si_context *sctx);607608static inline unsigned si_get_constbuf_slot(unsigned slot)609{610/* Constant buffers are in slots [32..47], ascending */611return SI_NUM_SHADER_BUFFERS + slot;612}613614static inline unsigned si_get_shaderbuf_slot(unsigned slot)615{616/* shader buffers are in slots [31..0], descending */617return SI_NUM_SHADER_BUFFERS - 1 - slot;618}619620static inline unsigned si_get_sampler_slot(unsigned slot)621{622/* 32 samplers are in sampler slots [16..47], 16 dw per slot, ascending */623/* those are equivalent to image slots [32..95], 8 dw per slot, ascending */624return SI_NUM_IMAGE_SLOTS / 2 + slot;625}626627static inline unsigned si_get_image_slot(unsigned slot)628{629/* image slots are in [31..0] (sampler slots [15..0]), descending */630/* images are in slots [31..16], while FMASKs are in slots [15..0] */631return SI_NUM_IMAGE_SLOTS - 1 - slot;632}633634#ifdef __cplusplus635}636#endif637638#endif639640641