1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright © 2017 Intel Corporation
3bf215546Sopenharmony_ci *
4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub
8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom
9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions:
10bf215546Sopenharmony_ci *
11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
13bf215546Sopenharmony_ci * Software.
14bf215546Sopenharmony_ci *
15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
22bf215546Sopenharmony_ci */
23bf215546Sopenharmony_ci#ifndef IRIS_CONTEXT_H
24bf215546Sopenharmony_ci#define IRIS_CONTEXT_H
25bf215546Sopenharmony_ci
26bf215546Sopenharmony_ci#include "pipe/p_context.h"
27bf215546Sopenharmony_ci#include "pipe/p_state.h"
28bf215546Sopenharmony_ci#include "util/perf/u_trace.h"
29bf215546Sopenharmony_ci#include "util/set.h"
30bf215546Sopenharmony_ci#include "util/slab.h"
31bf215546Sopenharmony_ci#include "util/u_debug.h"
32bf215546Sopenharmony_ci#include "util/macros.h"
33bf215546Sopenharmony_ci#include "util/u_threaded_context.h"
34bf215546Sopenharmony_ci#include "intel/blorp/blorp.h"
35bf215546Sopenharmony_ci#include "intel/dev/intel_debug.h"
36bf215546Sopenharmony_ci#include "intel/common/intel_l3_config.h"
37bf215546Sopenharmony_ci#include "intel/compiler/brw_compiler.h"
38bf215546Sopenharmony_ci#include "intel/ds/intel_driver_ds.h"
39bf215546Sopenharmony_ci#include "iris_batch.h"
40bf215546Sopenharmony_ci#include "iris_binder.h"
41bf215546Sopenharmony_ci#include "iris_fence.h"
42bf215546Sopenharmony_ci#include "iris_resource.h"
43bf215546Sopenharmony_ci#include "iris_screen.h"
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_cistruct iris_bo;
46bf215546Sopenharmony_cistruct iris_context;
47bf215546Sopenharmony_cistruct blorp_batch;
48bf215546Sopenharmony_cistruct blorp_params;
49bf215546Sopenharmony_ci
50bf215546Sopenharmony_ci#define IRIS_MAX_TEXTURE_BUFFER_SIZE (1 << 27)
51bf215546Sopenharmony_ci#define IRIS_MAX_TEXTURE_SAMPLERS 32
52bf215546Sopenharmony_ci/* IRIS_MAX_ABOS and IRIS_MAX_SSBOS must be the same. */
53bf215546Sopenharmony_ci#define IRIS_MAX_ABOS 16
54bf215546Sopenharmony_ci#define IRIS_MAX_SSBOS 16
55bf215546Sopenharmony_ci#define IRIS_MAX_VIEWPORTS 16
56bf215546Sopenharmony_ci#define IRIS_MAX_CLIP_PLANES 8
57bf215546Sopenharmony_ci#define IRIS_MAX_GLOBAL_BINDINGS 32
58bf215546Sopenharmony_ci
59bf215546Sopenharmony_cienum iris_param_domain {
60bf215546Sopenharmony_ci   BRW_PARAM_DOMAIN_BUILTIN = 0,
61bf215546Sopenharmony_ci   BRW_PARAM_DOMAIN_IMAGE,
62bf215546Sopenharmony_ci};
63bf215546Sopenharmony_ci
64bf215546Sopenharmony_cienum {
65bf215546Sopenharmony_ci   DRI_CONF_BO_REUSE_DISABLED,
66bf215546Sopenharmony_ci   DRI_CONF_BO_REUSE_ALL
67bf215546Sopenharmony_ci};
68bf215546Sopenharmony_ci
69bf215546Sopenharmony_ci#define BRW_PARAM(domain, val)   (BRW_PARAM_DOMAIN_##domain << 24 | (val))
70bf215546Sopenharmony_ci#define BRW_PARAM_DOMAIN(param)  ((uint32_t)(param) >> 24)
71bf215546Sopenharmony_ci#define BRW_PARAM_VALUE(param)   ((uint32_t)(param) & 0x00ffffff)
72bf215546Sopenharmony_ci#define BRW_PARAM_IMAGE(idx, offset) BRW_PARAM(IMAGE, ((idx) << 8) | (offset))
73bf215546Sopenharmony_ci#define BRW_PARAM_IMAGE_IDX(value)   (BRW_PARAM_VALUE(value) >> 8)
74bf215546Sopenharmony_ci#define BRW_PARAM_IMAGE_OFFSET(value)(BRW_PARAM_VALUE(value) & 0xf)
75bf215546Sopenharmony_ci
76bf215546Sopenharmony_ci/**
77bf215546Sopenharmony_ci * Dirty flags.  When state changes, we flag some combination of these
78bf215546Sopenharmony_ci * to indicate that particular GPU commands need to be re-emitted.
79bf215546Sopenharmony_ci *
80bf215546Sopenharmony_ci * Each bit typically corresponds to a single 3DSTATE_* command packet, but
81bf215546Sopenharmony_ci * in rare cases they map to a group of related packets that need to be
82bf215546Sopenharmony_ci * emitted together.
83bf215546Sopenharmony_ci *
84bf215546Sopenharmony_ci * See iris_upload_render_state().
85bf215546Sopenharmony_ci */
86bf215546Sopenharmony_ci#define IRIS_DIRTY_COLOR_CALC_STATE               (1ull <<  0)
87bf215546Sopenharmony_ci#define IRIS_DIRTY_POLYGON_STIPPLE                (1ull <<  1)
88bf215546Sopenharmony_ci#define IRIS_DIRTY_SCISSOR_RECT                   (1ull <<  2)
89bf215546Sopenharmony_ci#define IRIS_DIRTY_WM_DEPTH_STENCIL               (1ull <<  3)
90bf215546Sopenharmony_ci#define IRIS_DIRTY_CC_VIEWPORT                    (1ull <<  4)
91bf215546Sopenharmony_ci#define IRIS_DIRTY_SF_CL_VIEWPORT                 (1ull <<  5)
92bf215546Sopenharmony_ci#define IRIS_DIRTY_PS_BLEND                       (1ull <<  6)
93bf215546Sopenharmony_ci#define IRIS_DIRTY_BLEND_STATE                    (1ull <<  7)
94bf215546Sopenharmony_ci#define IRIS_DIRTY_RASTER                         (1ull <<  8)
95bf215546Sopenharmony_ci#define IRIS_DIRTY_CLIP                           (1ull <<  9)
96bf215546Sopenharmony_ci#define IRIS_DIRTY_SBE                            (1ull << 10)
97bf215546Sopenharmony_ci#define IRIS_DIRTY_LINE_STIPPLE                   (1ull << 11)
98bf215546Sopenharmony_ci#define IRIS_DIRTY_VERTEX_ELEMENTS                (1ull << 12)
99bf215546Sopenharmony_ci#define IRIS_DIRTY_MULTISAMPLE                    (1ull << 13)
100bf215546Sopenharmony_ci#define IRIS_DIRTY_VERTEX_BUFFERS                 (1ull << 14)
101bf215546Sopenharmony_ci#define IRIS_DIRTY_SAMPLE_MASK                    (1ull << 15)
102bf215546Sopenharmony_ci#define IRIS_DIRTY_URB                            (1ull << 16)
103bf215546Sopenharmony_ci#define IRIS_DIRTY_DEPTH_BUFFER                   (1ull << 17)
104bf215546Sopenharmony_ci#define IRIS_DIRTY_WM                             (1ull << 18)
105bf215546Sopenharmony_ci#define IRIS_DIRTY_SO_BUFFERS                     (1ull << 19)
106bf215546Sopenharmony_ci#define IRIS_DIRTY_SO_DECL_LIST                   (1ull << 20)
107bf215546Sopenharmony_ci#define IRIS_DIRTY_STREAMOUT                      (1ull << 21)
108bf215546Sopenharmony_ci#define IRIS_DIRTY_VF_SGVS                        (1ull << 22)
109bf215546Sopenharmony_ci#define IRIS_DIRTY_VF                             (1ull << 23)
110bf215546Sopenharmony_ci#define IRIS_DIRTY_VF_TOPOLOGY                    (1ull << 24)
111bf215546Sopenharmony_ci#define IRIS_DIRTY_RENDER_RESOLVES_AND_FLUSHES    (1ull << 25)
112bf215546Sopenharmony_ci#define IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES   (1ull << 26)
113bf215546Sopenharmony_ci#define IRIS_DIRTY_VF_STATISTICS                  (1ull << 27)
114bf215546Sopenharmony_ci#define IRIS_DIRTY_PMA_FIX                        (1ull << 28)
115bf215546Sopenharmony_ci#define IRIS_DIRTY_DEPTH_BOUNDS                   (1ull << 29)
116bf215546Sopenharmony_ci#define IRIS_DIRTY_RENDER_BUFFER                  (1ull << 30)
117bf215546Sopenharmony_ci#define IRIS_DIRTY_STENCIL_REF                    (1ull << 31)
118bf215546Sopenharmony_ci#define IRIS_DIRTY_VERTEX_BUFFER_FLUSHES          (1ull << 32)
119bf215546Sopenharmony_ci#define IRIS_DIRTY_RENDER_MISC_BUFFER_FLUSHES     (1ull << 33)
120bf215546Sopenharmony_ci#define IRIS_DIRTY_COMPUTE_MISC_BUFFER_FLUSHES    (1ull << 34)
121bf215546Sopenharmony_ci#define IRIS_DIRTY_VFG                            (1ull << 35)
122bf215546Sopenharmony_ci
123bf215546Sopenharmony_ci#define IRIS_ALL_DIRTY_FOR_COMPUTE (IRIS_DIRTY_COMPUTE_RESOLVES_AND_FLUSHES | \
124bf215546Sopenharmony_ci                                    IRIS_DIRTY_COMPUTE_MISC_BUFFER_FLUSHES)
125bf215546Sopenharmony_ci
126bf215546Sopenharmony_ci#define IRIS_ALL_DIRTY_FOR_RENDER (~IRIS_ALL_DIRTY_FOR_COMPUTE)
127bf215546Sopenharmony_ci
128bf215546Sopenharmony_ci/**
129bf215546Sopenharmony_ci * Per-stage dirty flags.  When state changes, we flag some combination of
130bf215546Sopenharmony_ci * these to indicate that particular GPU commands need to be re-emitted.
131bf215546Sopenharmony_ci * Unlike the IRIS_DIRTY_* flags these are shader stage-specific and can be
132bf215546Sopenharmony_ci * indexed by shifting the mask by the shader stage index.
133bf215546Sopenharmony_ci *
134bf215546Sopenharmony_ci * See iris_upload_render_state().
135bf215546Sopenharmony_ci */
136bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_VS        (1ull << 0)
137bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TCS       (1ull << 1)
138bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_TES       (1ull << 2)
139bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_GS        (1ull << 3)
140bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_PS        (1ull << 4)
141bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_SAMPLER_STATES_CS        (1ull << 5)
142bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_VS            (1ull << 6)
143bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_TCS           (1ull << 7)
144bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_TES           (1ull << 8)
145bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_GS            (1ull << 9)
146bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_FS            (1ull << 10)
147bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_UNCOMPILED_CS            (1ull << 11)
148bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_VS                       (1ull << 12)
149bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_TCS                      (1ull << 13)
150bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_TES                      (1ull << 14)
151bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_GS                       (1ull << 15)
152bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_FS                       (1ull << 16)
153bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CS                       (1ull << 17)
154bf215546Sopenharmony_ci#define IRIS_SHIFT_FOR_STAGE_DIRTY_CONSTANTS      18
155bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_VS             (1ull << 18)
156bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_TCS            (1ull << 19)
157bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_TES            (1ull << 20)
158bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_GS             (1ull << 21)
159bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_FS             (1ull << 22)
160bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_CONSTANTS_CS             (1ull << 23)
161bf215546Sopenharmony_ci#define IRIS_SHIFT_FOR_STAGE_DIRTY_BINDINGS       24
162bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_VS              (1ull << 24)
163bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_TCS             (1ull << 25)
164bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_TES             (1ull << 26)
165bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_GS              (1ull << 27)
166bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_FS              (1ull << 28)
167bf215546Sopenharmony_ci#define IRIS_STAGE_DIRTY_BINDINGS_CS              (1ull << 29)
168bf215546Sopenharmony_ci
169bf215546Sopenharmony_ci#define IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE (IRIS_STAGE_DIRTY_CS | \
170bf215546Sopenharmony_ci                                          IRIS_STAGE_DIRTY_SAMPLER_STATES_CS | \
171bf215546Sopenharmony_ci                                          IRIS_STAGE_DIRTY_UNCOMPILED_CS |    \
172bf215546Sopenharmony_ci                                          IRIS_STAGE_DIRTY_CONSTANTS_CS |     \
173bf215546Sopenharmony_ci                                          IRIS_STAGE_DIRTY_BINDINGS_CS)
174bf215546Sopenharmony_ci
175bf215546Sopenharmony_ci#define IRIS_ALL_STAGE_DIRTY_FOR_RENDER (~IRIS_ALL_STAGE_DIRTY_FOR_COMPUTE)
176bf215546Sopenharmony_ci
177bf215546Sopenharmony_ci#define IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER (IRIS_STAGE_DIRTY_BINDINGS_VS  | \
178bf215546Sopenharmony_ci                                                  IRIS_STAGE_DIRTY_BINDINGS_TCS | \
179bf215546Sopenharmony_ci                                                  IRIS_STAGE_DIRTY_BINDINGS_TES | \
180bf215546Sopenharmony_ci                                                  IRIS_STAGE_DIRTY_BINDINGS_GS  | \
181bf215546Sopenharmony_ci                                                  IRIS_STAGE_DIRTY_BINDINGS_FS)
182bf215546Sopenharmony_ci
183bf215546Sopenharmony_ci#define IRIS_ALL_STAGE_DIRTY_BINDINGS (IRIS_ALL_STAGE_DIRTY_BINDINGS_FOR_RENDER | \
184bf215546Sopenharmony_ci                                       IRIS_STAGE_DIRTY_BINDINGS_CS)
185bf215546Sopenharmony_ci
186bf215546Sopenharmony_ci/**
187bf215546Sopenharmony_ci * Non-orthogonal state (NOS) dependency flags.
188bf215546Sopenharmony_ci *
189bf215546Sopenharmony_ci * Shader programs may depend on non-orthogonal state.  These flags are
190bf215546Sopenharmony_ci * used to indicate that a shader's key depends on the state provided by
191bf215546Sopenharmony_ci * a certain Gallium CSO.  Changing any CSOs marked as a dependency will
192bf215546Sopenharmony_ci * cause the driver to re-compute the shader key, possibly triggering a
193bf215546Sopenharmony_ci * shader recompile.
194bf215546Sopenharmony_ci */
195bf215546Sopenharmony_cienum iris_nos_dep {
196bf215546Sopenharmony_ci   IRIS_NOS_FRAMEBUFFER,
197bf215546Sopenharmony_ci   IRIS_NOS_DEPTH_STENCIL_ALPHA,
198bf215546Sopenharmony_ci   IRIS_NOS_RASTERIZER,
199bf215546Sopenharmony_ci   IRIS_NOS_BLEND,
200bf215546Sopenharmony_ci   IRIS_NOS_LAST_VUE_MAP,
201bf215546Sopenharmony_ci
202bf215546Sopenharmony_ci   IRIS_NOS_COUNT,
203bf215546Sopenharmony_ci};
204bf215546Sopenharmony_ci
205bf215546Sopenharmony_ci/** @{
206bf215546Sopenharmony_ci *
207bf215546Sopenharmony_ci * Program cache keys for state based recompiles.
208bf215546Sopenharmony_ci */
209bf215546Sopenharmony_ci
210bf215546Sopenharmony_ci/* Provide explicit padding for each member, to ensure that the compiler
211bf215546Sopenharmony_ci * initializes every bit in the shader cache keys.  The keys will be compared
212bf215546Sopenharmony_ci * with memcmp.
213bf215546Sopenharmony_ci */
214bf215546Sopenharmony_ciPRAGMA_DIAGNOSTIC_PUSH
215bf215546Sopenharmony_ciPRAGMA_DIAGNOSTIC_ERROR(-Wpadded)
216bf215546Sopenharmony_ci
217bf215546Sopenharmony_ci/**
218bf215546Sopenharmony_ci * Note, we need to take care to have padding explicitly declared
219bf215546Sopenharmony_ci * for key since we will directly memcmp the whole struct.
220bf215546Sopenharmony_ci */
221bf215546Sopenharmony_cistruct iris_base_prog_key {
222bf215546Sopenharmony_ci   unsigned program_string_id;
223bf215546Sopenharmony_ci   bool limit_trig_input_range;
224bf215546Sopenharmony_ci   unsigned padding:24;
225bf215546Sopenharmony_ci};
226bf215546Sopenharmony_ci
227bf215546Sopenharmony_cistruct iris_vue_prog_key {
228bf215546Sopenharmony_ci   struct iris_base_prog_key base;
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_ci   unsigned nr_userclip_plane_consts:4;
231bf215546Sopenharmony_ci   unsigned padding:28;
232bf215546Sopenharmony_ci};
233bf215546Sopenharmony_ci
234bf215546Sopenharmony_cistruct iris_vs_prog_key {
235bf215546Sopenharmony_ci   struct iris_vue_prog_key vue;
236bf215546Sopenharmony_ci};
237bf215546Sopenharmony_ci
238bf215546Sopenharmony_cistruct iris_tcs_prog_key {
239bf215546Sopenharmony_ci   struct iris_vue_prog_key vue;
240bf215546Sopenharmony_ci
241bf215546Sopenharmony_ci   enum tess_primitive_mode _tes_primitive_mode;
242bf215546Sopenharmony_ci
243bf215546Sopenharmony_ci   uint8_t input_vertices;
244bf215546Sopenharmony_ci
245bf215546Sopenharmony_ci   bool quads_workaround;
246bf215546Sopenharmony_ci   unsigned padding:16;
247bf215546Sopenharmony_ci
248bf215546Sopenharmony_ci   /** A bitfield of per-patch outputs written. */
249bf215546Sopenharmony_ci   uint32_t patch_outputs_written;
250bf215546Sopenharmony_ci
251bf215546Sopenharmony_ci   /** A bitfield of per-vertex outputs written. */
252bf215546Sopenharmony_ci   uint64_t outputs_written;
253bf215546Sopenharmony_ci};
254bf215546Sopenharmony_ci
255bf215546Sopenharmony_cistruct iris_tes_prog_key {
256bf215546Sopenharmony_ci   struct iris_vue_prog_key vue;
257bf215546Sopenharmony_ci
258bf215546Sopenharmony_ci   /** A bitfield of per-patch inputs read. */
259bf215546Sopenharmony_ci   uint32_t patch_inputs_read;
260bf215546Sopenharmony_ci
261bf215546Sopenharmony_ci   /** A bitfield of per-vertex inputs read. */
262bf215546Sopenharmony_ci   uint64_t inputs_read;
263bf215546Sopenharmony_ci};
264bf215546Sopenharmony_ci
265bf215546Sopenharmony_cistruct iris_gs_prog_key {
266bf215546Sopenharmony_ci   struct iris_vue_prog_key vue;
267bf215546Sopenharmony_ci};
268bf215546Sopenharmony_ci
269bf215546Sopenharmony_cistruct iris_fs_prog_key {
270bf215546Sopenharmony_ci   struct iris_base_prog_key base;
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci   uint64_t input_slots_valid;
273bf215546Sopenharmony_ci   uint8_t color_outputs_valid;
274bf215546Sopenharmony_ci
275bf215546Sopenharmony_ci   unsigned nr_color_regions:5;
276bf215546Sopenharmony_ci   bool flat_shade:1;
277bf215546Sopenharmony_ci   bool alpha_test_replicate_alpha:1;
278bf215546Sopenharmony_ci   bool alpha_to_coverage:1;
279bf215546Sopenharmony_ci   bool clamp_fragment_color:1;
280bf215546Sopenharmony_ci   bool persample_interp:1;
281bf215546Sopenharmony_ci   bool multisample_fbo:1;
282bf215546Sopenharmony_ci   bool force_dual_color_blend:1;
283bf215546Sopenharmony_ci   bool coherent_fb_fetch:1;
284bf215546Sopenharmony_ci   uint64_t padding:43;
285bf215546Sopenharmony_ci};
286bf215546Sopenharmony_ci
287bf215546Sopenharmony_cistruct iris_cs_prog_key {
288bf215546Sopenharmony_ci   struct iris_base_prog_key base;
289bf215546Sopenharmony_ci};
290bf215546Sopenharmony_ci
291bf215546Sopenharmony_ciunion iris_any_prog_key {
292bf215546Sopenharmony_ci   struct iris_base_prog_key base;
293bf215546Sopenharmony_ci   struct iris_vue_prog_key vue;
294bf215546Sopenharmony_ci   struct iris_vs_prog_key vs;
295bf215546Sopenharmony_ci   struct iris_tcs_prog_key tcs;
296bf215546Sopenharmony_ci   struct iris_tes_prog_key tes;
297bf215546Sopenharmony_ci   struct iris_gs_prog_key gs;
298bf215546Sopenharmony_ci   struct iris_fs_prog_key fs;
299bf215546Sopenharmony_ci   struct iris_cs_prog_key cs;
300bf215546Sopenharmony_ci};
301bf215546Sopenharmony_ci
302bf215546Sopenharmony_ci/* Restore the pack alignment to default. */
303bf215546Sopenharmony_ciPRAGMA_DIAGNOSTIC_POP
304bf215546Sopenharmony_ci
305bf215546Sopenharmony_ci/** @} */
306bf215546Sopenharmony_ci
307bf215546Sopenharmony_cistruct iris_depth_stencil_alpha_state;
308bf215546Sopenharmony_ci
309bf215546Sopenharmony_ci/**
310bf215546Sopenharmony_ci * Cache IDs for the in-memory program cache (ice->shaders.cache).
311bf215546Sopenharmony_ci */
312bf215546Sopenharmony_cienum iris_program_cache_id {
313bf215546Sopenharmony_ci   IRIS_CACHE_VS  = MESA_SHADER_VERTEX,
314bf215546Sopenharmony_ci   IRIS_CACHE_TCS = MESA_SHADER_TESS_CTRL,
315bf215546Sopenharmony_ci   IRIS_CACHE_TES = MESA_SHADER_TESS_EVAL,
316bf215546Sopenharmony_ci   IRIS_CACHE_GS  = MESA_SHADER_GEOMETRY,
317bf215546Sopenharmony_ci   IRIS_CACHE_FS  = MESA_SHADER_FRAGMENT,
318bf215546Sopenharmony_ci   IRIS_CACHE_CS  = MESA_SHADER_COMPUTE,
319bf215546Sopenharmony_ci   IRIS_CACHE_BLORP,
320bf215546Sopenharmony_ci};
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_ci/** @{
323bf215546Sopenharmony_ci *
324bf215546Sopenharmony_ci * Defines for PIPE_CONTROL operations, which trigger cache flushes,
325bf215546Sopenharmony_ci * synchronization, pipelined memory writes, and so on.
326bf215546Sopenharmony_ci *
327bf215546Sopenharmony_ci * The bits here are not the actual hardware values.  The actual fields
328bf215546Sopenharmony_ci * move between various generations, so we just have flags for each
329bf215546Sopenharmony_ci * potential operation, and use genxml to encode the actual packet.
330bf215546Sopenharmony_ci */
331bf215546Sopenharmony_cienum pipe_control_flags
332bf215546Sopenharmony_ci{
333bf215546Sopenharmony_ci   PIPE_CONTROL_FLUSH_LLC                       = (1 << 1),
334bf215546Sopenharmony_ci   PIPE_CONTROL_LRI_POST_SYNC_OP                = (1 << 2),
335bf215546Sopenharmony_ci   PIPE_CONTROL_STORE_DATA_INDEX                = (1 << 3),
336bf215546Sopenharmony_ci   PIPE_CONTROL_CS_STALL                        = (1 << 4),
337bf215546Sopenharmony_ci   PIPE_CONTROL_GLOBAL_SNAPSHOT_COUNT_RESET     = (1 << 5),
338bf215546Sopenharmony_ci   PIPE_CONTROL_SYNC_GFDT                       = (1 << 6),
339bf215546Sopenharmony_ci   PIPE_CONTROL_TLB_INVALIDATE                  = (1 << 7),
340bf215546Sopenharmony_ci   PIPE_CONTROL_MEDIA_STATE_CLEAR               = (1 << 8),
341bf215546Sopenharmony_ci   PIPE_CONTROL_WRITE_IMMEDIATE                 = (1 << 9),
342bf215546Sopenharmony_ci   PIPE_CONTROL_WRITE_DEPTH_COUNT               = (1 << 10),
343bf215546Sopenharmony_ci   PIPE_CONTROL_WRITE_TIMESTAMP                 = (1 << 11),
344bf215546Sopenharmony_ci   PIPE_CONTROL_DEPTH_STALL                     = (1 << 12),
345bf215546Sopenharmony_ci   PIPE_CONTROL_RENDER_TARGET_FLUSH             = (1 << 13),
346bf215546Sopenharmony_ci   PIPE_CONTROL_INSTRUCTION_INVALIDATE          = (1 << 14),
347bf215546Sopenharmony_ci   PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE        = (1 << 15),
348bf215546Sopenharmony_ci   PIPE_CONTROL_INDIRECT_STATE_POINTERS_DISABLE = (1 << 16),
349bf215546Sopenharmony_ci   PIPE_CONTROL_NOTIFY_ENABLE                   = (1 << 17),
350bf215546Sopenharmony_ci   PIPE_CONTROL_FLUSH_ENABLE                    = (1 << 18),
351bf215546Sopenharmony_ci   PIPE_CONTROL_DATA_CACHE_FLUSH                = (1 << 19),
352bf215546Sopenharmony_ci   PIPE_CONTROL_VF_CACHE_INVALIDATE             = (1 << 20),
353bf215546Sopenharmony_ci   PIPE_CONTROL_CONST_CACHE_INVALIDATE          = (1 << 21),
354bf215546Sopenharmony_ci   PIPE_CONTROL_STATE_CACHE_INVALIDATE          = (1 << 22),
355bf215546Sopenharmony_ci   PIPE_CONTROL_STALL_AT_SCOREBOARD             = (1 << 23),
356bf215546Sopenharmony_ci   PIPE_CONTROL_DEPTH_CACHE_FLUSH               = (1 << 24),
357bf215546Sopenharmony_ci   PIPE_CONTROL_TILE_CACHE_FLUSH                = (1 << 25),
358bf215546Sopenharmony_ci   PIPE_CONTROL_FLUSH_HDC                       = (1 << 26),
359bf215546Sopenharmony_ci   PIPE_CONTROL_PSS_STALL_SYNC                  = (1 << 27),
360bf215546Sopenharmony_ci   PIPE_CONTROL_L3_READ_ONLY_CACHE_INVALIDATE   = (1 << 28),
361bf215546Sopenharmony_ci};
362bf215546Sopenharmony_ci
363bf215546Sopenharmony_ci#define PIPE_CONTROL_CACHE_FLUSH_BITS \
364bf215546Sopenharmony_ci   (PIPE_CONTROL_DEPTH_CACHE_FLUSH |  \
365bf215546Sopenharmony_ci    PIPE_CONTROL_DATA_CACHE_FLUSH |   \
366bf215546Sopenharmony_ci    PIPE_CONTROL_TILE_CACHE_FLUSH |   \
367bf215546Sopenharmony_ci    PIPE_CONTROL_FLUSH_HDC | \
368bf215546Sopenharmony_ci    PIPE_CONTROL_RENDER_TARGET_FLUSH)
369bf215546Sopenharmony_ci
370bf215546Sopenharmony_ci#define PIPE_CONTROL_CACHE_INVALIDATE_BITS  \
371bf215546Sopenharmony_ci   (PIPE_CONTROL_STATE_CACHE_INVALIDATE |   \
372bf215546Sopenharmony_ci    PIPE_CONTROL_CONST_CACHE_INVALIDATE |   \
373bf215546Sopenharmony_ci    PIPE_CONTROL_VF_CACHE_INVALIDATE |      \
374bf215546Sopenharmony_ci    PIPE_CONTROL_TEXTURE_CACHE_INVALIDATE | \
375bf215546Sopenharmony_ci    PIPE_CONTROL_INSTRUCTION_INVALIDATE)
376bf215546Sopenharmony_ci
377bf215546Sopenharmony_ci#define PIPE_CONTROL_L3_RO_INVALIDATE_BITS       \
378bf215546Sopenharmony_ci   (PIPE_CONTROL_L3_READ_ONLY_CACHE_INVALIDATE | \
379bf215546Sopenharmony_ci    PIPE_CONTROL_CONST_CACHE_INVALIDATE)
380bf215546Sopenharmony_ci
381bf215546Sopenharmony_cienum iris_predicate_state {
382bf215546Sopenharmony_ci   /* The first two states are used if we can determine whether to draw
383bf215546Sopenharmony_ci    * without having to look at the values in the query object buffer. This
384bf215546Sopenharmony_ci    * will happen if there is no conditional render in progress, if the query
385bf215546Sopenharmony_ci    * object is already completed or if something else has already added
386bf215546Sopenharmony_ci    * samples to the preliminary result.
387bf215546Sopenharmony_ci    */
388bf215546Sopenharmony_ci   IRIS_PREDICATE_STATE_RENDER,
389bf215546Sopenharmony_ci   IRIS_PREDICATE_STATE_DONT_RENDER,
390bf215546Sopenharmony_ci
391bf215546Sopenharmony_ci   /* In this case whether to draw or not depends on the result of an
392bf215546Sopenharmony_ci    * MI_PREDICATE command so the predicate enable bit needs to be checked.
393bf215546Sopenharmony_ci    */
394bf215546Sopenharmony_ci   IRIS_PREDICATE_STATE_USE_BIT,
395bf215546Sopenharmony_ci};
396bf215546Sopenharmony_ci
397bf215546Sopenharmony_ci/** @} */
398bf215546Sopenharmony_ci
399bf215546Sopenharmony_ci/**
400bf215546Sopenharmony_ci * An uncompiled, API-facing shader.  This is the Gallium CSO for shaders.
401bf215546Sopenharmony_ci * It primarily contains the NIR for the shader.
402bf215546Sopenharmony_ci *
403bf215546Sopenharmony_ci * Each API-facing shader can be compiled into multiple shader variants,
404bf215546Sopenharmony_ci * based on non-orthogonal state dependencies, recorded in the shader key.
405bf215546Sopenharmony_ci *
406bf215546Sopenharmony_ci * See iris_compiled_shader, which represents a compiled shader variant.
407bf215546Sopenharmony_ci */
408bf215546Sopenharmony_cistruct iris_uncompiled_shader {
409bf215546Sopenharmony_ci   struct pipe_reference ref;
410bf215546Sopenharmony_ci
411bf215546Sopenharmony_ci   /**
412bf215546Sopenharmony_ci    * NIR for the shader.
413bf215546Sopenharmony_ci    *
414bf215546Sopenharmony_ci    * Even for shaders that originate as TGSI, this pointer will be non-NULL.
415bf215546Sopenharmony_ci    */
416bf215546Sopenharmony_ci   struct nir_shader *nir;
417bf215546Sopenharmony_ci
418bf215546Sopenharmony_ci   struct pipe_stream_output_info stream_output;
419bf215546Sopenharmony_ci
420bf215546Sopenharmony_ci   /* A SHA1 of the serialized NIR for the disk cache. */
421bf215546Sopenharmony_ci   unsigned char nir_sha1[20];
422bf215546Sopenharmony_ci
423bf215546Sopenharmony_ci   unsigned program_id;
424bf215546Sopenharmony_ci
425bf215546Sopenharmony_ci   /** Bitfield of (1 << IRIS_NOS_*) flags. */
426bf215546Sopenharmony_ci   unsigned nos;
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_ci   /** Have any shader variants been compiled yet? */
429bf215546Sopenharmony_ci   bool compiled_once;
430bf215546Sopenharmony_ci
431bf215546Sopenharmony_ci   /* Whether shader uses atomic operations. */
432bf215546Sopenharmony_ci   bool uses_atomic_load_store;
433bf215546Sopenharmony_ci
434bf215546Sopenharmony_ci   /** Size (in bytes) of the kernel input data */
435bf215546Sopenharmony_ci   unsigned kernel_input_size;
436bf215546Sopenharmony_ci
437bf215546Sopenharmony_ci   /** Size (in bytes) of the local (shared) data passed as kernel inputs */
438bf215546Sopenharmony_ci   unsigned kernel_shared_size;
439bf215546Sopenharmony_ci
440bf215546Sopenharmony_ci   /** List of iris_compiled_shader variants */
441bf215546Sopenharmony_ci   struct list_head variants;
442bf215546Sopenharmony_ci
443bf215546Sopenharmony_ci   /** Lock for the variants list */
444bf215546Sopenharmony_ci   simple_mtx_t lock;
445bf215546Sopenharmony_ci
446bf215546Sopenharmony_ci   /** For parallel shader compiles */
447bf215546Sopenharmony_ci   struct util_queue_fence ready;
448bf215546Sopenharmony_ci};
449bf215546Sopenharmony_ci
450bf215546Sopenharmony_cienum iris_surface_group {
451bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_RENDER_TARGET,
452bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_RENDER_TARGET_READ,
453bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_CS_WORK_GROUPS,
454bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_TEXTURE,
455bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_IMAGE,
456bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_UBO,
457bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_SSBO,
458bf215546Sopenharmony_ci
459bf215546Sopenharmony_ci   IRIS_SURFACE_GROUP_COUNT,
460bf215546Sopenharmony_ci};
461bf215546Sopenharmony_ci
462bf215546Sopenharmony_cienum {
463bf215546Sopenharmony_ci   /* Invalid value for a binding table index. */
464bf215546Sopenharmony_ci   IRIS_SURFACE_NOT_USED = 0xa0a0a0a0,
465bf215546Sopenharmony_ci};
466bf215546Sopenharmony_ci
467bf215546Sopenharmony_cistruct iris_binding_table {
468bf215546Sopenharmony_ci   uint32_t size_bytes;
469bf215546Sopenharmony_ci
470bf215546Sopenharmony_ci   /** Number of surfaces in each group, before compacting. */
471bf215546Sopenharmony_ci   uint32_t sizes[IRIS_SURFACE_GROUP_COUNT];
472bf215546Sopenharmony_ci
473bf215546Sopenharmony_ci   /** Initial offset of each group. */
474bf215546Sopenharmony_ci   uint32_t offsets[IRIS_SURFACE_GROUP_COUNT];
475bf215546Sopenharmony_ci
476bf215546Sopenharmony_ci   /** Mask of surfaces used in each group. */
477bf215546Sopenharmony_ci   uint64_t used_mask[IRIS_SURFACE_GROUP_COUNT];
478bf215546Sopenharmony_ci};
479bf215546Sopenharmony_ci
480bf215546Sopenharmony_ci/**
481bf215546Sopenharmony_ci * A compiled shader variant, containing a pointer to the GPU assembly,
482bf215546Sopenharmony_ci * as well as program data and other packets needed by state upload.
483bf215546Sopenharmony_ci *
484bf215546Sopenharmony_ci * There can be several iris_compiled_shader variants per API-level shader
485bf215546Sopenharmony_ci * (iris_uncompiled_shader), due to state-based recompiles (brw_*_prog_key).
486bf215546Sopenharmony_ci */
487bf215546Sopenharmony_cistruct iris_compiled_shader {
488bf215546Sopenharmony_ci   struct pipe_reference ref;
489bf215546Sopenharmony_ci
490bf215546Sopenharmony_ci   /** Link in the iris_uncompiled_shader::variants list */
491bf215546Sopenharmony_ci   struct list_head link;
492bf215546Sopenharmony_ci
493bf215546Sopenharmony_ci   /** Key for this variant (but not for BLORP programs) */
494bf215546Sopenharmony_ci   union iris_any_prog_key key;
495bf215546Sopenharmony_ci
496bf215546Sopenharmony_ci   /**
497bf215546Sopenharmony_ci    * Is the variant fully compiled and ready?
498bf215546Sopenharmony_ci    *
499bf215546Sopenharmony_ci    * Variants are added to \c iris_uncompiled_shader::variants before
500bf215546Sopenharmony_ci    * compilation actually occurs.  This signals that compilation has
501bf215546Sopenharmony_ci    * completed.
502bf215546Sopenharmony_ci    */
503bf215546Sopenharmony_ci   struct util_queue_fence ready;
504bf215546Sopenharmony_ci
505bf215546Sopenharmony_ci   /** Variant is ready, but compilation failed. */
506bf215546Sopenharmony_ci   bool compilation_failed;
507bf215546Sopenharmony_ci
508bf215546Sopenharmony_ci   /** Reference to the uploaded assembly. */
509bf215546Sopenharmony_ci   struct iris_state_ref assembly;
510bf215546Sopenharmony_ci
511bf215546Sopenharmony_ci   /** Pointer to the assembly in the BO's map. */
512bf215546Sopenharmony_ci   void *map;
513bf215546Sopenharmony_ci
514bf215546Sopenharmony_ci   /** The program data (owned by the program cache hash table) */
515bf215546Sopenharmony_ci   struct brw_stage_prog_data *prog_data;
516bf215546Sopenharmony_ci
517bf215546Sopenharmony_ci   /** A list of system values to be uploaded as uniforms. */
518bf215546Sopenharmony_ci   enum brw_param_builtin *system_values;
519bf215546Sopenharmony_ci   unsigned num_system_values;
520bf215546Sopenharmony_ci
521bf215546Sopenharmony_ci   /** Size (in bytes) of the kernel input data */
522bf215546Sopenharmony_ci   unsigned kernel_input_size;
523bf215546Sopenharmony_ci
524bf215546Sopenharmony_ci   /** Number of constbufs expected by the shader. */
525bf215546Sopenharmony_ci   unsigned num_cbufs;
526bf215546Sopenharmony_ci
527bf215546Sopenharmony_ci   /**
528bf215546Sopenharmony_ci    * Derived 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets
529bf215546Sopenharmony_ci    * (the VUE-based information for transform feedback outputs).
530bf215546Sopenharmony_ci    */
531bf215546Sopenharmony_ci   uint32_t *streamout;
532bf215546Sopenharmony_ci
533bf215546Sopenharmony_ci   struct iris_binding_table bt;
534bf215546Sopenharmony_ci
535bf215546Sopenharmony_ci   /**
536bf215546Sopenharmony_ci    * Shader packets and other data derived from prog_data.  These must be
537bf215546Sopenharmony_ci    * completely determined from prog_data.
538bf215546Sopenharmony_ci    */
539bf215546Sopenharmony_ci   uint8_t derived_data[0];
540bf215546Sopenharmony_ci};
541bf215546Sopenharmony_ci
542bf215546Sopenharmony_ci/**
543bf215546Sopenharmony_ci * API context state that is replicated per shader stage.
544bf215546Sopenharmony_ci */
545bf215546Sopenharmony_cistruct iris_shader_state {
546bf215546Sopenharmony_ci   /** Uniform Buffers */
547bf215546Sopenharmony_ci   struct pipe_shader_buffer constbuf[PIPE_MAX_CONSTANT_BUFFERS];
548bf215546Sopenharmony_ci   struct iris_state_ref constbuf_surf_state[PIPE_MAX_CONSTANT_BUFFERS];
549bf215546Sopenharmony_ci
550bf215546Sopenharmony_ci   bool sysvals_need_upload;
551bf215546Sopenharmony_ci
552bf215546Sopenharmony_ci   /** Shader Storage Buffers */
553bf215546Sopenharmony_ci   struct pipe_shader_buffer ssbo[PIPE_MAX_SHADER_BUFFERS];
554bf215546Sopenharmony_ci   struct iris_state_ref ssbo_surf_state[PIPE_MAX_SHADER_BUFFERS];
555bf215546Sopenharmony_ci
556bf215546Sopenharmony_ci   /** Shader Storage Images (image load store) */
557bf215546Sopenharmony_ci   struct iris_image_view image[PIPE_MAX_SHADER_IMAGES];
558bf215546Sopenharmony_ci
559bf215546Sopenharmony_ci   struct iris_state_ref sampler_table;
560bf215546Sopenharmony_ci   struct iris_sampler_state *samplers[IRIS_MAX_TEXTURE_SAMPLERS];
561bf215546Sopenharmony_ci   struct iris_sampler_view *textures[IRIS_MAX_TEXTURE_SAMPLERS];
562bf215546Sopenharmony_ci
563bf215546Sopenharmony_ci   /** Bitfield of which constant buffers are bound (non-null). */
564bf215546Sopenharmony_ci   uint32_t bound_cbufs;
565bf215546Sopenharmony_ci   uint32_t dirty_cbufs;
566bf215546Sopenharmony_ci
567bf215546Sopenharmony_ci   /** Bitfield of which image views are bound (non-null). */
568bf215546Sopenharmony_ci   uint32_t bound_image_views;
569bf215546Sopenharmony_ci
570bf215546Sopenharmony_ci   /** Bitfield of which sampler views are bound (non-null). */
571bf215546Sopenharmony_ci   uint32_t bound_sampler_views;
572bf215546Sopenharmony_ci
573bf215546Sopenharmony_ci   /** Bitfield of which shader storage buffers are bound (non-null). */
574bf215546Sopenharmony_ci   uint32_t bound_ssbos;
575bf215546Sopenharmony_ci
576bf215546Sopenharmony_ci   /** Bitfield of which shader storage buffers are writable. */
577bf215546Sopenharmony_ci   uint32_t writable_ssbos;
578bf215546Sopenharmony_ci};
579bf215546Sopenharmony_ci
580bf215546Sopenharmony_ci/**
581bf215546Sopenharmony_ci * Gallium CSO for stream output (transform feedback) targets.
582bf215546Sopenharmony_ci */
583bf215546Sopenharmony_cistruct iris_stream_output_target {
584bf215546Sopenharmony_ci   struct pipe_stream_output_target base;
585bf215546Sopenharmony_ci
586bf215546Sopenharmony_ci   /** Storage holding the offset where we're writing in the buffer */
587bf215546Sopenharmony_ci   struct iris_state_ref offset;
588bf215546Sopenharmony_ci
589bf215546Sopenharmony_ci   /** Stride (bytes-per-vertex) during this transform feedback operation */
590bf215546Sopenharmony_ci   uint16_t stride;
591bf215546Sopenharmony_ci
592bf215546Sopenharmony_ci   /** Does the next 3DSTATE_SO_BUFFER need to zero the offsets? */
593bf215546Sopenharmony_ci   bool zero_offset;
594bf215546Sopenharmony_ci};
595bf215546Sopenharmony_ci
596bf215546Sopenharmony_ci/**
597bf215546Sopenharmony_ci * The API context (derived from pipe_context).
598bf215546Sopenharmony_ci *
599bf215546Sopenharmony_ci * Most driver state is tracked here.
600bf215546Sopenharmony_ci */
601bf215546Sopenharmony_cistruct iris_context {
602bf215546Sopenharmony_ci   struct pipe_context ctx;
603bf215546Sopenharmony_ci   struct threaded_context *thrctx;
604bf215546Sopenharmony_ci
605bf215546Sopenharmony_ci   /** A debug callback for KHR_debug output. */
606bf215546Sopenharmony_ci   struct util_debug_callback dbg;
607bf215546Sopenharmony_ci
608bf215546Sopenharmony_ci   /** A device reset status callback for notifying that the GPU is hosed. */
609bf215546Sopenharmony_ci   struct pipe_device_reset_callback reset;
610bf215546Sopenharmony_ci
611bf215546Sopenharmony_ci   /** A set of dmabuf resources dirtied beyond their default aux-states. */
612bf215546Sopenharmony_ci   struct set *dirty_dmabufs;
613bf215546Sopenharmony_ci
614bf215546Sopenharmony_ci   /** Slab allocator for iris_transfer_map objects. */
615bf215546Sopenharmony_ci   struct slab_child_pool transfer_pool;
616bf215546Sopenharmony_ci
617bf215546Sopenharmony_ci   /** Slab allocator for threaded_context's iris_transfer_map objects */
618bf215546Sopenharmony_ci   struct slab_child_pool transfer_pool_unsync;
619bf215546Sopenharmony_ci
620bf215546Sopenharmony_ci   struct blorp_context blorp;
621bf215546Sopenharmony_ci
622bf215546Sopenharmony_ci   struct iris_batch batches[IRIS_BATCH_COUNT];
623bf215546Sopenharmony_ci
624bf215546Sopenharmony_ci   struct u_upload_mgr *query_buffer_uploader;
625bf215546Sopenharmony_ci
626bf215546Sopenharmony_ci   struct intel_ds_device ds;
627bf215546Sopenharmony_ci
628bf215546Sopenharmony_ci   struct {
629bf215546Sopenharmony_ci      struct {
630bf215546Sopenharmony_ci         /**
631bf215546Sopenharmony_ci          * Either the value of BaseVertex for indexed draw calls or the value
632bf215546Sopenharmony_ci          * of the argument <first> for non-indexed draw calls.
633bf215546Sopenharmony_ci          */
634bf215546Sopenharmony_ci         int firstvertex;
635bf215546Sopenharmony_ci         int baseinstance;
636bf215546Sopenharmony_ci      } params;
637bf215546Sopenharmony_ci
638bf215546Sopenharmony_ci      /**
639bf215546Sopenharmony_ci       * Are the above values the ones stored in the draw_params buffer?
640bf215546Sopenharmony_ci       * If so, we can compare them against new values to see if anything
641bf215546Sopenharmony_ci       * changed.  If not, we need to assume they changed.
642bf215546Sopenharmony_ci       */
643bf215546Sopenharmony_ci      bool params_valid;
644bf215546Sopenharmony_ci
645bf215546Sopenharmony_ci      /**
646bf215546Sopenharmony_ci       * Resource and offset that stores draw_parameters from the indirect
647bf215546Sopenharmony_ci       * buffer or to the buffer that stures the previous values for non
648bf215546Sopenharmony_ci       * indirect draws.
649bf215546Sopenharmony_ci       */
650bf215546Sopenharmony_ci      struct iris_state_ref draw_params;
651bf215546Sopenharmony_ci
652bf215546Sopenharmony_ci      struct {
653bf215546Sopenharmony_ci         /**
654bf215546Sopenharmony_ci          * The value of DrawID. This always comes in from it's own vertex
655bf215546Sopenharmony_ci          * buffer since it's not part of the indirect draw parameters.
656bf215546Sopenharmony_ci          */
657bf215546Sopenharmony_ci         int drawid;
658bf215546Sopenharmony_ci
659bf215546Sopenharmony_ci         /**
660bf215546Sopenharmony_ci          * Stores if an indexed or non-indexed draw (~0/0). Useful to
661bf215546Sopenharmony_ci          * calculate BaseVertex as an AND of firstvertex and is_indexed_draw.
662bf215546Sopenharmony_ci          */
663bf215546Sopenharmony_ci         int is_indexed_draw;
664bf215546Sopenharmony_ci      } derived_params;
665bf215546Sopenharmony_ci
666bf215546Sopenharmony_ci      /**
667bf215546Sopenharmony_ci       * Resource and offset used for GL_ARB_shader_draw_parameters which
668bf215546Sopenharmony_ci       * contains parameters that are not present in the indirect buffer as
669bf215546Sopenharmony_ci       * drawid and is_indexed_draw. They will go in their own vertex element.
670bf215546Sopenharmony_ci       */
671bf215546Sopenharmony_ci      struct iris_state_ref derived_draw_params;
672bf215546Sopenharmony_ci   } draw;
673bf215546Sopenharmony_ci
674bf215546Sopenharmony_ci   struct {
675bf215546Sopenharmony_ci      struct iris_uncompiled_shader *uncompiled[MESA_SHADER_STAGES];
676bf215546Sopenharmony_ci      struct iris_compiled_shader *prog[MESA_SHADER_STAGES];
677bf215546Sopenharmony_ci      struct iris_compiled_shader *last_vue_shader;
678bf215546Sopenharmony_ci      struct {
679bf215546Sopenharmony_ci         unsigned size[4];
680bf215546Sopenharmony_ci         unsigned entries[4];
681bf215546Sopenharmony_ci         unsigned start[4];
682bf215546Sopenharmony_ci         bool constrained;
683bf215546Sopenharmony_ci      } urb;
684bf215546Sopenharmony_ci
685bf215546Sopenharmony_ci      /** Uploader for shader assembly from the driver thread */
686bf215546Sopenharmony_ci      struct u_upload_mgr *uploader_driver;
687bf215546Sopenharmony_ci      /** Uploader for shader assembly from the threaded context */
688bf215546Sopenharmony_ci      struct u_upload_mgr *uploader_unsync;
689bf215546Sopenharmony_ci      struct hash_table *cache;
690bf215546Sopenharmony_ci
691bf215546Sopenharmony_ci      /** Is a GS or TES outputting points or lines? */
692bf215546Sopenharmony_ci      bool output_topology_is_points_or_lines;
693bf215546Sopenharmony_ci
694bf215546Sopenharmony_ci      /**
695bf215546Sopenharmony_ci       * Scratch buffers for various sizes and stages.
696bf215546Sopenharmony_ci       *
697bf215546Sopenharmony_ci       * Indexed by the "Per-Thread Scratch Space" field's 4-bit encoding,
698bf215546Sopenharmony_ci       * and shader stage.
699bf215546Sopenharmony_ci       */
700bf215546Sopenharmony_ci      struct iris_bo *scratch_bos[1 << 4][MESA_SHADER_STAGES];
701bf215546Sopenharmony_ci
702bf215546Sopenharmony_ci      /**
703bf215546Sopenharmony_ci       * Scratch buffer surface states on Gfx12.5+
704bf215546Sopenharmony_ci       */
705bf215546Sopenharmony_ci      struct iris_state_ref scratch_surfs[1 << 4];
706bf215546Sopenharmony_ci   } shaders;
707bf215546Sopenharmony_ci
708bf215546Sopenharmony_ci   struct intel_perf_context *perf_ctx;
709bf215546Sopenharmony_ci
710bf215546Sopenharmony_ci   /** Frame number for debug prints */
711bf215546Sopenharmony_ci   uint32_t frame;
712bf215546Sopenharmony_ci
713bf215546Sopenharmony_ci   struct {
714bf215546Sopenharmony_ci      uint64_t dirty;
715bf215546Sopenharmony_ci      uint64_t stage_dirty;
716bf215546Sopenharmony_ci      uint64_t stage_dirty_for_nos[IRIS_NOS_COUNT];
717bf215546Sopenharmony_ci
718bf215546Sopenharmony_ci      unsigned num_viewports;
719bf215546Sopenharmony_ci      unsigned sample_mask;
720bf215546Sopenharmony_ci      struct iris_blend_state *cso_blend;
721bf215546Sopenharmony_ci      struct iris_rasterizer_state *cso_rast;
722bf215546Sopenharmony_ci      struct iris_depth_stencil_alpha_state *cso_zsa;
723bf215546Sopenharmony_ci      struct iris_vertex_element_state *cso_vertex_elements;
724bf215546Sopenharmony_ci      struct pipe_blend_color blend_color;
725bf215546Sopenharmony_ci      struct pipe_poly_stipple poly_stipple;
726bf215546Sopenharmony_ci      struct pipe_viewport_state viewports[IRIS_MAX_VIEWPORTS];
727bf215546Sopenharmony_ci      struct pipe_scissor_state scissors[IRIS_MAX_VIEWPORTS];
728bf215546Sopenharmony_ci      struct pipe_stencil_ref stencil_ref;
729bf215546Sopenharmony_ci      struct pipe_framebuffer_state framebuffer;
730bf215546Sopenharmony_ci      struct pipe_clip_state clip_planes;
731bf215546Sopenharmony_ci
732bf215546Sopenharmony_ci      float default_outer_level[4];
733bf215546Sopenharmony_ci      float default_inner_level[2];
734bf215546Sopenharmony_ci
735bf215546Sopenharmony_ci      /** Bitfield of which vertex buffers are bound (non-null). */
736bf215546Sopenharmony_ci      uint64_t bound_vertex_buffers;
737bf215546Sopenharmony_ci
738bf215546Sopenharmony_ci      uint8_t patch_vertices;
739bf215546Sopenharmony_ci      bool primitive_restart;
740bf215546Sopenharmony_ci      unsigned cut_index;
741bf215546Sopenharmony_ci      enum pipe_prim_type prim_mode:8;
742bf215546Sopenharmony_ci      bool prim_is_points_or_lines;
743bf215546Sopenharmony_ci      uint8_t vertices_per_patch;
744bf215546Sopenharmony_ci
745bf215546Sopenharmony_ci      bool window_space_position;
746bf215546Sopenharmony_ci
747bf215546Sopenharmony_ci      /** The last compute group size */
748bf215546Sopenharmony_ci      uint32_t last_block[3];
749bf215546Sopenharmony_ci
750bf215546Sopenharmony_ci      /** The last compute grid size */
751bf215546Sopenharmony_ci      uint32_t last_grid[3];
752bf215546Sopenharmony_ci      /** The last compute grid dimensions */
753bf215546Sopenharmony_ci      uint32_t last_grid_dim;
754bf215546Sopenharmony_ci      /** Reference to the BO containing the compute grid size */
755bf215546Sopenharmony_ci      struct iris_state_ref grid_size;
756bf215546Sopenharmony_ci      /** Reference to the SURFACE_STATE for the compute grid resource */
757bf215546Sopenharmony_ci      struct iris_state_ref grid_surf_state;
758bf215546Sopenharmony_ci
759bf215546Sopenharmony_ci      /**
760bf215546Sopenharmony_ci       * Array of aux usages for drawing, altered to account for any
761bf215546Sopenharmony_ci       * self-dependencies from resources bound for sampling and rendering.
762bf215546Sopenharmony_ci       */
763bf215546Sopenharmony_ci      enum isl_aux_usage draw_aux_usage[BRW_MAX_DRAW_BUFFERS];
764bf215546Sopenharmony_ci
765bf215546Sopenharmony_ci      /** Aux usage of the fb's depth buffer (which may or may not exist). */
766bf215546Sopenharmony_ci      enum isl_aux_usage hiz_usage;
767bf215546Sopenharmony_ci
768bf215546Sopenharmony_ci      enum intel_urb_deref_block_size urb_deref_block_size;
769bf215546Sopenharmony_ci
770bf215546Sopenharmony_ci      /** Are depth writes enabled?  (Depth buffer may or may not exist.) */
771bf215546Sopenharmony_ci      bool depth_writes_enabled;
772bf215546Sopenharmony_ci
773bf215546Sopenharmony_ci      /** Are stencil writes enabled?  (Stencil buffer may or may not exist.) */
774bf215546Sopenharmony_ci      bool stencil_writes_enabled;
775bf215546Sopenharmony_ci
776bf215546Sopenharmony_ci      /** GenX-specific current state */
777bf215546Sopenharmony_ci      struct iris_genx_state *genx;
778bf215546Sopenharmony_ci
779bf215546Sopenharmony_ci      struct iris_shader_state shaders[MESA_SHADER_STAGES];
780bf215546Sopenharmony_ci
781bf215546Sopenharmony_ci      /** Do vertex shader uses shader draw parameters ? */
782bf215546Sopenharmony_ci      bool vs_uses_draw_params;
783bf215546Sopenharmony_ci      bool vs_uses_derived_draw_params;
784bf215546Sopenharmony_ci      bool vs_needs_sgvs_element;
785bf215546Sopenharmony_ci
786bf215546Sopenharmony_ci      /** Do vertex shader uses edge flag ? */
787bf215546Sopenharmony_ci      bool vs_needs_edge_flag;
788bf215546Sopenharmony_ci
789bf215546Sopenharmony_ci      /** Do any samplers need border color?  One bit per shader stage. */
790bf215546Sopenharmony_ci      uint8_t need_border_colors;
791bf215546Sopenharmony_ci
792bf215546Sopenharmony_ci      /** Global resource bindings */
793bf215546Sopenharmony_ci      struct pipe_resource *global_bindings[IRIS_MAX_GLOBAL_BINDINGS];
794bf215546Sopenharmony_ci
795bf215546Sopenharmony_ci      struct pipe_stream_output_target *so_target[PIPE_MAX_SO_BUFFERS];
796bf215546Sopenharmony_ci      bool streamout_active;
797bf215546Sopenharmony_ci
798bf215546Sopenharmony_ci      bool statistics_counters_enabled;
799bf215546Sopenharmony_ci
800bf215546Sopenharmony_ci      /** Current conditional rendering mode */
801bf215546Sopenharmony_ci      enum iris_predicate_state predicate;
802bf215546Sopenharmony_ci
803bf215546Sopenharmony_ci      /**
804bf215546Sopenharmony_ci       * Query BO with a MI_PREDICATE_RESULT snapshot calculated on the
805bf215546Sopenharmony_ci       * render context that needs to be uploaded to the compute context.
806bf215546Sopenharmony_ci       */
807bf215546Sopenharmony_ci      struct iris_bo *compute_predicate;
808bf215546Sopenharmony_ci
809bf215546Sopenharmony_ci      /** Is a PIPE_QUERY_PRIMITIVES_GENERATED query active? */
810bf215546Sopenharmony_ci      bool prims_generated_query_active;
811bf215546Sopenharmony_ci
812bf215546Sopenharmony_ci      /** 3DSTATE_STREAMOUT and 3DSTATE_SO_DECL_LIST packets */
813bf215546Sopenharmony_ci      uint32_t *streamout;
814bf215546Sopenharmony_ci
815bf215546Sopenharmony_ci      /** The SURFACE_STATE for a 1x1x1 null surface. */
816bf215546Sopenharmony_ci      struct iris_state_ref unbound_tex;
817bf215546Sopenharmony_ci
818bf215546Sopenharmony_ci      /** The SURFACE_STATE for a framebuffer-sized null surface. */
819bf215546Sopenharmony_ci      struct iris_state_ref null_fb;
820bf215546Sopenharmony_ci
821bf215546Sopenharmony_ci      struct u_upload_mgr *surface_uploader;
822bf215546Sopenharmony_ci      struct u_upload_mgr *bindless_uploader;
823bf215546Sopenharmony_ci      struct u_upload_mgr *dynamic_uploader;
824bf215546Sopenharmony_ci
825bf215546Sopenharmony_ci      struct iris_binder binder;
826bf215546Sopenharmony_ci
827bf215546Sopenharmony_ci      /** The high 16-bits of the last VBO/index buffer addresses */
828bf215546Sopenharmony_ci      uint16_t last_vbo_high_bits[33];
829bf215546Sopenharmony_ci      uint16_t last_index_bo_high_bits;
830bf215546Sopenharmony_ci
831bf215546Sopenharmony_ci      /**
832bf215546Sopenharmony_ci       * Resources containing streamed state which our render context
833bf215546Sopenharmony_ci       * currently points to.  Used to re-add these to the validation
834bf215546Sopenharmony_ci       * list when we start a new batch and haven't resubmitted commands.
835bf215546Sopenharmony_ci       */
836bf215546Sopenharmony_ci      struct {
837bf215546Sopenharmony_ci         struct pipe_resource *cc_vp;
838bf215546Sopenharmony_ci         struct pipe_resource *sf_cl_vp;
839bf215546Sopenharmony_ci         struct pipe_resource *color_calc;
840bf215546Sopenharmony_ci         struct pipe_resource *scissor;
841bf215546Sopenharmony_ci         struct pipe_resource *blend;
842bf215546Sopenharmony_ci         struct pipe_resource *index_buffer;
843bf215546Sopenharmony_ci         struct pipe_resource *cs_thread_ids;
844bf215546Sopenharmony_ci         struct pipe_resource *cs_desc;
845bf215546Sopenharmony_ci      } last_res;
846bf215546Sopenharmony_ci
847bf215546Sopenharmony_ci      /** Records the size of variable-length state for INTEL_DEBUG=bat */
848bf215546Sopenharmony_ci      struct hash_table_u64 *sizes;
849bf215546Sopenharmony_ci
850bf215546Sopenharmony_ci      /** Last rendering scale argument provided to genX(emit_hashing_mode). */
851bf215546Sopenharmony_ci      unsigned current_hash_scale;
852bf215546Sopenharmony_ci
853bf215546Sopenharmony_ci      /** Resource holding the pixel pipe hashing tables. */
854bf215546Sopenharmony_ci      struct pipe_resource *pixel_hashing_tables;
855bf215546Sopenharmony_ci   } state;
856bf215546Sopenharmony_ci};
857bf215546Sopenharmony_ci
858bf215546Sopenharmony_ci#define perf_debug(dbg, ...) do {                      \
859bf215546Sopenharmony_ci   if (INTEL_DEBUG(DEBUG_PERF))                        \
860bf215546Sopenharmony_ci      dbg_printf(__VA_ARGS__);                         \
861bf215546Sopenharmony_ci   if (unlikely(dbg))                                  \
862bf215546Sopenharmony_ci      util_debug_message(dbg, PERF_INFO, __VA_ARGS__); \
863bf215546Sopenharmony_ci} while(0)
864bf215546Sopenharmony_ci
865bf215546Sopenharmony_cistruct pipe_context *
866bf215546Sopenharmony_ciiris_create_context(struct pipe_screen *screen, void *priv, unsigned flags);
867bf215546Sopenharmony_civoid iris_destroy_context(struct pipe_context *ctx);
868bf215546Sopenharmony_ci
869bf215546Sopenharmony_civoid iris_lost_context_state(struct iris_batch *batch);
870bf215546Sopenharmony_ci
871bf215546Sopenharmony_civoid iris_mark_dirty_dmabuf(struct iris_context *ice,
872bf215546Sopenharmony_ci                            struct pipe_resource *res);
873bf215546Sopenharmony_civoid iris_flush_dirty_dmabufs(struct iris_context *ice);
874bf215546Sopenharmony_ci
875bf215546Sopenharmony_civoid iris_init_blit_functions(struct pipe_context *ctx);
876bf215546Sopenharmony_civoid iris_init_clear_functions(struct pipe_context *ctx);
877bf215546Sopenharmony_civoid iris_init_program_functions(struct pipe_context *ctx);
878bf215546Sopenharmony_civoid iris_init_screen_program_functions(struct pipe_screen *pscreen);
879bf215546Sopenharmony_civoid iris_init_resource_functions(struct pipe_context *ctx);
880bf215546Sopenharmony_civoid iris_init_perfquery_functions(struct pipe_context *ctx);
881bf215546Sopenharmony_civoid iris_update_compiled_shaders(struct iris_context *ice);
882bf215546Sopenharmony_civoid iris_update_compiled_compute_shader(struct iris_context *ice);
883bf215546Sopenharmony_civoid iris_fill_cs_push_const_buffer(struct brw_cs_prog_data *cs_prog_data,
884bf215546Sopenharmony_ci                                    unsigned threads,
885bf215546Sopenharmony_ci                                    uint32_t *dst);
886bf215546Sopenharmony_ci
887bf215546Sopenharmony_ci
888bf215546Sopenharmony_ci/* iris_blit.c */
889bf215546Sopenharmony_civoid iris_blorp_surf_for_resource(struct isl_device *isl_dev,
890bf215546Sopenharmony_ci                                  struct blorp_surf *surf,
891bf215546Sopenharmony_ci                                  struct pipe_resource *p_res,
892bf215546Sopenharmony_ci                                  enum isl_aux_usage aux_usage,
893bf215546Sopenharmony_ci                                  unsigned level,
894bf215546Sopenharmony_ci                                  bool is_render_target);
895bf215546Sopenharmony_civoid iris_copy_region(struct blorp_context *blorp,
896bf215546Sopenharmony_ci                      struct iris_batch *batch,
897bf215546Sopenharmony_ci                      struct pipe_resource *dst,
898bf215546Sopenharmony_ci                      unsigned dst_level,
899bf215546Sopenharmony_ci                      unsigned dstx, unsigned dsty, unsigned dstz,
900bf215546Sopenharmony_ci                      struct pipe_resource *src,
901bf215546Sopenharmony_ci                      unsigned src_level,
902bf215546Sopenharmony_ci                      const struct pipe_box *src_box);
903bf215546Sopenharmony_ci
904bf215546Sopenharmony_cistatic inline enum blorp_batch_flags
905bf215546Sopenharmony_ciiris_blorp_flags_for_batch(struct iris_batch *batch)
906bf215546Sopenharmony_ci{
907bf215546Sopenharmony_ci   if (batch->name == IRIS_BATCH_COMPUTE)
908bf215546Sopenharmony_ci      return BLORP_BATCH_USE_COMPUTE;
909bf215546Sopenharmony_ci
910bf215546Sopenharmony_ci   if (batch->name == IRIS_BATCH_BLITTER)
911bf215546Sopenharmony_ci      return BLORP_BATCH_USE_BLITTER;
912bf215546Sopenharmony_ci
913bf215546Sopenharmony_ci   return 0;
914bf215546Sopenharmony_ci}
915bf215546Sopenharmony_ci
916bf215546Sopenharmony_ci/* iris_draw.c */
917bf215546Sopenharmony_ci
918bf215546Sopenharmony_civoid iris_draw_vbo(struct pipe_context *ctx, const struct pipe_draw_info *info,
919bf215546Sopenharmony_ci                   unsigned drawid_offset,
920bf215546Sopenharmony_ci                   const struct pipe_draw_indirect_info *indirect,
921bf215546Sopenharmony_ci                   const struct pipe_draw_start_count_bias *draws,
922bf215546Sopenharmony_ci                   unsigned num_draws);
923bf215546Sopenharmony_civoid iris_launch_grid(struct pipe_context *, const struct pipe_grid_info *);
924bf215546Sopenharmony_ci
925bf215546Sopenharmony_ci/* iris_pipe_control.c */
926bf215546Sopenharmony_ci
927bf215546Sopenharmony_civoid iris_emit_pipe_control_flush(struct iris_batch *batch,
928bf215546Sopenharmony_ci                                  const char *reason, uint32_t flags);
929bf215546Sopenharmony_civoid iris_emit_pipe_control_write(struct iris_batch *batch,
930bf215546Sopenharmony_ci                                  const char *reason, uint32_t flags,
931bf215546Sopenharmony_ci                                  struct iris_bo *bo, uint32_t offset,
932bf215546Sopenharmony_ci                                  uint64_t imm);
933bf215546Sopenharmony_civoid iris_emit_end_of_pipe_sync(struct iris_batch *batch,
934bf215546Sopenharmony_ci                                const char *reason, uint32_t flags);
935bf215546Sopenharmony_civoid iris_emit_buffer_barrier_for(struct iris_batch *batch,
936bf215546Sopenharmony_ci                                  struct iris_bo *bo,
937bf215546Sopenharmony_ci                                  enum iris_domain access);
938bf215546Sopenharmony_civoid iris_flush_all_caches(struct iris_batch *batch);
939bf215546Sopenharmony_ci
940bf215546Sopenharmony_ci#define iris_handle_always_flush_cache(batch) \
941bf215546Sopenharmony_ci   if (unlikely(batch->screen->driconf.always_flush_cache)) \
942bf215546Sopenharmony_ci      iris_flush_all_caches(batch);
943bf215546Sopenharmony_ci
944bf215546Sopenharmony_civoid iris_init_flush_functions(struct pipe_context *ctx);
945bf215546Sopenharmony_ci
946bf215546Sopenharmony_ci/* iris_program.c */
947bf215546Sopenharmony_civoid iris_upload_ubo_ssbo_surf_state(struct iris_context *ice,
948bf215546Sopenharmony_ci                                     struct pipe_shader_buffer *buf,
949bf215546Sopenharmony_ci                                     struct iris_state_ref *surf_state,
950bf215546Sopenharmony_ci                                     isl_surf_usage_flags_t usage);
951bf215546Sopenharmony_ciconst struct shader_info *iris_get_shader_info(const struct iris_context *ice,
952bf215546Sopenharmony_ci                                               gl_shader_stage stage);
953bf215546Sopenharmony_cistruct iris_bo *iris_get_scratch_space(struct iris_context *ice,
954bf215546Sopenharmony_ci                                       unsigned per_thread_scratch,
955bf215546Sopenharmony_ci                                       gl_shader_stage stage);
956bf215546Sopenharmony_ciconst struct iris_state_ref *iris_get_scratch_surf(struct iris_context *ice,
957bf215546Sopenharmony_ci                                                   unsigned per_thread_scratch);
958bf215546Sopenharmony_ciuint32_t iris_group_index_to_bti(const struct iris_binding_table *bt,
959bf215546Sopenharmony_ci                                 enum iris_surface_group group,
960bf215546Sopenharmony_ci                                 uint32_t index);
961bf215546Sopenharmony_ciuint32_t iris_bti_to_group_index(const struct iris_binding_table *bt,
962bf215546Sopenharmony_ci                                 enum iris_surface_group group,
963bf215546Sopenharmony_ci                                 uint32_t bti);
964bf215546Sopenharmony_ci
965bf215546Sopenharmony_ci/* iris_disk_cache.c */
966bf215546Sopenharmony_ci
967bf215546Sopenharmony_civoid iris_disk_cache_store(struct disk_cache *cache,
968bf215546Sopenharmony_ci                           const struct iris_uncompiled_shader *ish,
969bf215546Sopenharmony_ci                           const struct iris_compiled_shader *shader,
970bf215546Sopenharmony_ci                           const void *prog_key,
971bf215546Sopenharmony_ci                           uint32_t prog_key_size);
972bf215546Sopenharmony_cibool
973bf215546Sopenharmony_ciiris_disk_cache_retrieve(struct iris_screen *screen,
974bf215546Sopenharmony_ci                         struct u_upload_mgr *uploader,
975bf215546Sopenharmony_ci                         struct iris_uncompiled_shader *ish,
976bf215546Sopenharmony_ci                         struct iris_compiled_shader *shader,
977bf215546Sopenharmony_ci                         const void *prog_key,
978bf215546Sopenharmony_ci                         uint32_t prog_key_size);
979bf215546Sopenharmony_ci
980bf215546Sopenharmony_ci/* iris_program_cache.c */
981bf215546Sopenharmony_ci
982bf215546Sopenharmony_civoid iris_init_program_cache(struct iris_context *ice);
983bf215546Sopenharmony_civoid iris_destroy_program_cache(struct iris_context *ice);
984bf215546Sopenharmony_cistruct iris_compiled_shader *iris_find_cached_shader(struct iris_context *ice,
985bf215546Sopenharmony_ci                                                     enum iris_program_cache_id,
986bf215546Sopenharmony_ci                                                     uint32_t key_size,
987bf215546Sopenharmony_ci                                                     const void *key);
988bf215546Sopenharmony_ci
989bf215546Sopenharmony_cistruct iris_compiled_shader *iris_create_shader_variant(const struct iris_screen *,
990bf215546Sopenharmony_ci                                                        void *mem_ctx,
991bf215546Sopenharmony_ci                                                        enum iris_program_cache_id cache_id,
992bf215546Sopenharmony_ci                                                        uint32_t key_size,
993bf215546Sopenharmony_ci                                                        const void *key);
994bf215546Sopenharmony_ci
995bf215546Sopenharmony_civoid iris_finalize_program(struct iris_compiled_shader *shader,
996bf215546Sopenharmony_ci                           struct brw_stage_prog_data *prog_data,
997bf215546Sopenharmony_ci                           uint32_t *streamout,
998bf215546Sopenharmony_ci                           enum brw_param_builtin *system_values,
999bf215546Sopenharmony_ci                           unsigned num_system_values,
1000bf215546Sopenharmony_ci                           unsigned kernel_input_size,
1001bf215546Sopenharmony_ci                           unsigned num_cbufs,
1002bf215546Sopenharmony_ci                           const struct iris_binding_table *bt);
1003bf215546Sopenharmony_ci
1004bf215546Sopenharmony_civoid iris_upload_shader(struct iris_screen *screen,
1005bf215546Sopenharmony_ci                        struct iris_uncompiled_shader *,
1006bf215546Sopenharmony_ci                        struct iris_compiled_shader *,
1007bf215546Sopenharmony_ci                        struct hash_table *driver_ht,
1008bf215546Sopenharmony_ci                        struct u_upload_mgr *uploader,
1009bf215546Sopenharmony_ci                        enum iris_program_cache_id,
1010bf215546Sopenharmony_ci                        uint32_t key_size,
1011bf215546Sopenharmony_ci                        const void *key,
1012bf215546Sopenharmony_ci                        const void *assembly);
1013bf215546Sopenharmony_civoid iris_delete_shader_variant(struct iris_compiled_shader *shader);
1014bf215546Sopenharmony_ci
1015bf215546Sopenharmony_civoid iris_destroy_shader_state(struct pipe_context *ctx, void *state);
1016bf215546Sopenharmony_ci
1017bf215546Sopenharmony_cistatic inline void
1018bf215546Sopenharmony_ciiris_uncompiled_shader_reference(struct pipe_context *ctx,
1019bf215546Sopenharmony_ci                                 struct iris_uncompiled_shader **dst,
1020bf215546Sopenharmony_ci                                 struct iris_uncompiled_shader *src)
1021bf215546Sopenharmony_ci{
1022bf215546Sopenharmony_ci   if (*dst == src)
1023bf215546Sopenharmony_ci      return;
1024bf215546Sopenharmony_ci
1025bf215546Sopenharmony_ci   struct iris_uncompiled_shader *old_dst = *dst;
1026bf215546Sopenharmony_ci
1027bf215546Sopenharmony_ci   if (pipe_reference(old_dst != NULL ? &old_dst->ref : NULL,
1028bf215546Sopenharmony_ci                      src != NULL ? &src->ref : NULL)) {
1029bf215546Sopenharmony_ci      iris_destroy_shader_state(ctx, *dst);
1030bf215546Sopenharmony_ci   }
1031bf215546Sopenharmony_ci
1032bf215546Sopenharmony_ci   *dst = src;
1033bf215546Sopenharmony_ci}
1034bf215546Sopenharmony_ci
1035bf215546Sopenharmony_cistatic inline void
1036bf215546Sopenharmony_ciiris_shader_variant_reference(struct iris_compiled_shader **dst,
1037bf215546Sopenharmony_ci                              struct iris_compiled_shader *src)
1038bf215546Sopenharmony_ci{
1039bf215546Sopenharmony_ci   struct iris_compiled_shader *old_dst = *dst;
1040bf215546Sopenharmony_ci
1041bf215546Sopenharmony_ci   if (pipe_reference(old_dst ? &old_dst->ref: NULL, src ? &src->ref : NULL))
1042bf215546Sopenharmony_ci      iris_delete_shader_variant(old_dst);
1043bf215546Sopenharmony_ci
1044bf215546Sopenharmony_ci   *dst = src;
1045bf215546Sopenharmony_ci}
1046bf215546Sopenharmony_ci
1047bf215546Sopenharmony_cibool iris_blorp_lookup_shader(struct blorp_batch *blorp_batch,
1048bf215546Sopenharmony_ci                              const void *key,
1049bf215546Sopenharmony_ci                              uint32_t key_size,
1050bf215546Sopenharmony_ci                              uint32_t *kernel_out,
1051bf215546Sopenharmony_ci                              void *prog_data_out);
1052bf215546Sopenharmony_cibool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, uint32_t stage,
1053bf215546Sopenharmony_ci                              const void *key, uint32_t key_size,
1054bf215546Sopenharmony_ci                              const void *kernel, uint32_t kernel_size,
1055bf215546Sopenharmony_ci                              const struct brw_stage_prog_data *prog_data,
1056bf215546Sopenharmony_ci                              uint32_t prog_data_size,
1057bf215546Sopenharmony_ci                              uint32_t *kernel_out,
1058bf215546Sopenharmony_ci                              void *prog_data_out);
1059bf215546Sopenharmony_ci
1060bf215546Sopenharmony_ci/* iris_resolve.c */
1061bf215546Sopenharmony_ci
1062bf215546Sopenharmony_civoid iris_predraw_resolve_inputs(struct iris_context *ice,
1063bf215546Sopenharmony_ci                                 struct iris_batch *batch,
1064bf215546Sopenharmony_ci                                 bool *draw_aux_buffer_disabled,
1065bf215546Sopenharmony_ci                                 gl_shader_stage stage,
1066bf215546Sopenharmony_ci                                 bool consider_framebuffer);
1067bf215546Sopenharmony_civoid iris_predraw_resolve_framebuffer(struct iris_context *ice,
1068bf215546Sopenharmony_ci                                      struct iris_batch *batch,
1069bf215546Sopenharmony_ci                                      bool *draw_aux_buffer_disabled);
1070bf215546Sopenharmony_civoid iris_predraw_flush_buffers(struct iris_context *ice,
1071bf215546Sopenharmony_ci                                struct iris_batch *batch,
1072bf215546Sopenharmony_ci                                gl_shader_stage stage);
1073bf215546Sopenharmony_civoid iris_postdraw_update_resolve_tracking(struct iris_context *ice,
1074bf215546Sopenharmony_ci                                           struct iris_batch *batch);
1075bf215546Sopenharmony_civoid iris_cache_flush_for_render(struct iris_batch *batch,
1076bf215546Sopenharmony_ci                                 struct iris_bo *bo,
1077bf215546Sopenharmony_ci                                 enum isl_aux_usage aux_usage);
1078bf215546Sopenharmony_ciint iris_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
1079bf215546Sopenharmony_ci                               struct pipe_driver_query_info *info);
1080bf215546Sopenharmony_ciint iris_get_driver_query_group_info(struct pipe_screen *pscreen,
1081bf215546Sopenharmony_ci                                     unsigned index,
1082bf215546Sopenharmony_ci                                     struct pipe_driver_query_group_info *info);
1083bf215546Sopenharmony_ci
1084bf215546Sopenharmony_ci/* iris_state.c */
1085bf215546Sopenharmony_civoid gfx9_toggle_preemption(struct iris_context *ice,
1086bf215546Sopenharmony_ci                            struct iris_batch *batch,
1087bf215546Sopenharmony_ci                            const struct pipe_draw_info *draw);
1088bf215546Sopenharmony_ci
1089bf215546Sopenharmony_ci
1090bf215546Sopenharmony_ci
1091bf215546Sopenharmony_ci#ifdef genX
1092bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1093bf215546Sopenharmony_ci#else
1094bf215546Sopenharmony_ci#  define genX(x) gfx4_##x
1095bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1096bf215546Sopenharmony_ci#  undef genX
1097bf215546Sopenharmony_ci#  define genX(x) gfx5_##x
1098bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1099bf215546Sopenharmony_ci#  undef genX
1100bf215546Sopenharmony_ci#  define genX(x) gfx6_##x
1101bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1102bf215546Sopenharmony_ci#  undef genX
1103bf215546Sopenharmony_ci#  define genX(x) gfx7_##x
1104bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1105bf215546Sopenharmony_ci#  undef genX
1106bf215546Sopenharmony_ci#  define genX(x) gfx75_##x
1107bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1108bf215546Sopenharmony_ci#  undef genX
1109bf215546Sopenharmony_ci#  define genX(x) gfx8_##x
1110bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1111bf215546Sopenharmony_ci#  undef genX
1112bf215546Sopenharmony_ci#  define genX(x) gfx9_##x
1113bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1114bf215546Sopenharmony_ci#  undef genX
1115bf215546Sopenharmony_ci#  define genX(x) gfx11_##x
1116bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1117bf215546Sopenharmony_ci#  undef genX
1118bf215546Sopenharmony_ci#  define genX(x) gfx12_##x
1119bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1120bf215546Sopenharmony_ci#  undef genX
1121bf215546Sopenharmony_ci#  define genX(x) gfx125_##x
1122bf215546Sopenharmony_ci#  include "iris_genx_protos.h"
1123bf215546Sopenharmony_ci#  undef genX
1124bf215546Sopenharmony_ci#endif
1125bf215546Sopenharmony_ci
1126bf215546Sopenharmony_ci#endif
1127