19f464c52Smaya/* 29f464c52Smaya * Copyright © 2017 Intel Corporation 39f464c52Smaya * 49f464c52Smaya * Permission is hereby granted, free of charge, to any person obtaining a 59f464c52Smaya * copy of this software and associated documentation files (the "Software"), 69f464c52Smaya * to deal in the Software without restriction, including without limitation 79f464c52Smaya * on the rights to use, copy, modify, merge, publish, distribute, sub 89f464c52Smaya * license, and/or sell copies of the Software, and to permit persons to whom 99f464c52Smaya * the Software is furnished to do so, subject to the following conditions: 109f464c52Smaya * 119f464c52Smaya * The above copyright notice and this permission notice (including the next 129f464c52Smaya * paragraph) shall be included in all copies or substantial portions of the 139f464c52Smaya * Software. 149f464c52Smaya * 159f464c52Smaya * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 169f464c52Smaya * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 179f464c52Smaya * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 189f464c52Smaya * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 199f464c52Smaya * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 209f464c52Smaya * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 219f464c52Smaya * USE OR OTHER DEALINGS IN THE SOFTWARE. 229f464c52Smaya */ 239f464c52Smaya#ifndef IRIS_CONTEXT_H 249f464c52Smaya#define IRIS_CONTEXT_H 259f464c52Smaya 269f464c52Smaya#include "pipe/p_context.h" 279f464c52Smaya#include "pipe/p_state.h" 287ec681f3Smrg#include "util/set.h" 297ec681f3Smrg#include "util/slab.h" 309f464c52Smaya#include "util/u_debug.h" 317ec681f3Smrg#include "util/u_threaded_context.h" 329f464c52Smaya#include "intel/blorp/blorp.h" 337ec681f3Smrg#include "intel/dev/intel_debug.h" 347ec681f3Smrg#include "intel/common/intel_l3_config.h" 359f464c52Smaya#include "intel/compiler/brw_compiler.h" 369f464c52Smaya#include "iris_batch.h" 379f464c52Smaya#include "iris_binder.h" 389f464c52Smaya#include "iris_fence.h" 399f464c52Smaya#include "iris_resource.h" 409f464c52Smaya#include "iris_screen.h" 419f464c52Smaya 429f464c52Smayastruct iris_bo; 439f464c52Smayastruct iris_context; 449f464c52Smayastruct blorp_batch; 459f464c52Smayastruct blorp_params; 469f464c52Smaya 479f464c52Smaya#define IRIS_MAX_TEXTURE_BUFFER_SIZE (1 << 27) 489f464c52Smaya#define IRIS_MAX_TEXTURE_SAMPLERS 32 499f464c52Smaya/* IRIS_MAX_ABOS and IRIS_MAX_SSBOS must be the same. */ 509f464c52Smaya#define IRIS_MAX_ABOS 16 519f464c52Smaya#define IRIS_MAX_SSBOS 16 529f464c52Smaya#define IRIS_MAX_VIEWPORTS 16 539f464c52Smaya#define IRIS_MAX_CLIP_PLANES 8 547ec681f3Smrg#define IRIS_MAX_GLOBAL_BINDINGS 32 559f464c52Smaya 569f464c52Smayaenum iris_param_domain { 579f464c52Smaya BRW_PARAM_DOMAIN_BUILTIN = 0, 589f464c52Smaya BRW_PARAM_DOMAIN_IMAGE, 599f464c52Smaya}; 609f464c52Smaya 617ec681f3Smrgenum { 627ec681f3Smrg DRI_CONF_BO_REUSE_DISABLED, 637ec681f3Smrg DRI_CONF_BO_REUSE_ALL 647ec681f3Smrg}; 657ec681f3Smrg 669f464c52Smaya#define BRW_PARAM(domain, val) (BRW_PARAM_DOMAIN_##domain << 24 | (val)) 679f464c52Smaya#define BRW_PARAM_DOMAIN(param) ((uint32_t)(param) >> 24) 689f464c52Smaya#define BRW_PARAM_VALUE(param) ((uint32_t)(param) & 0x00ffffff) 699f464c52Smaya#define BRW_PARAM_IMAGE(idx, offset) BRW_PARAM(IMAGE, ((idx) << 8) | (offset)) 709f464c52Smaya#define BRW_PARAM_IMAGE_IDX(value) (BRW_PARAM_VALUE(value) >> 8) 719f464c52Smaya#define BRW_PARAM_IMAGE_OFFSET(value)(BRW_PARAM_VALUE(value) & 0xf) 729f464c52Smaya 739f464c52Smaya/** 749f464c52Smaya * Dirty flags. When state changes, we flag some combination of these 759f464c52Smaya * to indicate that particular GPU commands need to be re-emitted. 769f464c52Smaya * 779f464c52Smaya * Each bit typically corresponds to a single 3DSTATE_* command packet, but 789f464c52Smaya * in rare cases they map to a group of related packets that need to be 799f464c52Smaya * emitted together. 809f464c52Smaya * 819f464c52Smaya * See iris_upload_render_state(). 829f464c52Smaya */ 837ec681f3Smrg#define IRIS_DIRTY_COLOR_CALC_STATE (1ull << 0) 847ec681f3Smrg#define IRIS_DIRTY_POLYGON_STIPPLE (1ull << 1) 857ec681f3Smrg#define IRIS_DIRTY_SCISSOR_RECT (1ull << 2) 867ec681f3Smrg#define IRIS_DIRTY_WM_DEPTH_STENCIL (1ull << 3) 877ec681f3Smrg#define IRIS_DIRTY_CC_VIEWPORT (1ull << 4) 887ec681f3Smrg#define IRIS_DIRTY_SF_CL_VIEWPORT (1ull << 5) 897ec681f3Smrg#define IRIS_DIRTY_PS_BLEND (1ull << 6) 907ec681f3Smrg#define IRIS_DIRTY_BLEND_STATE (1ull << 7) 917ec681f3Smrg#define IRIS_DIRTY_RASTER (1ull << 8) 927ec681f3Smrg#define IRIS_DIRTY_CLIP (1ull << 9) 937ec681f3Smrg#define IRIS_DIRTY_SBE (1ull << 10) 947ec681f3Smrg#define IRIS_DIRTY_LINE_STIPPLE (1ull << 11) 957ec681f3Smrg#define IRIS_DIRTY_VERTEX_ELEMENTS (1ull << 12) 967ec681f3Smrg#define IRIS_DIRTY_MULTISAMPLE (1ull << 13) 977ec681f3Smrg#define IRIS_DIRTY_VERTEX_BUFFERS (1ull << 14) 987ec681f3Smrg#define IRIS_DIRTY_SAMPLE_MASK (1ull << 15) 997ec681f3Smrg#define IRIS_DIRTY_URB (1ull << 16) 1007ec681f3Smrg#define IRIS_DIRTY_DEPTH_BUFFER (1ull << 17) 1017ec681f3Smrg#define IRIS_DIRTY_WM (1ull << 18) 1027ec681f3Smrg#define IRIS_DIRTY_SO_BUFFERS (1ull << 19) 1037ec681f3Smrg#define IRIS_DIRTY_SO_DECL_LIST (1ull << 20) 1047ec681f3Smrg#define IRIS_DIRTY_STREAMOUT (1ull << 21) 1057ec681f3Smrg#define IRIS_DIRTY_VF_SGVS (1ull << 22) 1067ec681f3Smrg#define IRIS_DIRTY_VF (1ull << 23) 1077ec681f3Smrg#define IRIS_DIRTY_VF_TOPOLOGY (1ull << 24) 1087ec681f3Smrg#define IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES (1ull << 25) 1097ec681f3Smrg#define IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES (1ull << 26) 1107ec681f3Smrg#define IRIS_DIRTY_VF_STATISTICS (1ull << 27) 1117ec681f3Smrg#define IRIS_DIRTY_PMA_FIX (1ull << 28) 1127ec681f3Smrg#define IRIS_DIRTY_DEPTH_BOUNDS (1ull << 29) 1137ec681f3Smrg#define IRIS_DIRTY_RENDER_BUFFER (1ull << 30) 1147ec681f3Smrg#define IRIS_DIRTY_STENCIL_REF (1ull << 31) 1157ec681f3Smrg#define IRIS_DIRTY_VERTEX_BUFFER_FLUSHES (1ull << 32) 1167ec681f3Smrg#define IRIS_DIRTY_RENDER_MISC_BUFFER_FLUSHES (1ull << 33) 1177ec681f3Smrg#define IRIS_DIRTY_COMPUTE_MISC_BUFFER_FLUSHES (1ull << 34) 1187ec681f3Smrg 1197ec681f3Smrg#define IRIS_ALL_DIRTY_FOR_COMPUTE (IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES | \ 1207ec681f3Smrg IRIS_DIRTY_COMPUTE_MISC_BUFFER_FLUSHES) 1217ec681f3Smrg 1227ec681f3Smrg#define IRIS_ALL_DIRTY_FOR_RENDER (~IRIS_ALL_DIRTY_FOR_COMPUTE) 1237ec681f3Smrg 1247ec681f3Smrg/** 1257ec681f3Smrg * Per-stage dirty flags. When state changes, we flag some combination of 1267ec681f3Smrg * these to indicate that particular GPU commands need to be re-emitted. 1277ec681f3Smrg * Unlike the IRIS_DIRTY_* flags these are shader stage-specific and can be 1287ec681f3Smrg * indexed by shifting the mask by the shader stage index. 1297ec681f3Smrg * 1307ec681f3Smrg * See iris_upload_render_state(). 1317ec681f3Smrg */ 1327ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_VS (1ull << 0) 1337ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TCS (1ull << 1) 1347ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TES (1ull << 2) 1357ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_GS (1ull << 3) 1367ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_PS (1ull << 4) 1377ec681f3Smrg#define IRIS_STAGE_DIRTY_SAMPLER_STATES_CS (1ull << 5) 1387ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_VS (1ull << 6) 1397ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_TCS (1ull << 7) 1407ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_TES (1ull << 8) 1417ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_GS (1ull << 9) 1427ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_FS (1ull << 10) 1437ec681f3Smrg#define IRIS_STAGE_DIRTY_UNCOMPILED_CS (1ull << 11) 1447ec681f3Smrg#define IRIS_STAGE_DIRTY_VS (1ull << 12) 1457ec681f3Smrg#define IRIS_STAGE_DIRTY_TCS (1ull << 13) 1467ec681f3Smrg#define IRIS_STAGE_DIRTY_TES (1ull << 14) 1477ec681f3Smrg#define IRIS_STAGE_DIRTY_GS (1ull << 15) 1487ec681f3Smrg#define IRIS_STAGE_DIRTY_FS (1ull << 16) 1497ec681f3Smrg#define IRIS_STAGE_DIRTY_CS (1ull << 17) 1507ec681f3Smrg#define IRIS_SHIFT_FOR_STAGE_DIRTY_CONSTANTS 18 1517ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_VS (1ull << 18) 1527ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_TCS (1ull << 19) 1537ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_TES (1ull << 20) 1547ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_GS (1ull << 21) 1557ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_FS (1ull << 22) 1567ec681f3Smrg#define IRIS_STAGE_DIRTY_CONSTANTS_CS (1ull << 23) 1577ec681f3Smrg#define IRIS_SHIFT_FOR_STAGE_DIRTY_BINDINGS 24 1587ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_VS (1ull << 24) 1597ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_TCS (1ull << 25) 1607ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_TES (1ull << 26) 1617ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_GS (1ull << 27) 1627ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_FS (1ull << 28) 1637ec681f3Smrg#define IRIS_STAGE_DIRTY_BINDINGS_CS (1ull << 29) 1647ec681f3Smrg 1657ec681f3Smrg#define IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE (IRIS_STAGE_DIRTY_CS | \ 1667ec681f3Smrg IRIS_STAGE_DIRTY_SAMPLER_STATES_CS | \ 1677ec681f3Smrg IRIS_STAGE_DIRTY_UNCOMPILED_CS | \ 1687ec681f3Smrg IRIS_STAGE_DIRTY_CONSTANTS_CS | \ 1697ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_CS) 1707ec681f3Smrg 1717ec681f3Smrg#define IRIS_ALL_STAGE_DIRTY_FOR_RENDER (~IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE) 1727ec681f3Smrg 1737ec681f3Smrg#define IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER (IRIS_STAGE_DIRTY_BINDINGS_VS | \ 1747ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_TCS | \ 1757ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_TES | \ 1767ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_GS | \ 1777ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_FS) 1787ec681f3Smrg 1797ec681f3Smrg#define IRIS_ALL_STAGE_DIRTY_BINDINGS (IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER | \ 1807ec681f3Smrg IRIS_STAGE_DIRTY_BINDINGS_CS) 1819f464c52Smaya 1829f464c52Smaya/** 1839f464c52Smaya * Non-orthogonal state (NOS) dependency flags. 1849f464c52Smaya * 1859f464c52Smaya * Shader programs may depend on non-orthogonal state. These flags are 1869f464c52Smaya * used to indicate that a shader's key depends on the state provided by 1879f464c52Smaya * a certain Gallium CSO. Changing any CSOs marked as a dependency will 1889f464c52Smaya * cause the driver to re-compute the shader key, possibly triggering a 1899f464c52Smaya * shader recompile. 1909f464c52Smaya */ 1919f464c52Smayaenum iris_nos_dep { 1929f464c52Smaya IRIS_NOS_FRAMEBUFFER, 1939f464c52Smaya IRIS_NOS_DEPTH_STENCIL_ALPHA, 1949f464c52Smaya IRIS_NOS_RASTERIZER, 1959f464c52Smaya IRIS_NOS_BLEND, 1969f464c52Smaya IRIS_NOS_LAST_VUE_MAP, 1979f464c52Smaya 1989f464c52Smaya IRIS_NOS_COUNT, 1999f464c52Smaya}; 2009f464c52Smaya 2017ec681f3Smrg/** @{ 2027ec681f3Smrg * 2037ec681f3Smrg * Program cache keys for state based recompiles. 2047ec681f3Smrg */ 2057ec681f3Smrg 2067ec681f3Smrgstruct iris_base_prog_key { 2077ec681f3Smrg unsigned program_string_id; 2087ec681f3Smrg}; 2097ec681f3Smrg 2107ec681f3Smrg/** 2117ec681f3Smrg * Note, we need to take care to have padding explicitly declared 2127ec681f3Smrg * for key since we will directly memcmp the whole struct. 2137ec681f3Smrg */ 2147ec681f3Smrgstruct iris_vue_prog_key { 2157ec681f3Smrg struct iris_base_prog_key base; 2167ec681f3Smrg 2177ec681f3Smrg unsigned nr_userclip_plane_consts:4; 2187ec681f3Smrg unsigned padding:28; 2197ec681f3Smrg}; 2207ec681f3Smrg 2217ec681f3Smrgstruct iris_vs_prog_key { 2227ec681f3Smrg struct iris_vue_prog_key vue; 2237ec681f3Smrg}; 2247ec681f3Smrg 2257ec681f3Smrgstruct iris_tcs_prog_key { 2267ec681f3Smrg struct iris_vue_prog_key vue; 2277ec681f3Smrg 2287ec681f3Smrg uint16_t tes_primitive_mode; 2297ec681f3Smrg 2307ec681f3Smrg uint8_t input_vertices; 2317ec681f3Smrg 2327ec681f3Smrg bool quads_workaround; 2337ec681f3Smrg 2347ec681f3Smrg /** A bitfield of per-patch outputs written. */ 2357ec681f3Smrg uint32_t patch_outputs_written; 2367ec681f3Smrg 2377ec681f3Smrg /** A bitfield of per-vertex outputs written. */ 2387ec681f3Smrg uint64_t outputs_written; 2397ec681f3Smrg}; 2407ec681f3Smrg 2417ec681f3Smrgstruct iris_tes_prog_key { 2427ec681f3Smrg struct iris_vue_prog_key vue; 2437ec681f3Smrg 2447ec681f3Smrg /** A bitfield of per-patch inputs read. */ 2457ec681f3Smrg uint32_t patch_inputs_read; 2467ec681f3Smrg 2477ec681f3Smrg /** A bitfield of per-vertex inputs read. */ 2487ec681f3Smrg uint64_t inputs_read; 2497ec681f3Smrg}; 2507ec681f3Smrg 2517ec681f3Smrgstruct iris_gs_prog_key { 2527ec681f3Smrg struct iris_vue_prog_key vue; 2537ec681f3Smrg}; 2547ec681f3Smrg 2557ec681f3Smrgstruct iris_fs_prog_key { 2567ec681f3Smrg struct iris_base_prog_key base; 2577ec681f3Smrg 2587ec681f3Smrg unsigned nr_color_regions:5; 2597ec681f3Smrg bool flat_shade:1; 2607ec681f3Smrg bool alpha_test_replicate_alpha:1; 2617ec681f3Smrg bool alpha_to_coverage:1; 2627ec681f3Smrg bool clamp_fragment_color:1; 2637ec681f3Smrg bool persample_interp:1; 2647ec681f3Smrg bool multisample_fbo:1; 2657ec681f3Smrg bool force_dual_color_blend:1; 2667ec681f3Smrg bool coherent_fb_fetch:1; 2677ec681f3Smrg 2687ec681f3Smrg uint8_t color_outputs_valid; 2697ec681f3Smrg uint64_t input_slots_valid; 2707ec681f3Smrg}; 2717ec681f3Smrg 2727ec681f3Smrgstruct iris_cs_prog_key { 2737ec681f3Smrg struct iris_base_prog_key base; 2747ec681f3Smrg}; 2757ec681f3Smrg 2767ec681f3Smrgunion iris_any_prog_key { 2777ec681f3Smrg struct iris_base_prog_key base; 2787ec681f3Smrg struct iris_vue_prog_key vue; 2797ec681f3Smrg struct iris_vs_prog_key vs; 2807ec681f3Smrg struct iris_tcs_prog_key tcs; 2817ec681f3Smrg struct iris_tes_prog_key tes; 2827ec681f3Smrg struct iris_gs_prog_key gs; 2837ec681f3Smrg struct iris_fs_prog_key fs; 2847ec681f3Smrg struct iris_cs_prog_key cs; 2857ec681f3Smrg}; 2867ec681f3Smrg 2877ec681f3Smrg/** @} */ 2887ec681f3Smrg 2899f464c52Smayastruct iris_depth_stencil_alpha_state; 2909f464c52Smaya 2919f464c52Smaya/** 2929f464c52Smaya * Cache IDs for the in-memory program cache (ice->shaders.cache). 2939f464c52Smaya */ 2949f464c52Smayaenum iris_program_cache_id { 2959f464c52Smaya IRIS_CACHE_VS = MESA_SHADER_VERTEX, 2969f464c52Smaya IRIS_CACHE_TCS = MESA_SHADER_TESS_CTRL, 2979f464c52Smaya IRIS_CACHE_TES = MESA_SHADER_TESS_EVAL, 2989f464c52Smaya IRIS_CACHE_GS = MESA_SHADER_GEOMETRY, 2999f464c52Smaya IRIS_CACHE_FS = MESA_SHADER_FRAGMENT, 3009f464c52Smaya IRIS_CACHE_CS = MESA_SHADER_COMPUTE, 3019f464c52Smaya IRIS_CACHE_BLORP, 3029f464c52Smaya}; 3039f464c52Smaya 3049f464c52Smaya/** @{ 3059f464c52Smaya * 3069f464c52Smaya * Defines for PIPE_CONTROL operations, which trigger cache flushes, 3079f464c52Smaya * synchronization, pipelined memory writes, and so on. 3089f464c52Smaya * 3099f464c52Smaya * The bits here are not the actual hardware values. The actual fields 3109f464c52Smaya * move between various generations, so we just have flags for each 3119f464c52Smaya * potential operation, and use genxml to encode the actual packet. 3129f464c52Smaya */ 3139f464c52Smayaenum pipe_control_flags 3149f464c52Smaya{ 3159f464c52Smaya PIPE_CONTROL_FLUSH_LLC = (1 << 1), 3169f464c52Smaya PIPE_CONTROL_LRI_POST_SYNC_OP = (1 << 2), 3179f464c52Smaya PIPE_CONTROL_STORE_DATA_INDEX = (1 << 3), 3189f464c52Smaya PIPE_CONTROL_CS_STALL = (1 << 4), 3199f464c52Smaya PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET = (1 << 5), 3209f464c52Smaya PIPE_CONTROL_SYNC_GFDT = (1 << 6), 3219f464c52Smaya PIPE_CONTROL_TLB_INVALIDATE = (1 << 7), 3229f464c52Smaya PIPE_CONTROL_MEDIA_STATE_CLEAR = (1 << 8), 3239f464c52Smaya PIPE_CONTROL_WRITE_IMMEDIATE = (1 << 9), 3249f464c52Smaya PIPE_CONTROL_WRITE_DEPTH_COUNT = (1 << 10), 3259f464c52Smaya PIPE_CONTROL_WRITE_TIMESTAMP = (1 << 11), 3269f464c52Smaya PIPE_CONTROL_DEPTH_STALL = (1 << 12), 3279f464c52Smaya PIPE_CONTROL_RENDER_TARGET_FLUSH = (1 << 13), 3289f464c52Smaya PIPE_CONTROL_INSTRUCTION_INVALIDATE = (1 << 14), 3299f464c52Smaya PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE = (1 << 15), 3309f464c52Smaya PIPE_CONTROL_INDIRECT_STATE_POINTERS_DISABLE = (1 << 16), 3319f464c52Smaya PIPE_CONTROL_NOTIFY_ENABLE = (1 << 17), 3329f464c52Smaya PIPE_CONTROL_FLUSH_ENABLE = (1 << 18), 3339f464c52Smaya PIPE_CONTROL_DATA_CACHE_FLUSH = (1 << 19), 3349f464c52Smaya PIPE_CONTROL_VF_CACHE_INVALIDATE = (1 << 20), 3359f464c52Smaya PIPE_CONTROL_CONST_CACHE_INVALIDATE = (1 << 21), 3369f464c52Smaya PIPE_CONTROL_STATE_CACHE_INVALIDATE = (1 << 22), 3379f464c52Smaya PIPE_CONTROL_STALL_AT_SCOREBOARD = (1 << 23), 3389f464c52Smaya PIPE_CONTROL_DEPTH_CACHE_FLUSH = (1 << 24), 3397ec681f3Smrg PIPE_CONTROL_TILE_CACHE_FLUSH = (1 << 25), 3407ec681f3Smrg PIPE_CONTROL_FLUSH_HDC = (1 << 26), 3419f464c52Smaya}; 3429f464c52Smaya 3439f464c52Smaya#define PIPE_CONTROL_CACHE_FLUSH_BITS \ 3449f464c52Smaya (PIPE_CONTROL_DEPTH_CACHE_FLUSH | \ 3459f464c52Smaya PIPE_CONTROL_DATA_CACHE_FLUSH | \ 3467ec681f3Smrg PIPE_CONTROL_TILE_CACHE_FLUSH | \ 3479f464c52Smaya PIPE_CONTROL_RENDER_TARGET_FLUSH) 3489f464c52Smaya 3499f464c52Smaya#define PIPE_CONTROL_CACHE_INVALIDATE_BITS \ 3509f464c52Smaya (PIPE_CONTROL_STATE_CACHE_INVALIDATE | \ 3519f464c52Smaya PIPE_CONTROL_CONST_CACHE_INVALIDATE | \ 3529f464c52Smaya PIPE_CONTROL_VF_CACHE_INVALIDATE | \ 3539f464c52Smaya PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | \ 3549f464c52Smaya PIPE_CONTROL_INSTRUCTION_INVALIDATE) 3559f464c52Smaya 3569f464c52Smayaenum iris_predicate_state { 3579f464c52Smaya /* The first two states are used if we can determine whether to draw 3589f464c52Smaya * without having to look at the values in the query object buffer. This 3599f464c52Smaya * will happen if there is no conditional render in progress, if the query 3609f464c52Smaya * object is already completed or if something else has already added 3619f464c52Smaya * samples to the preliminary result. 3629f464c52Smaya */ 3639f464c52Smaya IRIS_PREDICATE_STATE_RENDER, 3649f464c52Smaya IRIS_PREDICATE_STATE_DONT_RENDER, 3659f464c52Smaya 3669f464c52Smaya /* In this case whether to draw or not depends on the result of an 3679f464c52Smaya * MI_PREDICATE command so the predicate enable bit needs to be checked. 3689f464c52Smaya */ 3699f464c52Smaya IRIS_PREDICATE_STATE_USE_BIT, 3709f464c52Smaya}; 3719f464c52Smaya 3729f464c52Smaya/** @} */ 3739f464c52Smaya 3747ec681f3Smrg/** 3757ec681f3Smrg * An uncompiled, API-facing shader. This is the Gallium CSO for shaders. 3767ec681f3Smrg * It primarily contains the NIR for the shader. 3777ec681f3Smrg * 3787ec681f3Smrg * Each API-facing shader can be compiled into multiple shader variants, 3797ec681f3Smrg * based on non-orthogonal state dependencies, recorded in the shader key. 3807ec681f3Smrg * 3817ec681f3Smrg * See iris_compiled_shader, which represents a compiled shader variant. 3827ec681f3Smrg */ 3837ec681f3Smrgstruct iris_uncompiled_shader { 3847ec681f3Smrg struct pipe_reference ref; 3857ec681f3Smrg 3867ec681f3Smrg /** 3877ec681f3Smrg * NIR for the shader. 3887ec681f3Smrg * 3897ec681f3Smrg * Even for shaders that originate as TGSI, this pointer will be non-NULL. 3907ec681f3Smrg */ 3917ec681f3Smrg struct nir_shader *nir; 3927ec681f3Smrg 3937ec681f3Smrg struct pipe_stream_output_info stream_output; 3947ec681f3Smrg 3957ec681f3Smrg /* A SHA1 of the serialized NIR for the disk cache. */ 3967ec681f3Smrg unsigned char nir_sha1[20]; 3977ec681f3Smrg 3987ec681f3Smrg unsigned program_id; 3997ec681f3Smrg 4007ec681f3Smrg /** Bitfield of (1 << IRIS_NOS_*) flags. */ 4017ec681f3Smrg unsigned nos; 4027ec681f3Smrg 4037ec681f3Smrg /** Have any shader variants been compiled yet? */ 4047ec681f3Smrg bool compiled_once; 4057ec681f3Smrg 4067ec681f3Smrg /* Whether shader uses atomic operations. */ 4077ec681f3Smrg bool uses_atomic_load_store; 4087ec681f3Smrg 4097ec681f3Smrg /** Size (in bytes) of the kernel input data */ 4107ec681f3Smrg unsigned kernel_input_size; 4117ec681f3Smrg 4127ec681f3Smrg /** Size (in bytes) of the local (shared) data passed as kernel inputs */ 4137ec681f3Smrg unsigned kernel_shared_size; 4147ec681f3Smrg 4157ec681f3Smrg /** List of iris_compiled_shader variants */ 4167ec681f3Smrg struct list_head variants; 4177ec681f3Smrg 4187ec681f3Smrg /** Lock for the variants list */ 4197ec681f3Smrg simple_mtx_t lock; 4207ec681f3Smrg 4217ec681f3Smrg /** For parallel shader compiles */ 4227ec681f3Smrg struct util_queue_fence ready; 4237ec681f3Smrg}; 4247ec681f3Smrg 4257ec681f3Smrgenum iris_surface_group { 4267ec681f3Smrg IRIS_SURFACE_GROUP_RENDER_TARGET, 4277ec681f3Smrg IRIS_SURFACE_GROUP_RENDER_TARGET_READ, 4287ec681f3Smrg IRIS_SURFACE_GROUP_CS_WORK_GROUPS, 4297ec681f3Smrg IRIS_SURFACE_GROUP_TEXTURE, 4307ec681f3Smrg IRIS_SURFACE_GROUP_IMAGE, 4317ec681f3Smrg IRIS_SURFACE_GROUP_UBO, 4327ec681f3Smrg IRIS_SURFACE_GROUP_SSBO, 4337ec681f3Smrg 4347ec681f3Smrg IRIS_SURFACE_GROUP_COUNT, 4357ec681f3Smrg}; 4367ec681f3Smrg 4377ec681f3Smrgenum { 4387ec681f3Smrg /* Invalid value for a binding table index. */ 4397ec681f3Smrg IRIS_SURFACE_NOT_USED = 0xa0a0a0a0, 4407ec681f3Smrg}; 4417ec681f3Smrg 4427ec681f3Smrgstruct iris_binding_table { 4437ec681f3Smrg uint32_t size_bytes; 4447ec681f3Smrg 4457ec681f3Smrg /** Number of surfaces in each group, before compacting. */ 4467ec681f3Smrg uint32_t sizes[IRIS_SURFACE_GROUP_COUNT]; 4477ec681f3Smrg 4487ec681f3Smrg /** Initial offset of each group. */ 4497ec681f3Smrg uint32_t offsets[IRIS_SURFACE_GROUP_COUNT]; 4507ec681f3Smrg 4517ec681f3Smrg /** Mask of surfaces used in each group. */ 4527ec681f3Smrg uint64_t used_mask[IRIS_SURFACE_GROUP_COUNT]; 4537ec681f3Smrg}; 4547ec681f3Smrg 4559f464c52Smaya/** 4569f464c52Smaya * A compiled shader variant, containing a pointer to the GPU assembly, 4579f464c52Smaya * as well as program data and other packets needed by state upload. 4589f464c52Smaya * 4599f464c52Smaya * There can be several iris_compiled_shader variants per API-level shader 4609f464c52Smaya * (iris_uncompiled_shader), due to state-based recompiles (brw_*_prog_key). 4619f464c52Smaya */ 4629f464c52Smayastruct iris_compiled_shader { 4637ec681f3Smrg struct pipe_reference ref; 4647ec681f3Smrg 4657ec681f3Smrg /** Link in the iris_uncompiled_shader::variants list */ 4667ec681f3Smrg struct list_head link; 4677ec681f3Smrg 4687ec681f3Smrg /** Key for this variant (but not for BLORP programs) */ 4697ec681f3Smrg union iris_any_prog_key key; 4707ec681f3Smrg 4717ec681f3Smrg /** 4727ec681f3Smrg * Is the variant fully compiled and ready? 4737ec681f3Smrg * 4747ec681f3Smrg * Variants are added to \c iris_uncompiled_shader::variants before 4757ec681f3Smrg * compilation actually occurs. This signals that compilation has 4767ec681f3Smrg * completed. 4777ec681f3Smrg */ 4787ec681f3Smrg struct util_queue_fence ready; 4797ec681f3Smrg 4807ec681f3Smrg /** Variant is ready, but compilation failed. */ 4817ec681f3Smrg bool compilation_failed; 4827ec681f3Smrg 4839f464c52Smaya /** Reference to the uploaded assembly. */ 4849f464c52Smaya struct iris_state_ref assembly; 4859f464c52Smaya 4869f464c52Smaya /** Pointer to the assembly in the BO's map. */ 4879f464c52Smaya void *map; 4889f464c52Smaya 4899f464c52Smaya /** The program data (owned by the program cache hash table) */ 4909f464c52Smaya struct brw_stage_prog_data *prog_data; 4919f464c52Smaya 4929f464c52Smaya /** A list of system values to be uploaded as uniforms. */ 4939f464c52Smaya enum brw_param_builtin *system_values; 4949f464c52Smaya unsigned num_system_values; 4959f464c52Smaya 4967ec681f3Smrg /** Size (in bytes) of the kernel input data */ 4977ec681f3Smrg unsigned kernel_input_size; 4987ec681f3Smrg 4999f464c52Smaya /** Number of constbufs expected by the shader. */ 5009f464c52Smaya unsigned num_cbufs; 5019f464c52Smaya 5029f464c52Smaya /** 5039f464c52Smaya * Derived 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets 5049f464c52Smaya * (the VUE-based information for transform feedback outputs). 5059f464c52Smaya */ 5069f464c52Smaya uint32_t *streamout; 5079f464c52Smaya 5087ec681f3Smrg struct iris_binding_table bt; 5097ec681f3Smrg 5109f464c52Smaya /** 5119f464c52Smaya * Shader packets and other data derived from prog_data. These must be 5129f464c52Smaya * completely determined from prog_data. 5139f464c52Smaya */ 5149f464c52Smaya uint8_t derived_data[0]; 5159f464c52Smaya}; 5169f464c52Smaya 5179f464c52Smaya/** 5189f464c52Smaya * API context state that is replicated per shader stage. 5199f464c52Smaya */ 5209f464c52Smayastruct iris_shader_state { 5219f464c52Smaya /** Uniform Buffers */ 5229f464c52Smaya struct pipe_shader_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS]; 5239f464c52Smaya struct iris_state_ref constbuf_surf_state[PIPE_MAX_CONSTANT_BUFFERS]; 5249f464c52Smaya 5257ec681f3Smrg bool sysvals_need_upload; 5269f464c52Smaya 5279f464c52Smaya /** Shader Storage Buffers */ 5289f464c52Smaya struct pipe_shader_buffer ssbo[PIPE_MAX_SHADER_BUFFERS]; 5299f464c52Smaya struct iris_state_ref ssbo_surf_state[PIPE_MAX_SHADER_BUFFERS]; 5309f464c52Smaya 5319f464c52Smaya /** Shader Storage Images (image load store) */ 5329f464c52Smaya struct iris_image_view image[PIPE_MAX_SHADER_IMAGES]; 5339f464c52Smaya 5349f464c52Smaya struct iris_state_ref sampler_table; 5359f464c52Smaya struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS]; 5369f464c52Smaya struct iris_sampler_view *textures[IRIS_MAX_TEXTURE_SAMPLERS]; 5379f464c52Smaya 5389f464c52Smaya /** Bitfield of which constant buffers are bound (non-null). */ 5399f464c52Smaya uint32_t bound_cbufs; 5407ec681f3Smrg uint32_t dirty_cbufs; 5419f464c52Smaya 5429f464c52Smaya /** Bitfield of which image views are bound (non-null). */ 5439f464c52Smaya uint32_t bound_image_views; 5449f464c52Smaya 5459f464c52Smaya /** Bitfield of which sampler views are bound (non-null). */ 5469f464c52Smaya uint32_t bound_sampler_views; 5479f464c52Smaya 5489f464c52Smaya /** Bitfield of which shader storage buffers are bound (non-null). */ 5499f464c52Smaya uint32_t bound_ssbos; 5509f464c52Smaya 5519f464c52Smaya /** Bitfield of which shader storage buffers are writable. */ 5529f464c52Smaya uint32_t writable_ssbos; 5539f464c52Smaya}; 5549f464c52Smaya 5559f464c52Smaya/** 5569f464c52Smaya * Gallium CSO for stream output (transform feedback) targets. 5579f464c52Smaya */ 5589f464c52Smayastruct iris_stream_output_target { 5599f464c52Smaya struct pipe_stream_output_target base; 5609f464c52Smaya 5619f464c52Smaya /** Storage holding the offset where we're writing in the buffer */ 5629f464c52Smaya struct iris_state_ref offset; 5639f464c52Smaya 5647ec681f3Smrg /** Stride (bytes-per-vertex) during this transform feedback operation */ 5659f464c52Smaya uint16_t stride; 5669f464c52Smaya 5677ec681f3Smrg /** Does the next 3DSTATE_SO_BUFFER need to zero the offsets? */ 5687ec681f3Smrg bool zero_offset; 5699f464c52Smaya}; 5709f464c52Smaya 5719f464c52Smaya/** 5729f464c52Smaya * A pool containing SAMPLER_BORDER_COLOR_STATE entries. 5739f464c52Smaya * 5749f464c52Smaya * See iris_border_color.c for more information. 5759f464c52Smaya */ 5769f464c52Smayastruct iris_border_color_pool { 5779f464c52Smaya struct iris_bo *bo; 5789f464c52Smaya void *map; 5799f464c52Smaya unsigned insert_point; 5809f464c52Smaya 5819f464c52Smaya /** Map from border colors to offsets in the buffer. */ 5829f464c52Smaya struct hash_table *ht; 5839f464c52Smaya}; 5849f464c52Smaya 5859f464c52Smaya/** 5869f464c52Smaya * The API context (derived from pipe_context). 5879f464c52Smaya * 5889f464c52Smaya * Most driver state is tracked here. 5899f464c52Smaya */ 5909f464c52Smayastruct iris_context { 5919f464c52Smaya struct pipe_context ctx; 5927ec681f3Smrg struct threaded_context *thrctx; 5939f464c52Smaya 5949f464c52Smaya /** A debug callback for KHR_debug output. */ 5959f464c52Smaya struct pipe_debug_callback dbg; 5969f464c52Smaya 5977ec681f3Smrg /** A device reset status callback for notifying that the GPU is hosed. */ 5987ec681f3Smrg struct pipe_device_reset_callback reset; 5997ec681f3Smrg 6007ec681f3Smrg /** A set of dmabuf resources dirtied beyond their default aux-states. */ 6017ec681f3Smrg struct set *dirty_dmabufs; 6027ec681f3Smrg 6039f464c52Smaya /** Slab allocator for iris_transfer_map objects. */ 6049f464c52Smaya struct slab_child_pool transfer_pool; 6059f464c52Smaya 6067ec681f3Smrg /** Slab allocator for threaded_context's iris_transfer_map objects */ 6077ec681f3Smrg struct slab_child_pool transfer_pool_unsync; 6089f464c52Smaya 6099f464c52Smaya struct blorp_context blorp; 6109f464c52Smaya 6119f464c52Smaya struct iris_batch batches[IRIS_BATCH_COUNT]; 6129f464c52Smaya 6139f464c52Smaya struct u_upload_mgr *query_buffer_uploader; 6149f464c52Smaya 6159f464c52Smaya struct { 6169f464c52Smaya struct { 6179f464c52Smaya /** 6189f464c52Smaya * Either the value of BaseVertex for indexed draw calls or the value 6199f464c52Smaya * of the argument <first> for non-indexed draw calls. 6209f464c52Smaya */ 6219f464c52Smaya int firstvertex; 6229f464c52Smaya int baseinstance; 6239f464c52Smaya } params; 6249f464c52Smaya 6257ec681f3Smrg /** 6267ec681f3Smrg * Are the above values the ones stored in the draw_params buffer? 6277ec681f3Smrg * If so, we can compare them against new values to see if anything 6287ec681f3Smrg * changed. If not, we need to assume they changed. 6297ec681f3Smrg */ 6307ec681f3Smrg bool params_valid; 6317ec681f3Smrg 6329f464c52Smaya /** 6339f464c52Smaya * Resource and offset that stores draw_parameters from the indirect 6349f464c52Smaya * buffer or to the buffer that stures the previous values for non 6359f464c52Smaya * indirect draws. 6369f464c52Smaya */ 6377ec681f3Smrg struct iris_state_ref draw_params; 6389f464c52Smaya 6399f464c52Smaya struct { 6409f464c52Smaya /** 6419f464c52Smaya * The value of DrawID. This always comes in from it's own vertex 6429f464c52Smaya * buffer since it's not part of the indirect draw parameters. 6439f464c52Smaya */ 6449f464c52Smaya int drawid; 6459f464c52Smaya 6469f464c52Smaya /** 6479f464c52Smaya * Stores if an indexed or non-indexed draw (~0/0). Useful to 6489f464c52Smaya * calculate BaseVertex as an AND of firstvertex and is_indexed_draw. 6499f464c52Smaya */ 6509f464c52Smaya int is_indexed_draw; 6519f464c52Smaya } derived_params; 6529f464c52Smaya 6539f464c52Smaya /** 6549f464c52Smaya * Resource and offset used for GL_ARB_shader_draw_parameters which 6559f464c52Smaya * contains parameters that are not present in the indirect buffer as 6569f464c52Smaya * drawid and is_indexed_draw. They will go in their own vertex element. 6579f464c52Smaya */ 6587ec681f3Smrg struct iris_state_ref derived_draw_params; 6599f464c52Smaya } draw; 6609f464c52Smaya 6619f464c52Smaya struct { 6629f464c52Smaya struct iris_uncompiled_shader *uncompiled[MESA_SHADER_STAGES]; 6639f464c52Smaya struct iris_compiled_shader *prog[MESA_SHADER_STAGES]; 6647ec681f3Smrg struct iris_compiled_shader *last_vue_shader; 6657ec681f3Smrg struct { 6667ec681f3Smrg unsigned size[4]; 6677ec681f3Smrg unsigned entries[4]; 6687ec681f3Smrg unsigned start[4]; 6697ec681f3Smrg bool constrained; 6707ec681f3Smrg } urb; 6717ec681f3Smrg 6727ec681f3Smrg /** Uploader for shader assembly from the driver thread */ 6737ec681f3Smrg struct u_upload_mgr *uploader_driver; 6747ec681f3Smrg /** Uploader for shader assembly from the threaded context */ 6757ec681f3Smrg struct u_upload_mgr *uploader_unsync; 6769f464c52Smaya struct hash_table *cache; 6779f464c52Smaya 6789f464c52Smaya /** Is a GS or TES outputting points or lines? */ 6799f464c52Smaya bool output_topology_is_points_or_lines; 6809f464c52Smaya 6819f464c52Smaya /** 6829f464c52Smaya * Scratch buffers for various sizes and stages. 6839f464c52Smaya * 6849f464c52Smaya * Indexed by the "Per-Thread Scratch Space" field's 4-bit encoding, 6859f464c52Smaya * and shader stage. 6869f464c52Smaya */ 6879f464c52Smaya struct iris_bo *scratch_bos[1 << 4][MESA_SHADER_STAGES]; 6887ec681f3Smrg 6897ec681f3Smrg /** 6907ec681f3Smrg * Scratch buffer surface states on Gfx12.5+ 6917ec681f3Smrg */ 6927ec681f3Smrg struct iris_state_ref scratch_surfs[1 << 4]; 6939f464c52Smaya } shaders; 6949f464c52Smaya 6957ec681f3Smrg struct intel_perf_context *perf_ctx; 6967ec681f3Smrg 6977ec681f3Smrg /** Frame number for debug prints */ 6987ec681f3Smrg uint32_t frame; 6999f464c52Smaya 7009f464c52Smaya struct { 7019f464c52Smaya uint64_t dirty; 7027ec681f3Smrg uint64_t stage_dirty; 7037ec681f3Smrg uint64_t stage_dirty_for_nos[IRIS_NOS_COUNT]; 7049f464c52Smaya 7059f464c52Smaya unsigned num_viewports; 7069f464c52Smaya unsigned sample_mask; 7079f464c52Smaya struct iris_blend_state *cso_blend; 7089f464c52Smaya struct iris_rasterizer_state *cso_rast; 7099f464c52Smaya struct iris_depth_stencil_alpha_state *cso_zsa; 7109f464c52Smaya struct iris_vertex_element_state *cso_vertex_elements; 7119f464c52Smaya struct pipe_blend_color blend_color; 7129f464c52Smaya struct pipe_poly_stipple poly_stipple; 7139f464c52Smaya struct pipe_viewport_state viewports[IRIS_MAX_VIEWPORTS]; 7149f464c52Smaya struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS]; 7159f464c52Smaya struct pipe_stencil_ref stencil_ref; 7169f464c52Smaya struct pipe_framebuffer_state framebuffer; 7179f464c52Smaya struct pipe_clip_state clip_planes; 7189f464c52Smaya 7199f464c52Smaya float default_outer_level[4]; 7209f464c52Smaya float default_inner_level[2]; 7219f464c52Smaya 7229f464c52Smaya /** Bitfield of which vertex buffers are bound (non-null). */ 7239f464c52Smaya uint64_t bound_vertex_buffers; 7249f464c52Smaya 7257ec681f3Smrg uint8_t patch_vertices; 7269f464c52Smaya bool primitive_restart; 7279f464c52Smaya unsigned cut_index; 7289f464c52Smaya enum pipe_prim_type prim_mode:8; 7299f464c52Smaya bool prim_is_points_or_lines; 7309f464c52Smaya uint8_t vertices_per_patch; 7319f464c52Smaya 7327ec681f3Smrg bool window_space_position; 7337ec681f3Smrg 7347ec681f3Smrg /** The last compute group size */ 7357ec681f3Smrg uint32_t last_block[3]; 7367ec681f3Smrg 7379f464c52Smaya /** The last compute grid size */ 7389f464c52Smaya uint32_t last_grid[3]; 7399f464c52Smaya /** Reference to the BO containing the compute grid size */ 7409f464c52Smaya struct iris_state_ref grid_size; 7419f464c52Smaya /** Reference to the SURFACE_STATE for the compute grid resource */ 7429f464c52Smaya struct iris_state_ref grid_surf_state; 7439f464c52Smaya 7449f464c52Smaya /** 7459f464c52Smaya * Array of aux usages for drawing, altered to account for any 7469f464c52Smaya * self-dependencies from resources bound for sampling and rendering. 7479f464c52Smaya */ 7489f464c52Smaya enum isl_aux_usage draw_aux_usage[BRW_MAX_DRAW_BUFFERS]; 7499f464c52Smaya 7507ec681f3Smrg /** Aux usage of the fb's depth buffer (which may or may not exist). */ 7517ec681f3Smrg enum isl_aux_usage hiz_usage; 7527ec681f3Smrg 7537ec681f3Smrg enum intel_urb_deref_block_size urb_deref_block_size; 7549f464c52Smaya 7559f464c52Smaya /** Are depth writes enabled? (Depth buffer may or may not exist.) */ 7569f464c52Smaya bool depth_writes_enabled; 7579f464c52Smaya 7589f464c52Smaya /** Are stencil writes enabled? (Stencil buffer may or may not exist.) */ 7599f464c52Smaya bool stencil_writes_enabled; 7609f464c52Smaya 7619f464c52Smaya /** GenX-specific current state */ 7629f464c52Smaya struct iris_genx_state *genx; 7639f464c52Smaya 7649f464c52Smaya struct iris_shader_state shaders[MESA_SHADER_STAGES]; 7659f464c52Smaya 7669f464c52Smaya /** Do vertex shader uses shader draw parameters ? */ 7679f464c52Smaya bool vs_uses_draw_params; 7689f464c52Smaya bool vs_uses_derived_draw_params; 7699f464c52Smaya bool vs_needs_sgvs_element; 7709f464c52Smaya 7719f464c52Smaya /** Do vertex shader uses edge flag ? */ 7729f464c52Smaya bool vs_needs_edge_flag; 7739f464c52Smaya 7749f464c52Smaya /** Do any samplers need border color? One bit per shader stage. */ 7759f464c52Smaya uint8_t need_border_colors; 7769f464c52Smaya 7777ec681f3Smrg /** Global resource bindings */ 7787ec681f3Smrg struct pipe_resource *global_bindings[IRIS_MAX_GLOBAL_BINDINGS]; 7797ec681f3Smrg 7809f464c52Smaya struct pipe_stream_output_target *so_target[PIPE_MAX_SO_BUFFERS]; 7819f464c52Smaya bool streamout_active; 7829f464c52Smaya 7839f464c52Smaya bool statistics_counters_enabled; 7849f464c52Smaya 7859f464c52Smaya /** Current conditional rendering mode */ 7869f464c52Smaya enum iris_predicate_state predicate; 7879f464c52Smaya 7889f464c52Smaya /** 7899f464c52Smaya * Query BO with a MI_PREDICATE_RESULT snapshot calculated on the 7909f464c52Smaya * render context that needs to be uploaded to the compute context. 7919f464c52Smaya */ 7929f464c52Smaya struct iris_bo *compute_predicate; 7939f464c52Smaya 7949f464c52Smaya /** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */ 7959f464c52Smaya bool prims_generated_query_active; 7969f464c52Smaya 7979f464c52Smaya /** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */ 7989f464c52Smaya uint32_t *streamout; 7999f464c52Smaya 8009f464c52Smaya /** The SURFACE_STATE for a 1x1x1 null surface. */ 8019f464c52Smaya struct iris_state_ref unbound_tex; 8029f464c52Smaya 8039f464c52Smaya /** The SURFACE_STATE for a framebuffer-sized null surface. */ 8049f464c52Smaya struct iris_state_ref null_fb; 8059f464c52Smaya 8069f464c52Smaya struct u_upload_mgr *surface_uploader; 8077ec681f3Smrg struct u_upload_mgr *bindless_uploader; 8089f464c52Smaya struct u_upload_mgr *dynamic_uploader; 8099f464c52Smaya 8109f464c52Smaya struct iris_binder binder; 8119f464c52Smaya 8129f464c52Smaya struct iris_border_color_pool border_color_pool; 8139f464c52Smaya 8149f464c52Smaya /** The high 16-bits of the last VBO/index buffer addresses */ 8159f464c52Smaya uint16_t last_vbo_high_bits[33]; 8169f464c52Smaya uint16_t last_index_bo_high_bits; 8179f464c52Smaya 8189f464c52Smaya /** 8199f464c52Smaya * Resources containing streamed state which our render context 8209f464c52Smaya * currently points to. Used to re-add these to the validation 8219f464c52Smaya * list when we start a new batch and haven't resubmitted commands. 8229f464c52Smaya */ 8239f464c52Smaya struct { 8249f464c52Smaya struct pipe_resource *cc_vp; 8259f464c52Smaya struct pipe_resource *sf_cl_vp; 8269f464c52Smaya struct pipe_resource *color_calc; 8279f464c52Smaya struct pipe_resource *scissor; 8289f464c52Smaya struct pipe_resource *blend; 8299f464c52Smaya struct pipe_resource *index_buffer; 8307ec681f3Smrg struct pipe_resource *cs_thread_ids; 8317ec681f3Smrg struct pipe_resource *cs_desc; 8329f464c52Smaya } last_res; 8337ec681f3Smrg 8347ec681f3Smrg /** Records the size of variable-length state for INTEL_DEBUG=bat */ 8357ec681f3Smrg struct hash_table_u64 *sizes; 8367ec681f3Smrg 8377ec681f3Smrg /** Last rendering scale argument provided to genX(emit_hashing_mode). */ 8387ec681f3Smrg unsigned current_hash_scale; 8399f464c52Smaya } state; 8409f464c52Smaya}; 8419f464c52Smaya 8429f464c52Smaya#define perf_debug(dbg, ...) do { \ 8437ec681f3Smrg if (INTEL_DEBUG(DEBUG_PERF)) \ 8449f464c52Smaya dbg_printf(__VA_ARGS__); \ 8459f464c52Smaya if (unlikely(dbg)) \ 8469f464c52Smaya pipe_debug_message(dbg, PERF_INFO, __VA_ARGS__); \ 8479f464c52Smaya} while(0) 8489f464c52Smaya 8499f464c52Smayastruct pipe_context * 8509f464c52Smayairis_create_context(struct pipe_screen *screen, void *priv, unsigned flags); 8517ec681f3Smrgvoid iris_destroy_context(struct pipe_context *ctx); 8527ec681f3Smrg 8537ec681f3Smrgvoid iris_lost_context_state(struct iris_batch *batch); 8547ec681f3Smrg 8557ec681f3Smrgvoid iris_mark_dirty_dmabuf(struct iris_context *ice, 8567ec681f3Smrg struct pipe_resource *res); 8577ec681f3Smrgvoid iris_flush_dirty_dmabufs(struct iris_context *ice); 8589f464c52Smaya 8599f464c52Smayavoid iris_init_blit_functions(struct pipe_context *ctx); 8609f464c52Smayavoid iris_init_clear_functions(struct pipe_context *ctx); 8619f464c52Smayavoid iris_init_program_functions(struct pipe_context *ctx); 8627ec681f3Smrgvoid iris_init_screen_program_functions(struct pipe_screen *pscreen); 8639f464c52Smayavoid iris_init_resource_functions(struct pipe_context *ctx); 8647ec681f3Smrgvoid iris_init_perfquery_functions(struct pipe_context *ctx); 8659f464c52Smayavoid iris_update_compiled_shaders(struct iris_context *ice); 8669f464c52Smayavoid iris_update_compiled_compute_shader(struct iris_context *ice); 8679f464c52Smayavoid iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data, 8687ec681f3Smrg unsigned threads, 8699f464c52Smaya uint32_t *dst); 8709f464c52Smaya 8719f464c52Smaya 8729f464c52Smaya/* iris_blit.c */ 8737ec681f3Smrgvoid iris_blorp_surf_for_resource(struct isl_device *isl_dev, 8749f464c52Smaya struct blorp_surf *surf, 8759f464c52Smaya struct pipe_resource *p_res, 8769f464c52Smaya enum isl_aux_usage aux_usage, 8779f464c52Smaya unsigned level, 8789f464c52Smaya bool is_render_target); 8799f464c52Smayavoid iris_copy_region(struct blorp_context *blorp, 8809f464c52Smaya struct iris_batch *batch, 8819f464c52Smaya struct pipe_resource *dst, 8829f464c52Smaya unsigned dst_level, 8839f464c52Smaya unsigned dstx, unsigned dsty, unsigned dstz, 8849f464c52Smaya struct pipe_resource *src, 8859f464c52Smaya unsigned src_level, 8869f464c52Smaya const struct pipe_box *src_box); 8879f464c52Smaya 8889f464c52Smaya/* iris_draw.c */ 8899f464c52Smaya 8907ec681f3Smrgvoid iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info, 8917ec681f3Smrg unsigned drawid_offset, 8927ec681f3Smrg const struct pipe_draw_indirect_info *indirect, 8937ec681f3Smrg const struct pipe_draw_start_count_bias *draws, 8947ec681f3Smrg unsigned num_draws); 8959f464c52Smayavoid iris_launch_grid(struct pipe_context *, const struct pipe_grid_info *); 8969f464c52Smaya 8979f464c52Smaya/* iris_pipe_control.c */ 8989f464c52Smaya 8999f464c52Smayavoid iris_emit_pipe_control_flush(struct iris_batch *batch, 9007ec681f3Smrg const char *reason, uint32_t flags); 9017ec681f3Smrgvoid iris_emit_pipe_control_write(struct iris_batch *batch, 9027ec681f3Smrg const char *reason, uint32_t flags, 9039f464c52Smaya struct iris_bo *bo, uint32_t offset, 9049f464c52Smaya uint64_t imm); 9059f464c52Smayavoid iris_emit_end_of_pipe_sync(struct iris_batch *batch, 9067ec681f3Smrg const char *reason, uint32_t flags); 9077ec681f3Smrgvoid iris_emit_buffer_barrier_for(struct iris_batch *batch, 9087ec681f3Smrg struct iris_bo *bo, 9097ec681f3Smrg enum iris_domain access); 9107ec681f3Smrgvoid iris_flush_all_caches(struct iris_batch *batch); 9119f464c52Smaya 9127ec681f3Smrg#define iris_handle_always_flush_cache(batch) \ 9137ec681f3Smrg if (unlikely(batch->screen->driconf.always_flush_cache)) \ 9147ec681f3Smrg iris_flush_all_caches(batch); 9159f464c52Smaya 9167ec681f3Smrgvoid iris_init_flush_functions(struct pipe_context *ctx); 9179f464c52Smaya 9189f464c52Smaya/* iris_border_color.c */ 9199f464c52Smaya 9209f464c52Smayavoid iris_init_border_color_pool(struct iris_context *ice); 9219f464c52Smayavoid iris_destroy_border_color_pool(struct iris_context *ice); 9229f464c52Smayavoid iris_border_color_pool_reserve(struct iris_context *ice, unsigned count); 9239f464c52Smayauint32_t iris_upload_border_color(struct iris_context *ice, 9249f464c52Smaya union pipe_color_union *color); 9259f464c52Smaya 9269f464c52Smaya/* iris_program.c */ 9277ec681f3Smrgvoid iris_upload_ubo_ssbo_surf_state(struct iris_context *ice, 9287ec681f3Smrg struct pipe_shader_buffer *buf, 9297ec681f3Smrg struct iris_state_ref *surf_state, 9307ec681f3Smrg isl_surf_usage_flags_t usage); 9319f464c52Smayaconst struct shader_info *iris_get_shader_info(const struct iris_context *ice, 9329f464c52Smaya gl_shader_stage stage); 9339f464c52Smayastruct iris_bo *iris_get_scratch_space(struct iris_context *ice, 9349f464c52Smaya unsigned per_thread_scratch, 9359f464c52Smaya gl_shader_stage stage); 9367ec681f3Smrgconst struct iris_state_ref *iris_get_scratch_surf(struct iris_context *ice, 9377ec681f3Smrg unsigned per_thread_scratch); 9387ec681f3Smrguint32_t iris_group_index_to_bti(const struct iris_binding_table *bt, 9397ec681f3Smrg enum iris_surface_group group, 9407ec681f3Smrg uint32_t index); 9417ec681f3Smrguint32_t iris_bti_to_group_index(const struct iris_binding_table *bt, 9427ec681f3Smrg enum iris_surface_group group, 9437ec681f3Smrg uint32_t bti); 9447ec681f3Smrg 9457ec681f3Smrg/* iris_disk_cache.c */ 9467ec681f3Smrg 9477ec681f3Smrgvoid iris_disk_cache_store(struct disk_cache *cache, 9487ec681f3Smrg const struct iris_uncompiled_shader *ish, 9497ec681f3Smrg const struct iris_compiled_shader *shader, 9507ec681f3Smrg const void *prog_key, 9517ec681f3Smrg uint32_t prog_key_size); 9527ec681f3Smrgbool 9537ec681f3Smrgiris_disk_cache_retrieve(struct iris_screen *screen, 9547ec681f3Smrg struct u_upload_mgr *uploader, 9557ec681f3Smrg struct iris_uncompiled_shader *ish, 9567ec681f3Smrg struct iris_compiled_shader *shader, 9577ec681f3Smrg const void *prog_key, 9587ec681f3Smrg uint32_t prog_key_size); 9599f464c52Smaya 9609f464c52Smaya/* iris_program_cache.c */ 9619f464c52Smaya 9629f464c52Smayavoid iris_init_program_cache(struct iris_context *ice); 9639f464c52Smayavoid iris_destroy_program_cache(struct iris_context *ice); 9649f464c52Smayastruct iris_compiled_shader *iris_find_cached_shader(struct iris_context *ice, 9659f464c52Smaya enum iris_program_cache_id, 9669f464c52Smaya uint32_t key_size, 9679f464c52Smaya const void *key); 9687ec681f3Smrg 9697ec681f3Smrgstruct iris_compiled_shader *iris_create_shader_variant(const struct iris_screen *, 9707ec681f3Smrg void *mem_ctx, 9717ec681f3Smrg enum iris_program_cache_id cache_id, 9727ec681f3Smrg uint32_t key_size, 9737ec681f3Smrg const void *key); 9747ec681f3Smrg 9757ec681f3Smrgvoid iris_finalize_program(struct iris_compiled_shader *shader, 9767ec681f3Smrg struct brw_stage_prog_data *prog_data, 9777ec681f3Smrg uint32_t *streamout, 9787ec681f3Smrg enum brw_param_builtin *system_values, 9797ec681f3Smrg unsigned num_system_values, 9807ec681f3Smrg unsigned kernel_input_size, 9817ec681f3Smrg unsigned num_cbufs, 9827ec681f3Smrg const struct iris_binding_table *bt); 9837ec681f3Smrg 9847ec681f3Smrgvoid iris_upload_shader(struct iris_screen *screen, 9857ec681f3Smrg struct iris_uncompiled_shader *, 9867ec681f3Smrg struct iris_compiled_shader *, 9877ec681f3Smrg struct hash_table *driver_ht, 9887ec681f3Smrg struct u_upload_mgr *uploader, 9897ec681f3Smrg enum iris_program_cache_id, 9907ec681f3Smrg uint32_t key_size, 9917ec681f3Smrg const void *key, 9927ec681f3Smrg const void *assembly); 9937ec681f3Smrgvoid iris_delete_shader_variant(struct iris_compiled_shader *shader); 9947ec681f3Smrg 9957ec681f3Smrgvoid iris_destroy_shader_state(struct pipe_context *ctx, void *state); 9967ec681f3Smrg 9977ec681f3Smrgstatic inline void 9987ec681f3Smrgiris_uncompiled_shader_reference(struct pipe_context *ctx, 9997ec681f3Smrg struct iris_uncompiled_shader **dst, 10007ec681f3Smrg struct iris_uncompiled_shader *src) 10017ec681f3Smrg{ 10027ec681f3Smrg if (*dst == src) 10037ec681f3Smrg return; 10047ec681f3Smrg 10057ec681f3Smrg struct iris_uncompiled_shader *old_dst = *dst; 10067ec681f3Smrg 10077ec681f3Smrg if (pipe_reference(old_dst != NULL ? &old_dst->ref : NULL, 10087ec681f3Smrg src != NULL ? &src->ref : NULL)) { 10097ec681f3Smrg iris_destroy_shader_state(ctx, *dst); 10107ec681f3Smrg } 10117ec681f3Smrg 10127ec681f3Smrg *dst = src; 10137ec681f3Smrg} 10147ec681f3Smrg 10157ec681f3Smrgstatic inline void 10167ec681f3Smrgiris_shader_variant_reference(struct iris_compiled_shader **dst, 10177ec681f3Smrg struct iris_compiled_shader *src) 10187ec681f3Smrg{ 10197ec681f3Smrg struct iris_compiled_shader *old_dst = *dst; 10207ec681f3Smrg 10217ec681f3Smrg if (pipe_reference(old_dst ? &old_dst->ref: NULL, src ? &src->ref : NULL)) 10227ec681f3Smrg iris_delete_shader_variant(old_dst); 10237ec681f3Smrg 10247ec681f3Smrg *dst = src; 10257ec681f3Smrg} 10267ec681f3Smrg 10279f464c52Smayabool iris_blorp_lookup_shader(struct blorp_batch *blorp_batch, 10289f464c52Smaya const void *key, 10299f464c52Smaya uint32_t key_size, 10309f464c52Smaya uint32_t *kernel_out, 10319f464c52Smaya void *prog_data_out); 10327ec681f3Smrgbool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage, 10339f464c52Smaya const void *key, uint32_t key_size, 10349f464c52Smaya const void *kernel, uint32_t kernel_size, 10359f464c52Smaya const struct brw_stage_prog_data *prog_data, 10369f464c52Smaya uint32_t prog_data_size, 10379f464c52Smaya uint32_t *kernel_out, 10389f464c52Smaya void *prog_data_out); 10399f464c52Smaya 10409f464c52Smaya/* iris_resolve.c */ 10419f464c52Smaya 10429f464c52Smayavoid iris_predraw_resolve_inputs(struct iris_context *ice, 10439f464c52Smaya struct iris_batch *batch, 10449f464c52Smaya bool *draw_aux_buffer_disabled, 10459f464c52Smaya gl_shader_stage stage, 10469f464c52Smaya bool consider_framebuffer); 10479f464c52Smayavoid iris_predraw_resolve_framebuffer(struct iris_context *ice, 10489f464c52Smaya struct iris_batch *batch, 10499f464c52Smaya bool *draw_aux_buffer_disabled); 10507ec681f3Smrgvoid iris_predraw_flush_buffers(struct iris_context *ice, 10517ec681f3Smrg struct iris_batch *batch, 10527ec681f3Smrg gl_shader_stage stage); 10539f464c52Smayavoid iris_postdraw_update_resolve_tracking(struct iris_context *ice, 10549f464c52Smaya struct iris_batch *batch); 10559f464c52Smayavoid iris_cache_flush_for_render(struct iris_batch *batch, 10569f464c52Smaya struct iris_bo *bo, 10579f464c52Smaya enum isl_aux_usage aux_usage); 10587ec681f3Smrgint iris_get_driver_query_info(struct pipe_screen *pscreen, unsigned index, 10597ec681f3Smrg struct pipe_driver_query_info *info); 10607ec681f3Smrgint iris_get_driver_query_group_info(struct pipe_screen *pscreen, 10617ec681f3Smrg unsigned index, 10627ec681f3Smrg struct pipe_driver_query_group_info *info); 10639f464c52Smaya 10649f464c52Smaya/* iris_state.c */ 10657ec681f3Smrgvoid gfx9_toggle_preemption(struct iris_context *ice, 10669f464c52Smaya struct iris_batch *batch, 10679f464c52Smaya const struct pipe_draw_info *draw); 10687ec681f3Smrg 10697ec681f3Smrg 10707ec681f3Smrg 10717ec681f3Smrg#ifdef genX 10727ec681f3Smrg# include "iris_genx_protos.h" 10737ec681f3Smrg#else 10747ec681f3Smrg# define genX(x) gfx4_##x 10757ec681f3Smrg# include "iris_genx_protos.h" 10767ec681f3Smrg# undef genX 10777ec681f3Smrg# define genX(x) gfx5_##x 10787ec681f3Smrg# include "iris_genx_protos.h" 10797ec681f3Smrg# undef genX 10807ec681f3Smrg# define genX(x) gfx6_##x 10817ec681f3Smrg# include "iris_genx_protos.h" 10827ec681f3Smrg# undef genX 10837ec681f3Smrg# define genX(x) gfx7_##x 10847ec681f3Smrg# include "iris_genx_protos.h" 10857ec681f3Smrg# undef genX 10867ec681f3Smrg# define genX(x) gfx75_##x 10877ec681f3Smrg# include "iris_genx_protos.h" 10887ec681f3Smrg# undef genX 10897ec681f3Smrg# define genX(x) gfx8_##x 10907ec681f3Smrg# include "iris_genx_protos.h" 10917ec681f3Smrg# undef genX 10927ec681f3Smrg# define genX(x) gfx9_##x 10937ec681f3Smrg# include "iris_genx_protos.h" 10947ec681f3Smrg# undef genX 10957ec681f3Smrg# define genX(x) gfx11_##x 10967ec681f3Smrg# include "iris_genx_protos.h" 10977ec681f3Smrg# undef genX 10987ec681f3Smrg# define genX(x) gfx12_##x 10997ec681f3Smrg# include "iris_genx_protos.h" 11007ec681f3Smrg# undef genX 11017ec681f3Smrg# define genX(x) gfx125_##x 11027ec681f3Smrg# include "iris_genx_protos.h" 11037ec681f3Smrg# undef genX 11047ec681f3Smrg#endif 11057ec681f3Smrg 11069f464c52Smaya#endif 1107