2017-11-23 23:15:14 -08:00
|
|
|
/*
|
|
|
|
* Copyright © 2017 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* on the rights to use, copy, modify, merge, publish, distribute, sub
|
|
|
|
* license, and/or sell copies of the Software, and to permit persons to whom
|
|
|
|
* the Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
|
|
|
|
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
|
|
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
|
|
* USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef IRIS_CONTEXT_H
|
|
|
|
#define IRIS_CONTEXT_H
|
|
|
|
|
|
|
|
#include "pipe/p_context.h"
|
|
|
|
#include "pipe/p_state.h"
|
2020-10-29 15:32:32 -07:00
|
|
|
#include "util/set.h"
|
2020-03-30 10:37:29 -04:00
|
|
|
#include "util/slab.h"
|
2017-11-23 23:15:14 -08:00
|
|
|
#include "util/u_debug.h"
|
2021-02-08 16:39:42 -08:00
|
|
|
#include "util/u_threaded_context.h"
|
2018-04-21 22:20:32 -07:00
|
|
|
#include "intel/blorp/blorp.h"
|
2021-04-05 10:44:41 -07:00
|
|
|
#include "intel/dev/intel_debug.h"
|
2021-03-03 13:20:06 -08:00
|
|
|
#include "intel/common/intel_l3_config.h"
|
2018-01-25 02:03:18 -08:00
|
|
|
#include "intel/compiler/brw_compiler.h"
|
2018-01-19 18:25:55 -08:00
|
|
|
#include "iris_batch.h"
|
2018-09-08 19:43:34 -07:00
|
|
|
#include "iris_binder.h"
|
2018-11-07 11:50:02 +00:00
|
|
|
#include "iris_fence.h"
|
2018-06-28 00:57:49 -07:00
|
|
|
#include "iris_resource.h"
|
2017-11-23 23:15:14 -08:00
|
|
|
#include "iris_screen.h"
|
|
|
|
|
|
|
|
struct iris_bo;
|
2018-04-20 23:28:03 -07:00
|
|
|
struct iris_context;
|
2018-04-21 00:05:57 -07:00
|
|
|
struct blorp_batch;
|
|
|
|
struct blorp_params;
|
2017-11-23 23:15:14 -08:00
|
|
|
|
2018-10-22 14:28:54 -07:00
|
|
|
#define IRIS_MAX_TEXTURE_BUFFER_SIZE (1 << 27)
|
2017-11-23 23:15:14 -08:00
|
|
|
#define IRIS_MAX_TEXTURE_SAMPLERS 32
|
2018-07-24 17:44:09 -07:00
|
|
|
/* IRIS_MAX_ABOS and IRIS_MAX_SSBOS must be the same. */
|
|
|
|
#define IRIS_MAX_ABOS 16
|
|
|
|
#define IRIS_MAX_SSBOS 16
|
2017-11-23 23:15:14 -08:00
|
|
|
#define IRIS_MAX_VIEWPORTS 16
|
2018-12-27 01:27:44 -08:00
|
|
|
#define IRIS_MAX_CLIP_PLANES 8
|
2018-10-25 17:53:23 -05:00
|
|
|
#define IRIS_MAX_GLOBAL_BINDINGS 32
|
2017-11-23 23:15:14 -08:00
|
|
|
|
2018-11-30 02:27:07 -08:00
|
|
|
enum iris_param_domain {
|
|
|
|
BRW_PARAM_DOMAIN_BUILTIN = 0,
|
|
|
|
BRW_PARAM_DOMAIN_IMAGE,
|
|
|
|
};
|
|
|
|
|
2019-08-28 14:46:16 +03:00
|
|
|
enum {
|
|
|
|
DRI_CONF_BO_REUSE_DISABLED,
|
|
|
|
DRI_CONF_BO_REUSE_ALL
|
|
|
|
};
|
|
|
|
|
2018-11-30 02:27:07 -08:00
|
|
|
#define BRW_PARAM(domain, val) (BRW_PARAM_DOMAIN_##domain << 24 | (val))
|
|
|
|
#define BRW_PARAM_DOMAIN(param) ((uint32_t)(param) >> 24)
|
|
|
|
#define BRW_PARAM_VALUE(param) ((uint32_t)(param) & 0x00ffffff)
|
|
|
|
#define BRW_PARAM_IMAGE(idx, offset) BRW_PARAM(IMAGE, ((idx) << 8) | (offset))
|
|
|
|
#define BRW_PARAM_IMAGE_IDX(value) (BRW_PARAM_VALUE(value) >> 8)
|
|
|
|
#define BRW_PARAM_IMAGE_OFFSET(value)(BRW_PARAM_VALUE(value) & 0xf)
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* Dirty flags. When state changes, we flag some combination of these
|
|
|
|
* to indicate that particular GPU commands need to be re-emitted.
|
|
|
|
*
|
|
|
|
* Each bit typically corresponds to a single 3DSTATE_* command packet, but
|
|
|
|
* in rare cases they map to a group of related packets that need to be
|
|
|
|
* emitted together.
|
|
|
|
*
|
|
|
|
* See iris_upload_render_state().
|
|
|
|
*/
|
2020-05-29 16:57:01 -07:00
|
|
|
#define IRIS_DIRTY_COLOR_CALC_STATE (1ull << 0)
|
|
|
|
#define IRIS_DIRTY_POLYGON_STIPPLE (1ull << 1)
|
|
|
|
#define IRIS_DIRTY_SCISSOR_RECT (1ull << 2)
|
|
|
|
#define IRIS_DIRTY_WM_DEPTH_STENCIL (1ull << 3)
|
|
|
|
#define IRIS_DIRTY_CC_VIEWPORT (1ull << 4)
|
|
|
|
#define IRIS_DIRTY_SF_CL_VIEWPORT (1ull << 5)
|
|
|
|
#define IRIS_DIRTY_PS_BLEND (1ull << 6)
|
|
|
|
#define IRIS_DIRTY_BLEND_STATE (1ull << 7)
|
|
|
|
#define IRIS_DIRTY_RASTER (1ull << 8)
|
|
|
|
#define IRIS_DIRTY_CLIP (1ull << 9)
|
|
|
|
#define IRIS_DIRTY_SBE (1ull << 10)
|
|
|
|
#define IRIS_DIRTY_LINE_STIPPLE (1ull << 11)
|
|
|
|
#define IRIS_DIRTY_VERTEX_ELEMENTS (1ull << 12)
|
|
|
|
#define IRIS_DIRTY_MULTISAMPLE (1ull << 13)
|
|
|
|
#define IRIS_DIRTY_VERTEX_BUFFERS (1ull << 14)
|
|
|
|
#define IRIS_DIRTY_SAMPLE_MASK (1ull << 15)
|
|
|
|
#define IRIS_DIRTY_URB (1ull << 16)
|
|
|
|
#define IRIS_DIRTY_DEPTH_BUFFER (1ull << 17)
|
|
|
|
#define IRIS_DIRTY_WM (1ull << 18)
|
|
|
|
#define IRIS_DIRTY_SO_BUFFERS (1ull << 19)
|
|
|
|
#define IRIS_DIRTY_SO_DECL_LIST (1ull << 20)
|
|
|
|
#define IRIS_DIRTY_STREAMOUT (1ull << 21)
|
|
|
|
#define IRIS_DIRTY_VF_SGVS (1ull << 22)
|
|
|
|
#define IRIS_DIRTY_VF (1ull << 23)
|
|
|
|
#define IRIS_DIRTY_VF_TOPOLOGY (1ull << 24)
|
|
|
|
#define IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES (1ull << 25)
|
|
|
|
#define IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES (1ull << 26)
|
|
|
|
#define IRIS_DIRTY_VF_STATISTICS (1ull << 27)
|
|
|
|
#define IRIS_DIRTY_PMA_FIX (1ull << 28)
|
|
|
|
#define IRIS_DIRTY_DEPTH_BOUNDS (1ull << 29)
|
|
|
|
#define IRIS_DIRTY_RENDER_BUFFER (1ull << 30)
|
|
|
|
#define IRIS_DIRTY_STENCIL_REF (1ull << 31)
|
|
|
|
|
|
|
|
#define IRIS_ALL_DIRTY_FOR_COMPUTE (IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES)
|
|
|
|
|
|
|
|
#define IRIS_ALL_DIRTY_FOR_RENDER (~IRIS_ALL_DIRTY_FOR_COMPUTE)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Per-stage dirty flags. When state changes, we flag some combination of
|
|
|
|
* these to indicate that particular GPU commands need to be re-emitted.
|
|
|
|
* Unlike the IRIS_DIRTY_* flags these are shader stage-specific and can be
|
|
|
|
* indexed by shifting the mask by the shader stage index.
|
|
|
|
*
|
|
|
|
* See iris_upload_render_state().
|
|
|
|
*/
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_VS (1ull << 0)
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TCS (1ull << 1)
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TES (1ull << 2)
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_GS (1ull << 3)
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_PS (1ull << 4)
|
|
|
|
#define IRIS_STAGE_DIRTY_SAMPLER_STATES_CS (1ull << 5)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_VS (1ull << 6)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_TCS (1ull << 7)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_TES (1ull << 8)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_GS (1ull << 9)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_FS (1ull << 10)
|
|
|
|
#define IRIS_STAGE_DIRTY_UNCOMPILED_CS (1ull << 11)
|
|
|
|
#define IRIS_STAGE_DIRTY_VS (1ull << 12)
|
|
|
|
#define IRIS_STAGE_DIRTY_TCS (1ull << 13)
|
|
|
|
#define IRIS_STAGE_DIRTY_TES (1ull << 14)
|
|
|
|
#define IRIS_STAGE_DIRTY_GS (1ull << 15)
|
|
|
|
#define IRIS_STAGE_DIRTY_FS (1ull << 16)
|
|
|
|
#define IRIS_STAGE_DIRTY_CS (1ull << 17)
|
|
|
|
#define IRIS_SHIFT_FOR_STAGE_DIRTY_CONSTANTS 18
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_VS (1ull << 18)
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_TCS (1ull << 19)
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_TES (1ull << 20)
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_GS (1ull << 21)
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_FS (1ull << 22)
|
|
|
|
#define IRIS_STAGE_DIRTY_CONSTANTS_CS (1ull << 23)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_VS (1ull << 24)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_TCS (1ull << 25)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_TES (1ull << 26)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_GS (1ull << 27)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_FS (1ull << 28)
|
|
|
|
#define IRIS_STAGE_DIRTY_BINDINGS_CS (1ull << 29)
|
|
|
|
|
|
|
|
#define IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE (IRIS_STAGE_DIRTY_CS | \
|
|
|
|
IRIS_STAGE_DIRTY_SAMPLER_STATES_CS | \
|
|
|
|
IRIS_STAGE_DIRTY_UNCOMPILED_CS | \
|
|
|
|
IRIS_STAGE_DIRTY_CONSTANTS_CS | \
|
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_CS)
|
|
|
|
|
|
|
|
#define IRIS_ALL_STAGE_DIRTY_FOR_RENDER (~IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE)
|
|
|
|
|
2021-07-03 10:04:47 +10:00
|
|
|
#define IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER (IRIS_STAGE_DIRTY_BINDINGS_VS | \
|
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_TCS | \
|
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_TES | \
|
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_GS | \
|
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_FS)
|
|
|
|
|
|
|
|
#define IRIS_ALL_STAGE_DIRTY_BINDINGS (IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER | \
|
2020-05-29 16:57:01 -07:00
|
|
|
IRIS_STAGE_DIRTY_BINDINGS_CS)
|
2018-09-08 19:43:34 -07:00
|
|
|
|
2018-07-16 16:21:22 -07:00
|
|
|
/**
|
|
|
|
* Non-orthogonal state (NOS) dependency flags.
|
|
|
|
*
|
|
|
|
* Shader programs may depend on non-orthogonal state. These flags are
|
|
|
|
* used to indicate that a shader's key depends on the state provided by
|
2018-07-30 23:49:34 -07:00
|
|
|
* a certain Gallium CSO. Changing any CSOs marked as a dependency will
|
|
|
|
* cause the driver to re-compute the shader key, possibly triggering a
|
|
|
|
* shader recompile.
|
2018-07-16 16:21:22 -07:00
|
|
|
*/
|
|
|
|
enum iris_nos_dep {
|
|
|
|
IRIS_NOS_FRAMEBUFFER,
|
|
|
|
IRIS_NOS_DEPTH_STENCIL_ALPHA,
|
|
|
|
IRIS_NOS_RASTERIZER,
|
|
|
|
IRIS_NOS_BLEND,
|
2018-08-15 13:35:05 -07:00
|
|
|
IRIS_NOS_LAST_VUE_MAP,
|
2018-07-16 16:21:22 -07:00
|
|
|
|
|
|
|
IRIS_NOS_COUNT,
|
|
|
|
};
|
|
|
|
|
2019-12-08 20:25:42 -08:00
|
|
|
/** @{
|
|
|
|
*
|
|
|
|
* Program cache keys for state based recompiles.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct iris_base_prog_key {
|
|
|
|
unsigned program_string_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_vue_prog_key {
|
|
|
|
struct iris_base_prog_key base;
|
|
|
|
|
|
|
|
unsigned nr_userclip_plane_consts:4;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_vs_prog_key {
|
|
|
|
struct iris_vue_prog_key vue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_tcs_prog_key {
|
|
|
|
struct iris_vue_prog_key vue;
|
|
|
|
|
|
|
|
uint16_t tes_primitive_mode;
|
|
|
|
|
|
|
|
uint8_t input_vertices;
|
|
|
|
|
|
|
|
bool quads_workaround;
|
|
|
|
|
|
|
|
/** A bitfield of per-patch outputs written. */
|
|
|
|
uint32_t patch_outputs_written;
|
|
|
|
|
|
|
|
/** A bitfield of per-vertex outputs written. */
|
|
|
|
uint64_t outputs_written;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_tes_prog_key {
|
|
|
|
struct iris_vue_prog_key vue;
|
|
|
|
|
|
|
|
/** A bitfield of per-patch inputs read. */
|
|
|
|
uint32_t patch_inputs_read;
|
|
|
|
|
|
|
|
/** A bitfield of per-vertex inputs read. */
|
|
|
|
uint64_t inputs_read;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_gs_prog_key {
|
|
|
|
struct iris_vue_prog_key vue;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_fs_prog_key {
|
|
|
|
struct iris_base_prog_key base;
|
|
|
|
|
|
|
|
unsigned nr_color_regions:5;
|
|
|
|
bool flat_shade:1;
|
|
|
|
bool alpha_test_replicate_alpha:1;
|
|
|
|
bool alpha_to_coverage:1;
|
|
|
|
bool clamp_fragment_color:1;
|
|
|
|
bool persample_interp:1;
|
|
|
|
bool multisample_fbo:1;
|
|
|
|
bool force_dual_color_blend:1;
|
|
|
|
bool coherent_fb_fetch:1;
|
|
|
|
|
|
|
|
uint8_t color_outputs_valid;
|
|
|
|
uint64_t input_slots_valid;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iris_cs_prog_key {
|
|
|
|
struct iris_base_prog_key base;
|
|
|
|
};
|
|
|
|
|
iris: Store a list of shader variants in the shader itself
We've traditionally stored shader variants in a per-context hash table,
based on a key with many per-stage fields. On older hardware supported
by i965, there were potentially quite a few variants, as many features
had to be emulated in shaders, including things like texture swizzling.
However, on the modern hardware targeted by iris, our NOS dependencies
are much smaller. We almost always guess the correct state when doing
the initial precompile, and so we have maybe 1-3 variants. iris NOS
keys are also dramatically smaller (4 to 24 bytes) than i965's.
Unlike the classic world, Gallium also provides a single kind of object
for API shaders---pipe_shader_state aka iris_uncompiled_shader. We can
simply store a list of shader variants there. This makes it possible
to access shader variants across contexts, rather than compiling them
separately for each context, which better matches how the APIs work.
To look up variants, we simply walk the list and memcmp the keys.
Since the list is almost always singular (and rarely ever long),
and the keys are tiny, this should be quite low overhead.
We continue storing internally generated shaders for BLORP and
passthrough TCS in the per-context hash table, as they don't have
an associated pipe_shader_state / iris_uncompiled_shader object.
(There can also be many BLORP shaders, and the blit keys are large,
so having a hash table rather than a list makes sense there.)
Because iris_uncompiled_shaders are shared across multiple contexts,
we do require locking when accessing this list. Fortunately, this
is a per-shader lock, rather than a global one. Additionally, since
we only append variants to the list, and generate the first one at
precompile time (while only one context has the uncompiled shader),
we can assume that it is safe to access that first entry without
locking the list. This means that we only have to lock when we
have multiple variants, which is relatively uncommon.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2020-11-16 13:17:08 -08:00
|
|
|
union iris_any_prog_key {
|
|
|
|
struct iris_base_prog_key base;
|
|
|
|
struct iris_vue_prog_key vue;
|
|
|
|
struct iris_vs_prog_key vs;
|
|
|
|
struct iris_tcs_prog_key tcs;
|
|
|
|
struct iris_tes_prog_key tes;
|
|
|
|
struct iris_gs_prog_key gs;
|
|
|
|
struct iris_fs_prog_key fs;
|
|
|
|
struct iris_cs_prog_key cs;
|
|
|
|
};
|
|
|
|
|
2019-12-08 20:25:42 -08:00
|
|
|
/** @} */
|
|
|
|
|
2017-12-27 02:54:26 -08:00
|
|
|
struct iris_depth_stencil_alpha_state;
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* Cache IDs for the in-memory program cache (ice->shaders.cache).
|
|
|
|
*/
|
2018-01-25 01:36:49 -08:00
|
|
|
enum iris_program_cache_id {
|
|
|
|
IRIS_CACHE_VS = MESA_SHADER_VERTEX,
|
|
|
|
IRIS_CACHE_TCS = MESA_SHADER_TESS_CTRL,
|
|
|
|
IRIS_CACHE_TES = MESA_SHADER_TESS_EVAL,
|
|
|
|
IRIS_CACHE_GS = MESA_SHADER_GEOMETRY,
|
|
|
|
IRIS_CACHE_FS = MESA_SHADER_FRAGMENT,
|
|
|
|
IRIS_CACHE_CS = MESA_SHADER_COMPUTE,
|
2018-04-21 23:27:15 -07:00
|
|
|
IRIS_CACHE_BLORP,
|
2018-01-25 01:36:49 -08:00
|
|
|
};
|
|
|
|
|
2018-04-19 12:52:51 -07:00
|
|
|
/** @{
|
|
|
|
*
|
2018-07-30 23:49:34 -07:00
|
|
|
* Defines for PIPE_CONTROL operations, which trigger cache flushes,
|
|
|
|
* synchronization, pipelined memory writes, and so on.
|
2018-04-19 12:52:51 -07:00
|
|
|
*
|
2018-07-30 23:49:34 -07:00
|
|
|
* The bits here are not the actual hardware values. The actual fields
|
|
|
|
* move between various generations, so we just have flags for each
|
2018-04-19 12:52:51 -07:00
|
|
|
* potential operation, and use genxml to encode the actual packet.
|
|
|
|
*/
|
|
|
|
enum pipe_control_flags
|
|
|
|
{
|
|
|
|
PIPE_CONTROL_FLUSH_LLC = (1 << 1),
|
|
|
|
PIPE_CONTROL_LRI_POST_SYNC_OP = (1 << 2),
|
|
|
|
PIPE_CONTROL_STORE_DATA_INDEX = (1 << 3),
|
|
|
|
PIPE_CONTROL_CS_STALL = (1 << 4),
|
|
|
|
PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET = (1 << 5),
|
|
|
|
PIPE_CONTROL_SYNC_GFDT = (1 << 6),
|
|
|
|
PIPE_CONTROL_TLB_INVALIDATE = (1 << 7),
|
|
|
|
PIPE_CONTROL_MEDIA_STATE_CLEAR = (1 << 8),
|
|
|
|
PIPE_CONTROL_WRITE_IMMEDIATE = (1 << 9),
|
|
|
|
PIPE_CONTROL_WRITE_DEPTH_COUNT = (1 << 10),
|
|
|
|
PIPE_CONTROL_WRITE_TIMESTAMP = (1 << 11),
|
|
|
|
PIPE_CONTROL_DEPTH_STALL = (1 << 12),
|
|
|
|
PIPE_CONTROL_RENDER_TARGET_FLUSH = (1 << 13),
|
|
|
|
PIPE_CONTROL_INSTRUCTION_INVALIDATE = (1 << 14),
|
|
|
|
PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE = (1 << 15),
|
|
|
|
PIPE_CONTROL_INDIRECT_STATE_POINTERS_DISABLE = (1 << 16),
|
|
|
|
PIPE_CONTROL_NOTIFY_ENABLE = (1 << 17),
|
|
|
|
PIPE_CONTROL_FLUSH_ENABLE = (1 << 18),
|
|
|
|
PIPE_CONTROL_DATA_CACHE_FLUSH = (1 << 19),
|
|
|
|
PIPE_CONTROL_VF_CACHE_INVALIDATE = (1 << 20),
|
|
|
|
PIPE_CONTROL_CONST_CACHE_INVALIDATE = (1 << 21),
|
|
|
|
PIPE_CONTROL_STATE_CACHE_INVALIDATE = (1 << 22),
|
|
|
|
PIPE_CONTROL_STALL_AT_SCOREBOARD = (1 << 23),
|
|
|
|
PIPE_CONTROL_DEPTH_CACHE_FLUSH = (1 << 24),
|
2019-04-29 11:05:07 -07:00
|
|
|
PIPE_CONTROL_TILE_CACHE_FLUSH = (1 << 25),
|
2020-01-15 15:13:43 +02:00
|
|
|
PIPE_CONTROL_FLUSH_HDC = (1 << 26),
|
2018-04-19 12:52:51 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#define PIPE_CONTROL_CACHE_FLUSH_BITS \
|
|
|
|
(PIPE_CONTROL_DEPTH_CACHE_FLUSH | \
|
|
|
|
PIPE_CONTROL_DATA_CACHE_FLUSH | \
|
2021-03-29 17:11:42 -07:00
|
|
|
PIPE_CONTROL_TILE_CACHE_FLUSH | \
|
2018-04-19 12:52:51 -07:00
|
|
|
PIPE_CONTROL_RENDER_TARGET_FLUSH)
|
|
|
|
|
|
|
|
#define PIPE_CONTROL_CACHE_INVALIDATE_BITS \
|
|
|
|
(PIPE_CONTROL_STATE_CACHE_INVALIDATE | \
|
|
|
|
PIPE_CONTROL_CONST_CACHE_INVALIDATE | \
|
|
|
|
PIPE_CONTROL_VF_CACHE_INVALIDATE | \
|
|
|
|
PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | \
|
|
|
|
PIPE_CONTROL_INSTRUCTION_INVALIDATE)
|
|
|
|
|
2018-11-27 09:03:16 +10:00
|
|
|
enum iris_predicate_state {
|
|
|
|
/* The first two states are used if we can determine whether to draw
|
|
|
|
* without having to look at the values in the query object buffer. This
|
|
|
|
* will happen if there is no conditional render in progress, if the query
|
|
|
|
* object is already completed or if something else has already added
|
|
|
|
* samples to the preliminary result.
|
|
|
|
*/
|
|
|
|
IRIS_PREDICATE_STATE_RENDER,
|
|
|
|
IRIS_PREDICATE_STATE_DONT_RENDER,
|
|
|
|
|
|
|
|
/* In this case whether to draw or not depends on the result of an
|
|
|
|
* MI_PREDICATE command so the predicate enable bit needs to be checked.
|
|
|
|
*/
|
|
|
|
IRIS_PREDICATE_STATE_USE_BIT,
|
|
|
|
};
|
|
|
|
|
2018-04-19 12:52:51 -07:00
|
|
|
/** @} */
|
|
|
|
|
2019-05-20 23:20:45 -07:00
|
|
|
/**
|
|
|
|
* An uncompiled, API-facing shader. This is the Gallium CSO for shaders.
|
|
|
|
* It primarily contains the NIR for the shader.
|
|
|
|
*
|
|
|
|
* Each API-facing shader can be compiled into multiple shader variants,
|
|
|
|
* based on non-orthogonal state dependencies, recorded in the shader key.
|
|
|
|
*
|
|
|
|
* See iris_compiled_shader, which represents a compiled shader variant.
|
|
|
|
*/
|
|
|
|
struct iris_uncompiled_shader {
|
2021-05-19 10:38:35 -07:00
|
|
|
/**
|
|
|
|
* NIR for the shader.
|
|
|
|
*
|
|
|
|
* Even for shaders that originate as TGSI, this pointer will be non-NULL.
|
|
|
|
*/
|
2019-05-20 23:20:45 -07:00
|
|
|
struct nir_shader *nir;
|
|
|
|
|
|
|
|
struct pipe_stream_output_info stream_output;
|
|
|
|
|
2019-05-28 15:34:52 -07:00
|
|
|
/* A SHA1 of the serialized NIR for the disk cache. */
|
|
|
|
unsigned char nir_sha1[20];
|
2019-05-20 23:25:40 -07:00
|
|
|
|
2019-05-20 23:20:45 -07:00
|
|
|
unsigned program_id;
|
|
|
|
|
|
|
|
/** Bitfield of (1 << IRIS_NOS_*) flags. */
|
|
|
|
unsigned nos;
|
|
|
|
|
|
|
|
/** Have any shader variants been compiled yet? */
|
|
|
|
bool compiled_once;
|
2019-05-21 16:10:21 -07:00
|
|
|
|
|
|
|
/** Should we use ALT mode for math? Useful for ARB programs. */
|
|
|
|
bool use_alt_mode;
|
2019-05-28 17:33:58 -05:00
|
|
|
|
2019-10-23 15:38:52 -07:00
|
|
|
bool needs_edge_flag;
|
|
|
|
|
2020-03-06 08:59:16 +02:00
|
|
|
/* Whether shader uses atomic operations. */
|
|
|
|
bool uses_atomic_load_store;
|
|
|
|
|
2020-08-11 10:30:42 -05:00
|
|
|
/** Size (in bytes) of the kernel input data */
|
|
|
|
unsigned kernel_input_size;
|
2020-10-06 15:57:21 -05:00
|
|
|
|
|
|
|
/** Size (in bytes) of the local (shared) data passed as kernel inputs */
|
|
|
|
unsigned kernel_shared_size;
|
iris: Store a list of shader variants in the shader itself
We've traditionally stored shader variants in a per-context hash table,
based on a key with many per-stage fields. On older hardware supported
by i965, there were potentially quite a few variants, as many features
had to be emulated in shaders, including things like texture swizzling.
However, on the modern hardware targeted by iris, our NOS dependencies
are much smaller. We almost always guess the correct state when doing
the initial precompile, and so we have maybe 1-3 variants. iris NOS
keys are also dramatically smaller (4 to 24 bytes) than i965's.
Unlike the classic world, Gallium also provides a single kind of object
for API shaders---pipe_shader_state aka iris_uncompiled_shader. We can
simply store a list of shader variants there. This makes it possible
to access shader variants across contexts, rather than compiling them
separately for each context, which better matches how the APIs work.
To look up variants, we simply walk the list and memcmp the keys.
Since the list is almost always singular (and rarely ever long),
and the keys are tiny, this should be quite low overhead.
We continue storing internally generated shaders for BLORP and
passthrough TCS in the per-context hash table, as they don't have
an associated pipe_shader_state / iris_uncompiled_shader object.
(There can also be many BLORP shaders, and the blit keys are large,
so having a hash table rather than a list makes sense there.)
Because iris_uncompiled_shaders are shared across multiple contexts,
we do require locking when accessing this list. Fortunately, this
is a per-shader lock, rather than a global one. Additionally, since
we only append variants to the list, and generate the first one at
precompile time (while only one context has the uncompiled shader),
we can assume that it is safe to access that first entry without
locking the list. This means that we only have to lock when we
have multiple variants, which is relatively uncommon.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2020-11-16 13:17:08 -08:00
|
|
|
|
|
|
|
/** List of iris_compiled_shader variants */
|
|
|
|
struct list_head variants;
|
|
|
|
|
|
|
|
/** Lock for the variants list */
|
|
|
|
simple_mtx_t lock;
|
2019-05-20 23:20:45 -07:00
|
|
|
};
|
|
|
|
|
2019-05-23 08:44:29 -07:00
|
|
|
enum iris_surface_group {
|
|
|
|
IRIS_SURFACE_GROUP_RENDER_TARGET,
|
2019-07-16 10:27:03 -07:00
|
|
|
IRIS_SURFACE_GROUP_RENDER_TARGET_READ,
|
2019-05-23 08:44:29 -07:00
|
|
|
IRIS_SURFACE_GROUP_CS_WORK_GROUPS,
|
|
|
|
IRIS_SURFACE_GROUP_TEXTURE,
|
|
|
|
IRIS_SURFACE_GROUP_IMAGE,
|
|
|
|
IRIS_SURFACE_GROUP_UBO,
|
|
|
|
IRIS_SURFACE_GROUP_SSBO,
|
|
|
|
|
|
|
|
IRIS_SURFACE_GROUP_COUNT,
|
|
|
|
};
|
|
|
|
|
2019-05-23 14:17:59 -07:00
|
|
|
enum {
|
|
|
|
/* Invalid value for a binding table index. */
|
|
|
|
IRIS_SURFACE_NOT_USED = 0xa0a0a0a0,
|
|
|
|
};
|
|
|
|
|
2019-05-22 22:17:27 -07:00
|
|
|
struct iris_binding_table {
|
|
|
|
uint32_t size_bytes;
|
|
|
|
|
2019-05-23 14:17:59 -07:00
|
|
|
/** Number of surfaces in each group, before compacting. */
|
|
|
|
uint32_t sizes[IRIS_SURFACE_GROUP_COUNT];
|
|
|
|
|
|
|
|
/** Initial offset of each group. */
|
2019-05-23 08:44:29 -07:00
|
|
|
uint32_t offsets[IRIS_SURFACE_GROUP_COUNT];
|
2019-05-23 14:17:59 -07:00
|
|
|
|
|
|
|
/** Mask of surfaces used in each group. */
|
|
|
|
uint64_t used_mask[IRIS_SURFACE_GROUP_COUNT];
|
2019-05-22 22:17:27 -07:00
|
|
|
};
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* A compiled shader variant, containing a pointer to the GPU assembly,
|
|
|
|
* as well as program data and other packets needed by state upload.
|
|
|
|
*
|
|
|
|
* There can be several iris_compiled_shader variants per API-level shader
|
|
|
|
* (iris_uncompiled_shader), due to state-based recompiles (brw_*_prog_key).
|
|
|
|
*/
|
2018-01-22 11:52:58 -08:00
|
|
|
struct iris_compiled_shader {
|
iris: Refcount shader variants
There is a small gap of time where the currently bound uncompiled
shaders, and compiled shader variant, are out of sync. Specifically,
between pipe->bind_*_state() and the next draw.
Currently, shaders variants live entirely within a single context,
and when deleting an iris_uncompiled_shader, we check if any of its
variants are currently bound, and defer deleting those until the next
iris_update_compiled_shaders() hook runs and binds new shaders to
replace them. (This is due to the time gap between binding new
uncompiled shaders, and updating variants at draw time when we have
the required NOS in place.)
This works pretty well in a single context world. But as we move to
share compiled shader variants across multiple contexts, it breaks down.
When deleting a shader, we can't look at all contexts to see if its
variants are bound anywhere. We can't even quantify whether those
contexts will run a future draw any time soon, to update and unbind.
One fairly crazy solution would be to delete the variants anyway, and
leave the stale pointers to dead variants in place. This requires
removing any code that compares old and new variants. Today, we do
that sometimes for seeing if the old/new shaders toggled some feature.
Worse than that, though, we don't just have to avoid dereferences, we'd
have to avoid pointer comparisons. If we free a variant, and quickly
allocate a new variant, malloc may return the same pointer. If it's
for the same shader stage, we may get a new different program that has
the same pointer as a previously bound stale one, causing us to think
nothing had changed when we really needed to do updates. Again, this
is doable, but leaves the code fragile - we'd have to guard against
future patches adding such checks back in.
So, don't do that. Instead, do basic reference counting. When a
variant is bound in a context, up the reference. When it's unbound,
decrement it. When it hits zero, we know it's not bound anywhere and
is safe to delete, with no stale references. This ends up being
reasonably cheap anyway, since the atomic is usually uncontested.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2021-01-27 13:46:26 -08:00
|
|
|
struct pipe_reference ref;
|
2019-06-05 13:12:58 -07:00
|
|
|
|
iris: Store a list of shader variants in the shader itself
We've traditionally stored shader variants in a per-context hash table,
based on a key with many per-stage fields. On older hardware supported
by i965, there were potentially quite a few variants, as many features
had to be emulated in shaders, including things like texture swizzling.
However, on the modern hardware targeted by iris, our NOS dependencies
are much smaller. We almost always guess the correct state when doing
the initial precompile, and so we have maybe 1-3 variants. iris NOS
keys are also dramatically smaller (4 to 24 bytes) than i965's.
Unlike the classic world, Gallium also provides a single kind of object
for API shaders---pipe_shader_state aka iris_uncompiled_shader. We can
simply store a list of shader variants there. This makes it possible
to access shader variants across contexts, rather than compiling them
separately for each context, which better matches how the APIs work.
To look up variants, we simply walk the list and memcmp the keys.
Since the list is almost always singular (and rarely ever long),
and the keys are tiny, this should be quite low overhead.
We continue storing internally generated shaders for BLORP and
passthrough TCS in the per-context hash table, as they don't have
an associated pipe_shader_state / iris_uncompiled_shader object.
(There can also be many BLORP shaders, and the blit keys are large,
so having a hash table rather than a list makes sense there.)
Because iris_uncompiled_shaders are shared across multiple contexts,
we do require locking when accessing this list. Fortunately, this
is a per-shader lock, rather than a global one. Additionally, since
we only append variants to the list, and generate the first one at
precompile time (while only one context has the uncompiled shader),
we can assume that it is safe to access that first entry without
locking the list. This means that we only have to lock when we
have multiple variants, which is relatively uncommon.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2020-11-16 13:17:08 -08:00
|
|
|
/** Link in the iris_uncompiled_shader::variants list */
|
|
|
|
struct list_head link;
|
|
|
|
|
|
|
|
/** Key for this variant (but not for BLORP programs) */
|
|
|
|
union iris_any_prog_key key;
|
|
|
|
|
2018-06-28 00:57:49 -07:00
|
|
|
/** Reference to the uploaded assembly. */
|
|
|
|
struct iris_state_ref assembly;
|
2018-01-25 19:39:10 -08:00
|
|
|
|
|
|
|
/** Pointer to the assembly in the BO's map. */
|
|
|
|
void *map;
|
2018-01-22 11:52:58 -08:00
|
|
|
|
|
|
|
/** The program data (owned by the program cache hash table) */
|
|
|
|
struct brw_stage_prog_data *prog_data;
|
|
|
|
|
2018-11-09 02:04:23 -08:00
|
|
|
/** A list of system values to be uploaded as uniforms. */
|
|
|
|
enum brw_param_builtin *system_values;
|
|
|
|
unsigned num_system_values;
|
|
|
|
|
2020-08-11 10:07:55 -05:00
|
|
|
/** Size (in bytes) of the kernel input data */
|
|
|
|
unsigned kernel_input_size;
|
|
|
|
|
2019-01-19 11:32:37 -08:00
|
|
|
/** Number of constbufs expected by the shader. */
|
|
|
|
unsigned num_cbufs;
|
|
|
|
|
2018-06-29 12:58:31 -07:00
|
|
|
/**
|
2018-07-11 12:45:19 -07:00
|
|
|
* Derived 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets
|
|
|
|
* (the VUE-based information for transform feedback outputs).
|
2018-06-29 12:58:31 -07:00
|
|
|
*/
|
2018-07-11 12:45:19 -07:00
|
|
|
uint32_t *streamout;
|
2018-06-29 12:58:31 -07:00
|
|
|
|
2019-05-22 22:17:27 -07:00
|
|
|
struct iris_binding_table bt;
|
|
|
|
|
2018-01-22 11:52:58 -08:00
|
|
|
/**
|
|
|
|
* Shader packets and other data derived from prog_data. These must be
|
|
|
|
* completely determined from prog_data.
|
|
|
|
*/
|
|
|
|
uint8_t derived_data[0];
|
|
|
|
};
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* API context state that is replicated per shader stage.
|
|
|
|
*/
|
2018-02-09 14:21:54 -08:00
|
|
|
struct iris_shader_state {
|
2018-08-30 15:45:36 -07:00
|
|
|
/** Uniform Buffers */
|
2019-04-16 23:44:15 -07:00
|
|
|
struct pipe_shader_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS];
|
|
|
|
struct iris_state_ref constbuf_surf_state[PIPE_MAX_CONSTANT_BUFFERS];
|
2018-08-30 15:45:36 -07:00
|
|
|
|
2019-06-14 14:03:28 +02:00
|
|
|
bool sysvals_need_upload;
|
2018-11-08 23:10:46 -08:00
|
|
|
|
2018-08-30 15:45:36 -07:00
|
|
|
/** Shader Storage Buffers */
|
2019-04-16 23:44:15 -07:00
|
|
|
struct pipe_shader_buffer ssbo[PIPE_MAX_SHADER_BUFFERS];
|
|
|
|
struct iris_state_ref ssbo_surf_state[PIPE_MAX_SHADER_BUFFERS];
|
2018-08-18 23:43:14 -07:00
|
|
|
|
2018-08-30 15:45:36 -07:00
|
|
|
/** Shader Storage Images (image load store) */
|
2019-04-22 11:27:37 -07:00
|
|
|
struct iris_image_view image[PIPE_MAX_SHADER_IMAGES];
|
2018-08-30 15:45:36 -07:00
|
|
|
|
2018-08-18 23:43:14 -07:00
|
|
|
struct iris_state_ref sampler_table;
|
|
|
|
struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS];
|
|
|
|
struct iris_sampler_view *textures[IRIS_MAX_TEXTURE_SAMPLERS];
|
2018-12-02 23:17:44 -08:00
|
|
|
|
2019-04-16 23:01:41 -07:00
|
|
|
/** Bitfield of which constant buffers are bound (non-null). */
|
|
|
|
uint32_t bound_cbufs;
|
|
|
|
|
2018-12-02 23:17:44 -08:00
|
|
|
/** Bitfield of which image views are bound (non-null). */
|
|
|
|
uint32_t bound_image_views;
|
|
|
|
|
|
|
|
/** Bitfield of which sampler views are bound (non-null). */
|
|
|
|
uint32_t bound_sampler_views;
|
2019-04-16 22:54:40 -07:00
|
|
|
|
|
|
|
/** Bitfield of which shader storage buffers are bound (non-null). */
|
|
|
|
uint32_t bound_ssbos;
|
|
|
|
|
|
|
|
/** Bitfield of which shader storage buffers are writable. */
|
|
|
|
uint32_t writable_ssbos;
|
2018-02-09 14:21:54 -08:00
|
|
|
};
|
|
|
|
|
2018-12-05 00:57:07 -08:00
|
|
|
/**
|
|
|
|
* Gallium CSO for stream output (transform feedback) targets.
|
|
|
|
*/
|
|
|
|
struct iris_stream_output_target {
|
|
|
|
struct pipe_stream_output_target base;
|
|
|
|
|
|
|
|
/** Storage holding the offset where we're writing in the buffer */
|
|
|
|
struct iris_state_ref offset;
|
2018-12-04 22:19:33 -08:00
|
|
|
|
2019-06-03 16:52:59 -07:00
|
|
|
/** Stride (bytes-per-vertex) during this transform feedback operation */
|
2018-12-04 22:19:33 -08:00
|
|
|
uint16_t stride;
|
2019-04-27 00:24:05 -07:00
|
|
|
|
2021-02-02 17:02:05 -08:00
|
|
|
/** Does the next 3DSTATE_SO_BUFFER need to zero the offsets? */
|
|
|
|
bool zero_offset;
|
2018-12-05 00:57:07 -08:00
|
|
|
};
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* A pool containing SAMPLER_BORDER_COLOR_STATE entries.
|
|
|
|
*
|
|
|
|
* See iris_border_color.c for more information.
|
|
|
|
*/
|
2018-06-28 02:25:25 -07:00
|
|
|
struct iris_border_color_pool {
|
|
|
|
struct iris_bo *bo;
|
|
|
|
void *map;
|
|
|
|
unsigned insert_point;
|
|
|
|
|
|
|
|
/** Map from border colors to offsets in the buffer. */
|
|
|
|
struct hash_table *ht;
|
|
|
|
};
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/**
|
|
|
|
* The API context (derived from pipe_context).
|
|
|
|
*
|
|
|
|
* Most driver state is tracked here.
|
|
|
|
*/
|
2017-11-23 23:15:14 -08:00
|
|
|
struct iris_context {
|
|
|
|
struct pipe_context ctx;
|
2020-05-15 11:23:03 -07:00
|
|
|
struct threaded_context *thrctx;
|
2017-11-23 23:15:14 -08:00
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/** A debug callback for KHR_debug output. */
|
2017-11-23 23:15:14 -08:00
|
|
|
struct pipe_debug_callback dbg;
|
|
|
|
|
2019-05-07 22:26:22 -07:00
|
|
|
/** A device reset status callback for notifying that the GPU is hosed. */
|
|
|
|
struct pipe_device_reset_callback reset;
|
|
|
|
|
2020-10-29 15:32:32 -07:00
|
|
|
/** A set of dmabuf resources dirtied beyond their default aux-states. */
|
|
|
|
struct set *dirty_dmabufs;
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/** Slab allocator for iris_transfer_map objects. */
|
2018-07-06 11:29:51 -07:00
|
|
|
struct slab_child_pool transfer_pool;
|
|
|
|
|
2021-02-10 15:09:11 -08:00
|
|
|
/** Slab allocator for threaded_context's iris_transfer_map objects */
|
|
|
|
struct slab_child_pool transfer_pool_unsync;
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
struct blorp_context blorp;
|
|
|
|
|
2018-11-20 09:00:22 -08:00
|
|
|
struct iris_batch batches[IRIS_BATCH_COUNT];
|
2018-07-26 21:59:20 -07:00
|
|
|
|
2019-01-15 14:15:07 -08:00
|
|
|
struct u_upload_mgr *query_buffer_uploader;
|
|
|
|
|
2019-02-26 14:37:23 +01:00
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
/**
|
|
|
|
* Either the value of BaseVertex for indexed draw calls or the value
|
|
|
|
* of the argument <first> for non-indexed draw calls.
|
|
|
|
*/
|
|
|
|
int firstvertex;
|
|
|
|
int baseinstance;
|
|
|
|
} params;
|
|
|
|
|
iris: Rework iris_update_draw_parameters to be more efficient
This improves a couple of things:
1. We now only update anything if the shader actually cares.
Previously, is_indexed_draw was causing us to flag dirty vertex
buffers, elements, and SGVs every time the shader switched between
indexed and non-indexed draws. This is a very common situation,
but we only need that information if the shader uses gl_BaseVertex.
We were also flagging things when switching between indirect/direct
draws as well, and now we only bother if it matters.
2. We upload new draw parameters only when necessary.
When we detect that the draw parameters have changed, we upload a
new copy, and use that. Previously we were uploading it every time
the vertex buffers were dirty (for possibly unrelated reasons) and
the shader needed that info. Tying these together also makes the
code a bit easier to follow.
In Civilization VI's benchmark, this code was flagging dirty state
many times per frame (49 average, 16 median, 614 maximum). Now it
occurs exactly once for the entire run.
2019-09-18 20:32:36 -07:00
|
|
|
/**
|
|
|
|
* Are the above values the ones stored in the draw_params buffer?
|
|
|
|
* If so, we can compare them against new values to see if anything
|
|
|
|
* changed. If not, we need to assume they changed.
|
|
|
|
*/
|
|
|
|
bool params_valid;
|
|
|
|
|
2019-02-26 14:37:23 +01:00
|
|
|
/**
|
|
|
|
* Resource and offset that stores draw_parameters from the indirect
|
|
|
|
* buffer or to the buffer that stures the previous values for non
|
|
|
|
* indirect draws.
|
|
|
|
*/
|
2019-09-18 20:12:33 -07:00
|
|
|
struct iris_state_ref draw_params;
|
2019-02-26 14:37:23 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
/**
|
|
|
|
* The value of DrawID. This always comes in from it's own vertex
|
|
|
|
* buffer since it's not part of the indirect draw parameters.
|
|
|
|
*/
|
|
|
|
int drawid;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Stores if an indexed or non-indexed draw (~0/0). Useful to
|
|
|
|
* calculate BaseVertex as an AND of firstvertex and is_indexed_draw.
|
|
|
|
*/
|
|
|
|
int is_indexed_draw;
|
|
|
|
} derived_params;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resource and offset used for GL_ARB_shader_draw_parameters which
|
|
|
|
* contains parameters that are not present in the indirect buffer as
|
|
|
|
* drawid and is_indexed_draw. They will go in their own vertex element.
|
|
|
|
*/
|
2019-09-18 20:12:33 -07:00
|
|
|
struct iris_state_ref derived_draw_params;
|
2019-02-26 14:37:23 +01:00
|
|
|
} draw;
|
|
|
|
|
2018-01-20 02:01:07 -08:00
|
|
|
struct {
|
2018-01-22 11:52:58 -08:00
|
|
|
struct iris_uncompiled_shader *uncompiled[MESA_SHADER_STAGES];
|
|
|
|
struct iris_compiled_shader *prog[MESA_SHADER_STAGES];
|
2021-02-18 14:27:19 -08:00
|
|
|
struct iris_compiled_shader *last_vue_shader;
|
iris: Reconfigure the URB only if it's necessary or possibly useful
Reconfiguring the URB partitioning is likely to cause shader stalls,
as the dividing line between each stage's section of memory is moving.
(Technically, 3DSTATE_URB_* are pipelined commands, but that mostly
means that the command streamer doesn't need to stall.) So it should
be beneficial to update the URB configuration less often.
If the previous URB configuration already has enough space for our
current shader's needs, we can just continue using it, assuming we
are able to allocate the maximum number of URB entries per stage.
However, if we ran out of URB space and had to limit the number of
URB entrties for a stage, and the per-entry size is larger than we
need, we should reconfigure it to try and improve concurrency.
So, we begin tracking the last URB configuration in the context,
and compare against that when updating shader variants.
Cuts 36% of the URB reconfigurations (excluding BLORP) from a
Shadow of Mordor trace, and 46% from a GFXBench Manhattan 3.0 trace.
One nice thing is that this removes the need to look at the old
prog_data when updating shaders, which should make it possible to
unbind shader variants without causing spurious URB updates.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8721>
2021-01-25 22:25:51 -08:00
|
|
|
struct {
|
|
|
|
unsigned size[4];
|
|
|
|
unsigned entries[4];
|
|
|
|
unsigned start[4];
|
|
|
|
bool constrained;
|
|
|
|
} urb;
|
2018-01-20 02:47:04 -08:00
|
|
|
|
2021-02-08 17:00:36 -08:00
|
|
|
/** Uploader for shader assembly from the driver thread */
|
|
|
|
struct u_upload_mgr *uploader_driver;
|
|
|
|
/** Uploader for shader assembly from the threaded context */
|
|
|
|
struct u_upload_mgr *uploader_unsync;
|
2018-01-25 19:39:10 -08:00
|
|
|
struct hash_table *cache;
|
2018-01-25 21:23:45 -08:00
|
|
|
|
2019-04-28 23:25:10 -07:00
|
|
|
/** Is a GS or TES outputting points or lines? */
|
|
|
|
bool output_topology_is_points_or_lines;
|
|
|
|
|
2018-11-07 22:05:14 -08:00
|
|
|
/**
|
|
|
|
* Scratch buffers for various sizes and stages.
|
|
|
|
*
|
|
|
|
* Indexed by the "Per-Thread Scratch Space" field's 4-bit encoding,
|
|
|
|
* and shader stage.
|
|
|
|
*/
|
|
|
|
struct iris_bo *scratch_bos[1 << 4][MESA_SHADER_STAGES];
|
2020-10-20 14:27:58 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Scratch buffer surface states on Gfx12.5+
|
|
|
|
*/
|
|
|
|
struct iris_state_ref scratch_surfs[1 << 4];
|
2018-01-20 02:01:07 -08:00
|
|
|
} shaders;
|
2018-01-16 01:15:15 -08:00
|
|
|
|
2021-04-06 13:32:02 -07:00
|
|
|
struct intel_perf_context *perf_ctx;
|
2019-07-03 12:38:16 -07:00
|
|
|
|
2020-02-11 11:21:47 -08:00
|
|
|
/** Frame number for debug prints */
|
|
|
|
uint32_t frame;
|
|
|
|
|
2017-11-23 23:15:14 -08:00
|
|
|
struct {
|
|
|
|
uint64_t dirty;
|
2020-05-29 16:57:01 -07:00
|
|
|
uint64_t stage_dirty;
|
|
|
|
uint64_t stage_dirty_for_nos[IRIS_NOS_COUNT];
|
2018-07-30 23:49:34 -07:00
|
|
|
|
2018-06-20 16:07:05 -07:00
|
|
|
unsigned num_viewports;
|
2018-01-10 00:19:29 -08:00
|
|
|
unsigned sample_mask;
|
2017-12-27 02:54:26 -08:00
|
|
|
struct iris_blend_state *cso_blend;
|
2018-01-09 11:44:04 -08:00
|
|
|
struct iris_rasterizer_state *cso_rast;
|
2017-12-27 02:54:26 -08:00
|
|
|
struct iris_depth_stencil_alpha_state *cso_zsa;
|
2018-01-09 21:29:09 -08:00
|
|
|
struct iris_vertex_element_state *cso_vertex_elements;
|
2017-11-23 23:15:14 -08:00
|
|
|
struct pipe_blend_color blend_color;
|
|
|
|
struct pipe_poly_stipple poly_stipple;
|
2018-07-14 01:29:33 -07:00
|
|
|
struct pipe_viewport_state viewports[IRIS_MAX_VIEWPORTS];
|
2017-11-23 23:15:14 -08:00
|
|
|
struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS];
|
|
|
|
struct pipe_stencil_ref stencil_ref;
|
2018-01-09 23:13:16 -08:00
|
|
|
struct pipe_framebuffer_state framebuffer;
|
2018-11-09 02:11:16 -08:00
|
|
|
struct pipe_clip_state clip_planes;
|
2018-07-01 22:13:07 -07:00
|
|
|
|
2018-09-21 12:22:34 -07:00
|
|
|
float default_outer_level[4];
|
|
|
|
float default_inner_level[2];
|
|
|
|
|
2018-12-04 16:38:14 -08:00
|
|
|
/** Bitfield of which vertex buffers are bound (non-null). */
|
|
|
|
uint64_t bound_vertex_buffers;
|
|
|
|
|
2018-08-31 18:03:19 -07:00
|
|
|
bool primitive_restart;
|
|
|
|
unsigned cut_index;
|
|
|
|
enum pipe_prim_type prim_mode:8;
|
2019-04-28 23:25:10 -07:00
|
|
|
bool prim_is_points_or_lines;
|
2018-08-31 18:03:19 -07:00
|
|
|
uint8_t vertices_per_patch;
|
2019-07-25 13:09:08 +03:00
|
|
|
|
|
|
|
bool window_space_position;
|
2018-08-31 18:03:19 -07:00
|
|
|
|
2020-04-28 14:03:47 -07:00
|
|
|
/** The last compute group size */
|
|
|
|
uint32_t last_block[3];
|
|
|
|
|
2018-10-19 01:14:38 -07:00
|
|
|
/** The last compute grid size */
|
|
|
|
uint32_t last_grid[3];
|
|
|
|
/** Reference to the BO containing the compute grid size */
|
|
|
|
struct iris_state_ref grid_size;
|
|
|
|
/** Reference to the SURFACE_STATE for the compute grid resource */
|
|
|
|
struct iris_state_ref grid_surf_state;
|
|
|
|
|
2018-12-07 18:13:07 -08:00
|
|
|
/**
|
|
|
|
* Array of aux usages for drawing, altered to account for any
|
|
|
|
* self-dependencies from resources bound for sampling and rendering.
|
|
|
|
*/
|
|
|
|
enum isl_aux_usage draw_aux_usage[BRW_MAX_DRAW_BUFFERS];
|
|
|
|
|
2020-12-16 14:57:14 -08:00
|
|
|
/** Aux usage of the fb's depth buffer (which may or may not exist). */
|
|
|
|
enum isl_aux_usage hiz_usage;
|
|
|
|
|
2021-03-03 13:49:18 -08:00
|
|
|
enum intel_urb_deref_block_size urb_deref_block_size;
|
2020-01-17 14:41:50 -06:00
|
|
|
|
2018-08-18 23:21:41 -07:00
|
|
|
/** Are depth writes enabled? (Depth buffer may or may not exist.) */
|
|
|
|
bool depth_writes_enabled;
|
|
|
|
|
|
|
|
/** Are stencil writes enabled? (Stencil buffer may or may not exist.) */
|
|
|
|
bool stencil_writes_enabled;
|
|
|
|
|
2018-07-30 23:49:34 -07:00
|
|
|
/** GenX-specific current state */
|
2018-07-01 22:13:07 -07:00
|
|
|
struct iris_genx_state *genx;
|
2018-01-11 22:18:54 -08:00
|
|
|
|
2018-08-18 23:39:48 -07:00
|
|
|
struct iris_shader_state shaders[MESA_SHADER_STAGES];
|
|
|
|
|
2019-02-26 14:37:23 +01:00
|
|
|
/** Do vertex shader uses shader draw parameters ? */
|
|
|
|
bool vs_uses_draw_params;
|
|
|
|
bool vs_uses_derived_draw_params;
|
|
|
|
bool vs_needs_sgvs_element;
|
|
|
|
|
2019-02-27 20:44:27 +01:00
|
|
|
/** Do vertex shader uses edge flag ? */
|
|
|
|
bool vs_needs_edge_flag;
|
|
|
|
|
2018-12-04 15:34:30 -08:00
|
|
|
/** Do any samplers need border color? One bit per shader stage. */
|
|
|
|
uint8_t need_border_colors;
|
2018-01-25 01:36:49 -08:00
|
|
|
|
2018-10-25 17:53:23 -05:00
|
|
|
/** Global resource bindings */
|
|
|
|
struct pipe_resource *global_bindings[IRIS_MAX_GLOBAL_BINDINGS];
|
|
|
|
|
2018-07-11 17:05:10 -07:00
|
|
|
struct pipe_stream_output_target *so_target[PIPE_MAX_SO_BUFFERS];
|
2018-07-11 12:45:19 -07:00
|
|
|
bool streamout_active;
|
2018-09-28 12:07:54 +02:00
|
|
|
|
2018-11-08 01:14:27 -08:00
|
|
|
bool statistics_counters_enabled;
|
|
|
|
|
2018-11-27 15:30:16 -08:00
|
|
|
/** Current conditional rendering mode */
|
|
|
|
enum iris_predicate_state predicate;
|
|
|
|
|
|
|
|
/**
|
2019-04-01 23:28:06 -07:00
|
|
|
* Query BO with a MI_PREDICATE_RESULT snapshot calculated on the
|
2018-11-27 15:30:16 -08:00
|
|
|
* render context that needs to be uploaded to the compute context.
|
|
|
|
*/
|
|
|
|
struct iris_bo *compute_predicate;
|
|
|
|
|
2018-09-28 12:07:54 +02:00
|
|
|
/** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */
|
|
|
|
bool prims_generated_query_active;
|
|
|
|
|
2018-07-11 17:05:10 -07:00
|
|
|
/** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */
|
2018-07-11 12:45:19 -07:00
|
|
|
uint32_t *streamout;
|
2018-06-29 12:58:31 -07:00
|
|
|
|
2018-07-30 22:59:52 -07:00
|
|
|
/** The SURFACE_STATE for a 1x1x1 null surface. */
|
2018-06-28 00:57:49 -07:00
|
|
|
struct iris_state_ref unbound_tex;
|
2018-06-27 16:59:59 -07:00
|
|
|
|
2018-07-30 22:59:52 -07:00
|
|
|
/** The SURFACE_STATE for a framebuffer-sized null surface. */
|
2018-07-31 10:33:35 +10:00
|
|
|
struct iris_state_ref null_fb;
|
|
|
|
|
2018-04-05 21:48:33 -07:00
|
|
|
struct u_upload_mgr *surface_uploader;
|
2020-10-20 21:29:50 -05:00
|
|
|
struct u_upload_mgr *bindless_uploader;
|
2018-04-05 21:48:33 -07:00
|
|
|
struct u_upload_mgr *dynamic_uploader;
|
|
|
|
|
2018-09-08 19:43:34 -07:00
|
|
|
struct iris_binder binder;
|
|
|
|
|
2018-06-28 02:25:25 -07:00
|
|
|
struct iris_border_color_pool border_color_pool;
|
|
|
|
|
2018-11-21 00:06:46 -08:00
|
|
|
/** The high 16-bits of the last VBO/index buffer addresses */
|
|
|
|
uint16_t last_vbo_high_bits[33];
|
|
|
|
uint16_t last_index_bo_high_bits;
|
|
|
|
|
2018-06-15 11:55:28 -07:00
|
|
|
/**
|
|
|
|
* Resources containing streamed state which our render context
|
|
|
|
* currently points to. Used to re-add these to the validation
|
|
|
|
* list when we start a new batch and haven't resubmitted commands.
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
struct pipe_resource *cc_vp;
|
|
|
|
struct pipe_resource *sf_cl_vp;
|
|
|
|
struct pipe_resource *color_calc;
|
|
|
|
struct pipe_resource *scissor;
|
|
|
|
struct pipe_resource *blend;
|
2018-09-20 17:27:47 -07:00
|
|
|
struct pipe_resource *index_buffer;
|
2019-06-26 23:38:59 -07:00
|
|
|
struct pipe_resource *cs_thread_ids;
|
2019-06-26 23:56:45 -07:00
|
|
|
struct pipe_resource *cs_desc;
|
2018-06-15 11:55:28 -07:00
|
|
|
} last_res;
|
iris: Record state sizes for INTEL_DEBUG=bat decoding.
Felix noticed a crash when using INTEL_DEBUG=bat decoding. It turned
out that we were sometimes placing variable length data near the end
of a buffer, and with the decoder guessing random lengths rather than
having an actual count, it was walking off the end and crashing. So
this does more than improve the decoder output.
Unfortunately, this is a bit more complicated than i965's handling,
because we don't have a single state buffer. Various places upload
data via u_upload_mgr, and so there isn't a central place to record
the size. We don't need to catch every single place, however, since
it's only important to record variable length packets (like viewports
and binding tables).
State data also lives arbitrarily long, rather than being discarded on
every batch like i965, so we don't know when to clear out old entries
either. (We also don't have a callback when an upload buffer is
released.) So, this tracking may space leak over time. That's probably
okay though, as this is only a debugging feature and it's a slow leak.
We may also get lucky and overwrite existing entries as we reuse BOs,
though I find this unlikely to happen.
The fact that the decoder works in terms of offsets from a state base
address is also not ideal, as dynamic state base address and surface
state base address differ for iris. However, because dynamic state
addresses start from the top of a 4GB region, and binding tables start
from addresses [0, 64K), it's highly unlikely that we'll get overlap.
We can always improve this, but for now it's better than what we had.
2019-05-22 18:14:38 -07:00
|
|
|
|
|
|
|
/** Records the size of variable-length state for INTEL_DEBUG=bat */
|
|
|
|
struct hash_table_u64 *sizes;
|
2019-08-10 12:45:46 -07:00
|
|
|
|
|
|
|
/** Last rendering scale argument provided to genX(emit_hashing_mode). */
|
|
|
|
unsigned current_hash_scale;
|
2017-11-23 23:15:14 -08:00
|
|
|
} state;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define perf_debug(dbg, ...) do { \
|
|
|
|
if (INTEL_DEBUG & DEBUG_PERF) \
|
|
|
|
dbg_printf(__VA_ARGS__); \
|
|
|
|
if (unlikely(dbg)) \
|
|
|
|
pipe_debug_message(dbg, PERF_INFO, __VA_ARGS__); \
|
|
|
|
} while(0)
|
|
|
|
|
|
|
|
struct pipe_context *
|
|
|
|
iris_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
|
|
|
|
|
2019-05-07 23:19:30 -07:00
|
|
|
void iris_lost_context_state(struct iris_batch *batch);
|
|
|
|
|
2020-10-29 15:32:32 -07:00
|
|
|
void iris_mark_dirty_dmabuf(struct iris_context *ice,
|
|
|
|
struct pipe_resource *res);
|
|
|
|
void iris_flush_dirty_dmabufs(struct iris_context *ice);
|
|
|
|
|
2018-01-19 18:57:30 -08:00
|
|
|
void iris_init_blit_functions(struct pipe_context *ctx);
|
|
|
|
void iris_init_clear_functions(struct pipe_context *ctx);
|
2017-11-23 23:15:14 -08:00
|
|
|
void iris_init_program_functions(struct pipe_context *ctx);
|
2018-01-19 18:57:30 -08:00
|
|
|
void iris_init_resource_functions(struct pipe_context *ctx);
|
2019-10-15 12:43:02 -07:00
|
|
|
void iris_init_perfquery_functions(struct pipe_context *ctx);
|
2018-01-16 01:15:15 -08:00
|
|
|
void iris_update_compiled_shaders(struct iris_context *ice);
|
2018-07-26 21:59:20 -07:00
|
|
|
void iris_update_compiled_compute_shader(struct iris_context *ice);
|
2018-09-18 16:24:13 -07:00
|
|
|
void iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data,
|
2020-04-09 16:54:25 -07:00
|
|
|
unsigned threads,
|
2018-09-18 16:24:13 -07:00
|
|
|
uint32_t *dst);
|
2018-07-26 21:59:20 -07:00
|
|
|
|
2018-01-16 01:15:15 -08:00
|
|
|
|
2018-06-24 15:16:34 -07:00
|
|
|
/* iris_blit.c */
|
2020-03-30 10:37:29 -04:00
|
|
|
void iris_blorp_surf_for_resource(struct isl_device *isl_dev,
|
2019-03-06 14:49:39 -08:00
|
|
|
struct blorp_surf *surf,
|
2018-06-24 15:16:34 -07:00
|
|
|
struct pipe_resource *p_res,
|
|
|
|
enum isl_aux_usage aux_usage,
|
2018-12-10 00:35:48 -08:00
|
|
|
unsigned level,
|
2018-06-24 15:16:34 -07:00
|
|
|
bool is_render_target);
|
2018-12-24 00:27:09 -08:00
|
|
|
void iris_copy_region(struct blorp_context *blorp,
|
|
|
|
struct iris_batch *batch,
|
|
|
|
struct pipe_resource *dst,
|
|
|
|
unsigned dst_level,
|
|
|
|
unsigned dstx, unsigned dsty, unsigned dstz,
|
|
|
|
struct pipe_resource *src,
|
|
|
|
unsigned src_level,
|
|
|
|
const struct pipe_box *src_box);
|
2018-06-24 15:16:34 -07:00
|
|
|
|
2018-01-25 02:03:18 -08:00
|
|
|
/* iris_draw.c */
|
|
|
|
|
2020-11-01 06:38:32 -05:00
|
|
|
void iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
|
2021-04-11 13:35:38 -04:00
|
|
|
unsigned drawid_offset,
|
2020-11-01 09:04:40 -05:00
|
|
|
const struct pipe_draw_indirect_info *indirect,
|
2021-04-11 09:49:49 -04:00
|
|
|
const struct pipe_draw_start_count_bias *draws,
|
2020-11-01 09:04:40 -05:00
|
|
|
unsigned num_draws);
|
2018-07-26 21:59:20 -07:00
|
|
|
void iris_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
|
2018-01-16 01:15:15 -08:00
|
|
|
|
2018-04-19 12:52:51 -07:00
|
|
|
/* iris_pipe_control.c */
|
|
|
|
|
2018-04-20 23:28:03 -07:00
|
|
|
void iris_emit_pipe_control_flush(struct iris_batch *batch,
|
2019-06-19 16:04:50 -05:00
|
|
|
const char *reason, uint32_t flags);
|
|
|
|
void iris_emit_pipe_control_write(struct iris_batch *batch,
|
|
|
|
const char *reason, uint32_t flags,
|
2018-04-19 12:52:51 -07:00
|
|
|
struct iris_bo *bo, uint32_t offset,
|
|
|
|
uint64_t imm);
|
2018-04-20 23:28:03 -07:00
|
|
|
void iris_emit_end_of_pipe_sync(struct iris_batch *batch,
|
2019-06-19 16:04:50 -05:00
|
|
|
const char *reason, uint32_t flags);
|
2020-02-05 18:59:46 -08:00
|
|
|
void iris_emit_buffer_barrier_for(struct iris_batch *batch,
|
|
|
|
struct iris_bo *bo,
|
|
|
|
enum iris_domain access);
|
2019-09-07 21:18:51 -07:00
|
|
|
void iris_flush_all_caches(struct iris_batch *batch);
|
|
|
|
|
|
|
|
#define iris_handle_always_flush_cache(batch) \
|
|
|
|
if (unlikely(batch->screen->driconf.always_flush_cache)) \
|
|
|
|
iris_flush_all_caches(batch);
|
2018-04-19 12:52:51 -07:00
|
|
|
|
2018-07-24 21:15:13 -07:00
|
|
|
void iris_init_flush_functions(struct pipe_context *ctx);
|
|
|
|
|
2018-06-28 02:25:25 -07:00
|
|
|
/* iris_border_color.c */
|
|
|
|
|
|
|
|
void iris_init_border_color_pool(struct iris_context *ice);
|
2018-11-28 15:15:21 -08:00
|
|
|
void iris_destroy_border_color_pool(struct iris_context *ice);
|
2018-06-28 02:25:25 -07:00
|
|
|
void iris_border_color_pool_reserve(struct iris_context *ice, unsigned count);
|
|
|
|
uint32_t iris_upload_border_color(struct iris_context *ice,
|
|
|
|
union pipe_color_union *color);
|
|
|
|
|
2018-07-24 15:04:39 -07:00
|
|
|
/* iris_program.c */
|
2019-05-28 17:52:58 -05:00
|
|
|
void iris_upload_ubo_ssbo_surf_state(struct iris_context *ice,
|
|
|
|
struct pipe_shader_buffer *buf,
|
|
|
|
struct iris_state_ref *surf_state,
|
2020-10-07 07:44:56 -07:00
|
|
|
isl_surf_usage_flags_t usage);
|
2018-07-24 15:04:39 -07:00
|
|
|
const struct shader_info *iris_get_shader_info(const struct iris_context *ice,
|
|
|
|
gl_shader_stage stage);
|
2018-12-12 01:41:39 -08:00
|
|
|
struct iris_bo *iris_get_scratch_space(struct iris_context *ice,
|
|
|
|
unsigned per_thread_scratch,
|
|
|
|
gl_shader_stage stage);
|
2020-10-20 14:27:58 -05:00
|
|
|
const struct iris_state_ref *iris_get_scratch_surf(struct iris_context *ice,
|
|
|
|
unsigned per_thread_scratch);
|
2019-05-23 14:17:59 -07:00
|
|
|
uint32_t iris_group_index_to_bti(const struct iris_binding_table *bt,
|
|
|
|
enum iris_surface_group group,
|
|
|
|
uint32_t index);
|
|
|
|
uint32_t iris_bti_to_group_index(const struct iris_binding_table *bt,
|
|
|
|
enum iris_surface_group group,
|
|
|
|
uint32_t bti);
|
2018-07-24 15:04:39 -07:00
|
|
|
|
2018-12-20 15:54:06 -08:00
|
|
|
/* iris_disk_cache.c */
|
|
|
|
|
|
|
|
void iris_disk_cache_store(struct disk_cache *cache,
|
|
|
|
const struct iris_uncompiled_shader *ish,
|
|
|
|
const struct iris_compiled_shader *shader,
|
|
|
|
const void *prog_key,
|
|
|
|
uint32_t prog_key_size);
|
|
|
|
struct iris_compiled_shader *
|
2021-02-08 18:38:22 -08:00
|
|
|
iris_disk_cache_retrieve(struct iris_screen *screen,
|
|
|
|
struct u_upload_mgr *uploader,
|
iris: Store a list of shader variants in the shader itself
We've traditionally stored shader variants in a per-context hash table,
based on a key with many per-stage fields. On older hardware supported
by i965, there were potentially quite a few variants, as many features
had to be emulated in shaders, including things like texture swizzling.
However, on the modern hardware targeted by iris, our NOS dependencies
are much smaller. We almost always guess the correct state when doing
the initial precompile, and so we have maybe 1-3 variants. iris NOS
keys are also dramatically smaller (4 to 24 bytes) than i965's.
Unlike the classic world, Gallium also provides a single kind of object
for API shaders---pipe_shader_state aka iris_uncompiled_shader. We can
simply store a list of shader variants there. This makes it possible
to access shader variants across contexts, rather than compiling them
separately for each context, which better matches how the APIs work.
To look up variants, we simply walk the list and memcmp the keys.
Since the list is almost always singular (and rarely ever long),
and the keys are tiny, this should be quite low overhead.
We continue storing internally generated shaders for BLORP and
passthrough TCS in the per-context hash table, as they don't have
an associated pipe_shader_state / iris_uncompiled_shader object.
(There can also be many BLORP shaders, and the blit keys are large,
so having a hash table rather than a list makes sense there.)
Because iris_uncompiled_shaders are shared across multiple contexts,
we do require locking when accessing this list. Fortunately, this
is a per-shader lock, rather than a global one. Additionally, since
we only append variants to the list, and generate the first one at
precompile time (while only one context has the uncompiled shader),
we can assume that it is safe to access that first entry without
locking the list. This means that we only have to lock when we
have multiple variants, which is relatively uncommon.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2020-11-16 13:17:08 -08:00
|
|
|
struct iris_uncompiled_shader *ish,
|
2018-12-20 15:54:06 -08:00
|
|
|
const void *prog_key,
|
|
|
|
uint32_t prog_key_size);
|
|
|
|
|
2018-01-25 02:03:18 -08:00
|
|
|
/* iris_program_cache.c */
|
|
|
|
|
2018-01-20 02:47:04 -08:00
|
|
|
void iris_init_program_cache(struct iris_context *ice);
|
|
|
|
void iris_destroy_program_cache(struct iris_context *ice);
|
2018-11-21 18:15:28 -08:00
|
|
|
struct iris_compiled_shader *iris_find_cached_shader(struct iris_context *ice,
|
|
|
|
enum iris_program_cache_id,
|
|
|
|
uint32_t key_size,
|
|
|
|
const void *key);
|
2021-02-08 18:01:31 -08:00
|
|
|
struct iris_compiled_shader *iris_upload_shader(struct iris_screen *screen,
|
iris: Store a list of shader variants in the shader itself
We've traditionally stored shader variants in a per-context hash table,
based on a key with many per-stage fields. On older hardware supported
by i965, there were potentially quite a few variants, as many features
had to be emulated in shaders, including things like texture swizzling.
However, on the modern hardware targeted by iris, our NOS dependencies
are much smaller. We almost always guess the correct state when doing
the initial precompile, and so we have maybe 1-3 variants. iris NOS
keys are also dramatically smaller (4 to 24 bytes) than i965's.
Unlike the classic world, Gallium also provides a single kind of object
for API shaders---pipe_shader_state aka iris_uncompiled_shader. We can
simply store a list of shader variants there. This makes it possible
to access shader variants across contexts, rather than compiling them
separately for each context, which better matches how the APIs work.
To look up variants, we simply walk the list and memcmp the keys.
Since the list is almost always singular (and rarely ever long),
and the keys are tiny, this should be quite low overhead.
We continue storing internally generated shaders for BLORP and
passthrough TCS in the per-context hash table, as they don't have
an associated pipe_shader_state / iris_uncompiled_shader object.
(There can also be many BLORP shaders, and the blit keys are large,
so having a hash table rather than a list makes sense there.)
Because iris_uncompiled_shaders are shared across multiple contexts,
we do require locking when accessing this list. Fortunately, this
is a per-shader lock, rather than a global one. Additionally, since
we only append variants to the list, and generate the first one at
precompile time (while only one context has the uncompiled shader),
we can assume that it is safe to access that first entry without
locking the list. This means that we only have to lock when we
have multiple variants, which is relatively uncommon.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2020-11-16 13:17:08 -08:00
|
|
|
struct iris_uncompiled_shader *,
|
2021-02-08 18:01:31 -08:00
|
|
|
struct hash_table *driver_ht,
|
|
|
|
struct u_upload_mgr *uploader,
|
2018-11-21 16:45:14 -08:00
|
|
|
enum iris_program_cache_id,
|
|
|
|
uint32_t key_size,
|
|
|
|
const void *key,
|
|
|
|
const void *assembly,
|
|
|
|
struct brw_stage_prog_data *,
|
|
|
|
uint32_t *streamout,
|
|
|
|
enum brw_param_builtin *sysv,
|
2019-01-19 11:32:37 -08:00
|
|
|
unsigned num_system_values,
|
2020-08-11 10:07:55 -05:00
|
|
|
unsigned kernel_input_size,
|
2019-05-22 22:17:27 -07:00
|
|
|
unsigned num_cbufs,
|
|
|
|
const struct iris_binding_table *bt);
|
iris: Refcount shader variants
There is a small gap of time where the currently bound uncompiled
shaders, and compiled shader variant, are out of sync. Specifically,
between pipe->bind_*_state() and the next draw.
Currently, shaders variants live entirely within a single context,
and when deleting an iris_uncompiled_shader, we check if any of its
variants are currently bound, and defer deleting those until the next
iris_update_compiled_shaders() hook runs and binds new shaders to
replace them. (This is due to the time gap between binding new
uncompiled shaders, and updating variants at draw time when we have
the required NOS in place.)
This works pretty well in a single context world. But as we move to
share compiled shader variants across multiple contexts, it breaks down.
When deleting a shader, we can't look at all contexts to see if its
variants are bound anywhere. We can't even quantify whether those
contexts will run a future draw any time soon, to update and unbind.
One fairly crazy solution would be to delete the variants anyway, and
leave the stale pointers to dead variants in place. This requires
removing any code that compares old and new variants. Today, we do
that sometimes for seeing if the old/new shaders toggled some feature.
Worse than that, though, we don't just have to avoid dereferences, we'd
have to avoid pointer comparisons. If we free a variant, and quickly
allocate a new variant, malloc may return the same pointer. If it's
for the same shader stage, we may get a new different program that has
the same pointer as a previously bound stale one, causing us to think
nothing had changed when we really needed to do updates. Again, this
is doable, but leaves the code fragile - we'd have to guard against
future patches adding such checks back in.
So, don't do that. Instead, do basic reference counting. When a
variant is bound in a context, up the reference. When it's unbound,
decrement it. When it hits zero, we know it's not bound anywhere and
is safe to delete, with no stale references. This ends up being
reasonably cheap anyway, since the atomic is usually uncontested.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7668>
2021-01-27 13:46:26 -08:00
|
|
|
void iris_delete_shader_variant(struct iris_compiled_shader *shader);
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
iris_shader_variant_reference(struct iris_compiled_shader **dst,
|
|
|
|
struct iris_compiled_shader *src)
|
|
|
|
{
|
|
|
|
struct iris_compiled_shader *old_dst = *dst;
|
|
|
|
|
|
|
|
if (pipe_reference(old_dst ? &old_dst->ref: NULL, src ? &src->ref : NULL))
|
|
|
|
iris_delete_shader_variant(old_dst);
|
|
|
|
|
|
|
|
*dst = src;
|
|
|
|
}
|
|
|
|
|
2018-04-21 23:27:15 -07:00
|
|
|
bool iris_blorp_lookup_shader(struct blorp_batch *blorp_batch,
|
|
|
|
const void *key,
|
|
|
|
uint32_t key_size,
|
|
|
|
uint32_t *kernel_out,
|
|
|
|
void *prog_data_out);
|
2020-03-12 14:27:13 -07:00
|
|
|
bool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage,
|
2018-04-21 23:27:15 -07:00
|
|
|
const void *key, uint32_t key_size,
|
|
|
|
const void *kernel, uint32_t kernel_size,
|
|
|
|
const struct brw_stage_prog_data *prog_data,
|
|
|
|
uint32_t prog_data_size,
|
|
|
|
uint32_t *kernel_out,
|
|
|
|
void *prog_data_out);
|
|
|
|
|
2018-08-19 00:18:51 -07:00
|
|
|
/* iris_resolve.c */
|
|
|
|
|
2018-12-07 18:13:07 -08:00
|
|
|
void iris_predraw_resolve_inputs(struct iris_context *ice,
|
|
|
|
struct iris_batch *batch,
|
2018-12-09 19:07:13 -08:00
|
|
|
bool *draw_aux_buffer_disabled,
|
2019-03-09 01:31:06 -08:00
|
|
|
gl_shader_stage stage,
|
2018-12-09 19:07:13 -08:00
|
|
|
bool consider_framebuffer);
|
2018-08-19 00:21:34 -07:00
|
|
|
void iris_predraw_resolve_framebuffer(struct iris_context *ice,
|
2018-12-07 18:13:07 -08:00
|
|
|
struct iris_batch *batch,
|
|
|
|
bool *draw_aux_buffer_disabled);
|
2018-08-19 00:21:34 -07:00
|
|
|
void iris_postdraw_update_resolve_tracking(struct iris_context *ice,
|
|
|
|
struct iris_batch *batch);
|
2018-08-19 00:18:51 -07:00
|
|
|
void iris_cache_flush_for_render(struct iris_batch *batch,
|
|
|
|
struct iris_bo *bo,
|
|
|
|
enum isl_aux_usage aux_usage);
|
2019-04-22 11:43:12 -07:00
|
|
|
int iris_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
|
|
|
|
struct pipe_driver_query_info *info);
|
|
|
|
int iris_get_driver_query_group_info(struct pipe_screen *pscreen,
|
|
|
|
unsigned index,
|
|
|
|
struct pipe_driver_query_group_info *info);
|
2018-08-19 00:18:51 -07:00
|
|
|
|
2019-04-11 10:07:15 -04:00
|
|
|
/* iris_state.c */
|
2021-03-29 15:40:04 -07:00
|
|
|
void gfx9_toggle_preemption(struct iris_context *ice,
|
2019-04-24 16:43:36 -07:00
|
|
|
struct iris_batch *batch,
|
|
|
|
const struct pipe_draw_info *draw);
|
2019-04-01 11:40:33 -07:00
|
|
|
|
2020-03-30 10:37:29 -04:00
|
|
|
|
|
|
|
|
2019-04-01 11:40:33 -07:00
|
|
|
#ifdef genX
|
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
#else
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx4_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx5_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx6_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx7_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx75_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx8_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx9_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx11_##x
|
2019-04-01 11:40:33 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx12_##x
|
2019-02-10 20:14:07 -08:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2021-03-29 15:40:04 -07:00
|
|
|
# define genX(x) gfx125_##x
|
2020-05-15 03:16:51 -07:00
|
|
|
# include "iris_genx_protos.h"
|
|
|
|
# undef genX
|
2019-04-01 11:40:33 -07:00
|
|
|
#endif
|
|
|
|
|
2017-11-23 23:15:14 -08:00
|
|
|
#endif
|