radeonsi: provide VS_STATE input to all VS variants
[mesa.git] / src / gallium / drivers / radeonsi / si_shader.h
1 /*
2 * Copyright 2012 Advanced Micro Devices, Inc.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 * Authors:
24 * Tom Stellard <thomas.stellard@amd.com>
25 * Michel Dänzer <michel.daenzer@amd.com>
26 * Christian König <christian.koenig@amd.com>
27 */
28
29 /* How linking shader inputs and outputs between vertex, tessellation, and
30 * geometry shaders works.
31 *
32 * Inputs and outputs between shaders are stored in a buffer. This buffer
33 * lives in LDS (typical case for tessellation), but it can also live
34 * in memory (ESGS). Each input or output has a fixed location within a vertex.
35 * The highest used input or output determines the stride between vertices.
36 *
37 * Since GS and tessellation are only possible in the OpenGL core profile,
38 * only these semantics are valid for per-vertex data:
39 *
40 * Name Location
41 *
42 * POSITION 0
43 * PSIZE 1
44 * CLIPDIST0..1 2..3
45 * CULLDIST0..1 (not implemented)
46 * GENERIC0..31 4..35
47 *
48 * For example, a shader only writing GENERIC0 has the output stride of 5.
49 *
50 * Only these semantics are valid for per-patch data:
51 *
52 * Name Location
53 *
54 * TESSOUTER 0
55 * TESSINNER 1
56 * PATCH0..29 2..31
57 *
58 * That's how independent shaders agree on input and output locations.
59 * The si_shader_io_get_unique_index function assigns the locations.
60 *
61 * For tessellation, other required information for calculating the input and
62 * output addresses like the vertex stride, the patch stride, and the offsets
63 * where per-vertex and per-patch data start, is passed to the shader via
64 * user data SGPRs. The offsets and strides are calculated at draw time and
65 * aren't available at compile time.
66 */
67
68 #ifndef SI_SHADER_H
69 #define SI_SHADER_H
70
71 #include <llvm-c/Core.h> /* LLVMModuleRef */
72 #include <llvm-c/TargetMachine.h>
73 #include "tgsi/tgsi_scan.h"
74 #include "util/u_queue.h"
75 #include "si_state.h"
76
77 struct ac_shader_binary;
78
79 #define SI_MAX_VS_OUTPUTS 40
80
81 /* SGPR user data indices */
82 enum {
83 SI_SGPR_RW_BUFFERS, /* rings (& stream-out, VS only) */
84 SI_SGPR_RW_BUFFERS_HI,
85 SI_SGPR_CONST_BUFFERS,
86 SI_SGPR_CONST_BUFFERS_HI,
87 SI_SGPR_SAMPLERS, /* images & sampler states interleaved */
88 SI_SGPR_SAMPLERS_HI,
89 SI_SGPR_IMAGES,
90 SI_SGPR_IMAGES_HI,
91 SI_SGPR_SHADER_BUFFERS,
92 SI_SGPR_SHADER_BUFFERS_HI,
93 SI_NUM_RESOURCE_SGPRS,
94
95 /* all VS variants */
96 SI_SGPR_VERTEX_BUFFERS = SI_NUM_RESOURCE_SGPRS,
97 SI_SGPR_VERTEX_BUFFERS_HI,
98 SI_SGPR_BASE_VERTEX,
99 SI_SGPR_START_INSTANCE,
100 SI_SGPR_DRAWID,
101 SI_SGPR_VS_STATE_BITS,
102 SI_VS_NUM_USER_SGPR,
103
104 /* both TCS and TES */
105 SI_SGPR_TCS_OFFCHIP_LAYOUT = SI_NUM_RESOURCE_SGPRS,
106 SI_TES_NUM_USER_SGPR,
107
108 /* TCS only */
109 SI_SGPR_TCS_OUT_OFFSETS = SI_TES_NUM_USER_SGPR,
110 SI_SGPR_TCS_OUT_LAYOUT,
111 SI_SGPR_TCS_IN_LAYOUT,
112 SI_TCS_NUM_USER_SGPR,
113
114 /* GS limits */
115 SI_GS_NUM_USER_SGPR = SI_NUM_RESOURCE_SGPRS,
116 SI_GSCOPY_NUM_USER_SGPR = SI_SGPR_RW_BUFFERS_HI + 1,
117
118 /* PS only */
119 SI_SGPR_ALPHA_REF = SI_NUM_RESOURCE_SGPRS,
120 SI_PS_NUM_USER_SGPR,
121
122 /* CS only */
123 SI_SGPR_GRID_SIZE = SI_NUM_RESOURCE_SGPRS,
124 SI_SGPR_BLOCK_SIZE = SI_SGPR_GRID_SIZE + 3,
125 SI_CS_NUM_USER_SGPR = SI_SGPR_BLOCK_SIZE + 3
126 };
127
128 /* LLVM function parameter indices */
129 enum {
130 SI_PARAM_RW_BUFFERS,
131 SI_PARAM_CONST_BUFFERS,
132 SI_PARAM_SAMPLERS,
133 SI_PARAM_IMAGES,
134 SI_PARAM_SHADER_BUFFERS,
135 SI_NUM_RESOURCE_PARAMS,
136
137 /* VS only parameters */
138 SI_PARAM_VERTEX_BUFFERS = SI_NUM_RESOURCE_PARAMS,
139 SI_PARAM_BASE_VERTEX,
140 SI_PARAM_START_INSTANCE,
141 SI_PARAM_DRAWID,
142 SI_PARAM_VS_STATE_BITS,
143
144 /* Layout of TCS outputs in the offchip buffer
145 * [0:8] = the number of patches per threadgroup.
146 * [9:15] = the number of output vertices per patch.
147 * [16:31] = the offset of per patch attributes in the buffer in bytes.
148 */
149 SI_PARAM_TCS_OFFCHIP_LAYOUT = SI_NUM_RESOURCE_PARAMS, /* for TCS & TES */
150
151 /* TCS only parameters. */
152
153 /* Offsets where TCS outputs and TCS patch outputs live in LDS:
154 * [0:15] = TCS output patch0 offset / 16, max = NUM_PATCHES * 32 * 32
155 * [16:31] = TCS output patch0 offset for per-patch / 16, max = NUM_PATCHES*32*32* + 32*32
156 */
157 SI_PARAM_TCS_OUT_OFFSETS,
158
159 /* Layout of TCS outputs / TES inputs:
160 * [0:12] = stride between output patches in dwords, num_outputs * num_vertices * 4, max = 32*32*4
161 * [13:20] = stride between output vertices in dwords = num_inputs * 4, max = 32*4
162 * [26:31] = gl_PatchVerticesIn, max = 32
163 */
164 SI_PARAM_TCS_OUT_LAYOUT,
165
166 /* Layout of LS outputs / TCS inputs
167 * [8:20] = stride between patches in dwords = num_inputs * num_vertices * 4, max = 32*32*4
168 * [24:31] = stride between vertices in dwords = num_inputs * 4, max = 32*4
169 * (same layout as SI_PARAM_VS_STATE_BITS)
170 */
171 SI_PARAM_TCS_IN_LAYOUT,
172
173 SI_PARAM_TCS_OC_LDS,
174 SI_PARAM_TESS_FACTOR_OFFSET,
175 SI_PARAM_PATCH_ID,
176 SI_PARAM_REL_IDS,
177
178 /* GS only parameters */
179 SI_PARAM_GS2VS_OFFSET = SI_NUM_RESOURCE_PARAMS,
180 SI_PARAM_GS_WAVE_ID,
181 SI_PARAM_VTX0_OFFSET,
182 SI_PARAM_VTX1_OFFSET,
183 SI_PARAM_PRIMITIVE_ID,
184 SI_PARAM_VTX2_OFFSET,
185 SI_PARAM_VTX3_OFFSET,
186 SI_PARAM_VTX4_OFFSET,
187 SI_PARAM_VTX5_OFFSET,
188 SI_PARAM_GS_INSTANCE_ID,
189
190 /* PS only parameters */
191 SI_PARAM_ALPHA_REF = SI_NUM_RESOURCE_PARAMS,
192 SI_PARAM_PRIM_MASK,
193 SI_PARAM_PERSP_SAMPLE,
194 SI_PARAM_PERSP_CENTER,
195 SI_PARAM_PERSP_CENTROID,
196 SI_PARAM_PERSP_PULL_MODEL,
197 SI_PARAM_LINEAR_SAMPLE,
198 SI_PARAM_LINEAR_CENTER,
199 SI_PARAM_LINEAR_CENTROID,
200 SI_PARAM_LINE_STIPPLE_TEX,
201 SI_PARAM_POS_X_FLOAT,
202 SI_PARAM_POS_Y_FLOAT,
203 SI_PARAM_POS_Z_FLOAT,
204 SI_PARAM_POS_W_FLOAT,
205 SI_PARAM_FRONT_FACE,
206 SI_PARAM_ANCILLARY,
207 SI_PARAM_SAMPLE_COVERAGE,
208 SI_PARAM_POS_FIXED_PT,
209
210 /* CS only parameters */
211 SI_PARAM_GRID_SIZE = SI_NUM_RESOURCE_PARAMS,
212 SI_PARAM_BLOCK_SIZE,
213 SI_PARAM_BLOCK_ID,
214 SI_PARAM_THREAD_ID,
215
216 SI_NUM_PARAMS = SI_PARAM_POS_FIXED_PT + 9, /* +8 for COLOR[0..1] */
217 };
218
219 /* Fields of driver-defined VS state SGPR. */
220 /* Clamp vertex color output (only used in VS as VS). */
221 #define S_VS_STATE_CLAMP_VERTEX_COLOR(x) (((unsigned)(x) & 0x1) << 0)
222 #define C_VS_STATE_CLAMP_VERTEX_COLOR 0xFFFFFFFE
223 #define S_VS_STATE_LS_OUT_PATCH_SIZE(x) (((unsigned)(x) & 0x1FFF) << 8)
224 #define C_VS_STATE_LS_OUT_PATCH_SIZE 0xFFE000FF
225 #define S_VS_STATE_LS_OUT_VERTEX_SIZE(x) (((unsigned)(x) & 0xFF) << 24)
226 #define C_VS_STATE_LS_OUT_VERTEX_SIZE 0x00FFFFFF
227
228 /* SI-specific system values. */
229 enum {
230 TGSI_SEMANTIC_DEFAULT_TESSOUTER_SI = TGSI_SEMANTIC_COUNT,
231 TGSI_SEMANTIC_DEFAULT_TESSINNER_SI,
232 };
233
234 /* For VS shader key fix_fetch. */
235 enum {
236 SI_FIX_FETCH_NONE = 0,
237 SI_FIX_FETCH_A2_SNORM,
238 SI_FIX_FETCH_A2_SSCALED,
239 SI_FIX_FETCH_A2_SINT,
240 SI_FIX_FETCH_RGBA_32_UNORM,
241 SI_FIX_FETCH_RGBX_32_UNORM,
242 SI_FIX_FETCH_RGBA_32_SNORM,
243 SI_FIX_FETCH_RGBX_32_SNORM,
244 SI_FIX_FETCH_RGBA_32_USCALED,
245 SI_FIX_FETCH_RGBA_32_SSCALED,
246 SI_FIX_FETCH_RGBA_32_FIXED,
247 SI_FIX_FETCH_RGBX_32_FIXED,
248 SI_FIX_FETCH_RG_64_FLOAT,
249 SI_FIX_FETCH_RGB_64_FLOAT,
250 SI_FIX_FETCH_RGBA_64_FLOAT,
251 SI_FIX_FETCH_RGB_8, /* A = 1.0 */
252 SI_FIX_FETCH_RGB_8_INT, /* A = 1 */
253 SI_FIX_FETCH_RGB_16,
254 SI_FIX_FETCH_RGB_16_INT,
255 };
256
257 struct si_shader;
258
259 /* State of the context creating the shader object. */
260 struct si_compiler_ctx_state {
261 /* Should only be used by si_init_shader_selector_async and
262 * si_build_shader_variant if thread_index == -1 (non-threaded). */
263 LLVMTargetMachineRef tm;
264
265 /* Used if thread_index == -1 or if debug.async is true. */
266 struct pipe_debug_callback debug;
267
268 /* Used for creating the log string for gallium/ddebug. */
269 bool is_debug_context;
270 };
271
272 /* A shader selector is a gallium CSO and contains shader variants and
273 * binaries for one TGSI program. This can be shared by multiple contexts.
274 */
275 struct si_shader_selector {
276 struct si_screen *screen;
277 struct util_queue_fence ready;
278 struct si_compiler_ctx_state compiler_ctx_state;
279
280 mtx_t mutex;
281 struct si_shader *first_variant; /* immutable after the first variant */
282 struct si_shader *last_variant; /* mutable */
283
284 /* The compiled TGSI shader expecting a prolog and/or epilog (not
285 * uploaded to a buffer).
286 */
287 struct si_shader *main_shader_part;
288 struct si_shader *main_shader_part_ls; /* as_ls is set in the key */
289 struct si_shader *main_shader_part_es; /* as_es is set in the key */
290
291 struct si_shader *gs_copy_shader;
292
293 struct tgsi_token *tokens;
294 struct pipe_stream_output_info so;
295 struct tgsi_shader_info info;
296
297 /* PIPE_SHADER_[VERTEX|FRAGMENT|...] */
298 unsigned type;
299
300 /* GS parameters. */
301 unsigned esgs_itemsize;
302 unsigned gs_input_verts_per_prim;
303 unsigned gs_output_prim;
304 unsigned gs_max_out_vertices;
305 unsigned gs_num_invocations;
306 unsigned max_gs_stream; /* count - 1 */
307 unsigned gsvs_vertex_size;
308 unsigned max_gsvs_emit_size;
309
310 /* PS parameters. */
311 unsigned color_attr_index[2];
312 unsigned db_shader_control;
313 /* Set 0xf or 0x0 (4 bits) per each written output.
314 * ANDed with spi_shader_col_format.
315 */
316 unsigned colors_written_4bit;
317
318 /* CS parameters */
319 unsigned local_size;
320
321 uint64_t outputs_written; /* "get_unique_index" bits */
322 uint32_t patch_outputs_written; /* "get_unique_index" bits */
323 uint32_t outputs_written2; /* "get_unique_index2" bits */
324
325 uint64_t inputs_read; /* "get_unique_index" bits */
326 uint32_t inputs_read2; /* "get_unique_index2" bits */
327 };
328
329 /* Valid shader configurations:
330 *
331 * API shaders VS | TCS | TES | GS |pass| PS
332 * are compiled as: | | | |thru|
333 * | | | | |
334 * Only VS & PS: VS | -- | -- | -- | -- | PS
335 * With GS: ES | -- | -- | GS | VS | PS
336 * With Tessel.: LS | HS | VS | -- | -- | PS
337 * With both: LS | HS | ES | GS | VS | PS
338 */
339
340 /* Common VS bits between the shader key and the prolog key. */
341 struct si_vs_prolog_bits {
342 unsigned instance_divisors[SI_MAX_ATTRIBS];
343 };
344
345 /* Common VS bits between the shader key and the epilog key. */
346 struct si_vs_epilog_bits {
347 unsigned export_prim_id:1; /* when PS needs it and GS is disabled */
348 };
349
350 /* Common TCS bits between the shader key and the epilog key. */
351 struct si_tcs_epilog_bits {
352 unsigned prim_mode:3;
353 unsigned tes_reads_tess_factors:1;
354 };
355
356 struct si_gs_prolog_bits {
357 unsigned tri_strip_adj_fix:1;
358 };
359
360 /* Common PS bits between the shader key and the prolog key. */
361 struct si_ps_prolog_bits {
362 unsigned color_two_side:1;
363 unsigned flatshade_colors:1;
364 unsigned poly_stipple:1;
365 unsigned force_persp_sample_interp:1;
366 unsigned force_linear_sample_interp:1;
367 unsigned force_persp_center_interp:1;
368 unsigned force_linear_center_interp:1;
369 unsigned bc_optimize_for_persp:1;
370 unsigned bc_optimize_for_linear:1;
371 };
372
373 /* Common PS bits between the shader key and the epilog key. */
374 struct si_ps_epilog_bits {
375 unsigned spi_shader_col_format;
376 unsigned color_is_int8:8;
377 unsigned color_is_int10:8;
378 unsigned last_cbuf:3;
379 unsigned alpha_func:3;
380 unsigned alpha_to_one:1;
381 unsigned poly_line_smoothing:1;
382 unsigned clamp_color:1;
383 };
384
385 union si_shader_part_key {
386 struct {
387 struct si_vs_prolog_bits states;
388 unsigned num_input_sgprs:5;
389 unsigned last_input:4;
390 } vs_prolog;
391 struct {
392 struct si_vs_epilog_bits states;
393 unsigned prim_id_param_offset:5;
394 } vs_epilog;
395 struct {
396 struct si_tcs_epilog_bits states;
397 } tcs_epilog;
398 struct {
399 struct si_gs_prolog_bits states;
400 } gs_prolog;
401 struct {
402 struct si_ps_prolog_bits states;
403 unsigned num_input_sgprs:5;
404 unsigned num_input_vgprs:5;
405 /* Color interpolation and two-side color selection. */
406 unsigned colors_read:8; /* color input components read */
407 unsigned num_interp_inputs:5; /* BCOLOR is at this location */
408 unsigned face_vgpr_index:5;
409 unsigned wqm:1;
410 char color_attr_index[2];
411 char color_interp_vgpr_index[2]; /* -1 == constant */
412 } ps_prolog;
413 struct {
414 struct si_ps_epilog_bits states;
415 unsigned colors_written:8;
416 unsigned writes_z:1;
417 unsigned writes_stencil:1;
418 unsigned writes_samplemask:1;
419 } ps_epilog;
420 };
421
422 struct si_shader_key {
423 /* Prolog and epilog flags. */
424 union {
425 struct {
426 struct si_vs_prolog_bits prolog;
427 struct si_vs_epilog_bits epilog;
428 } vs;
429 struct {
430 struct si_tcs_epilog_bits epilog;
431 } tcs; /* tessellation control shader */
432 struct {
433 struct si_vs_epilog_bits epilog; /* same as VS */
434 } tes; /* tessellation evaluation shader */
435 struct {
436 struct si_gs_prolog_bits prolog;
437 } gs;
438 struct {
439 struct si_ps_prolog_bits prolog;
440 struct si_ps_epilog_bits epilog;
441 } ps;
442 } part;
443
444 /* These two are initially set according to the NEXT_SHADER property,
445 * or guessed if the property doesn't seem correct.
446 */
447 unsigned as_es:1; /* export shader, which precedes GS */
448 unsigned as_ls:1; /* local shader, which precedes TCS */
449
450 /* Flags for monolithic compilation only. */
451 union {
452 struct {
453 /* One byte for every input: SI_FIX_FETCH_* enums. */
454 uint8_t fix_fetch[SI_MAX_ATTRIBS];
455 } vs;
456 struct {
457 uint64_t inputs_to_copy; /* for fixed-func TCS */
458 } tcs;
459 } mono;
460
461 /* Optimization flags for asynchronous compilation only. */
462 union {
463 struct {
464 uint64_t kill_outputs; /* "get_unique_index" bits */
465 uint32_t kill_outputs2; /* "get_unique_index2" bits */
466 unsigned clip_disable:1;
467 } hw_vs; /* HW VS (it can be VS, TES, GS) */
468 } opt;
469 };
470
471 struct si_shader_config {
472 unsigned num_sgprs;
473 unsigned num_vgprs;
474 unsigned spilled_sgprs;
475 unsigned spilled_vgprs;
476 unsigned private_mem_vgprs;
477 unsigned lds_size;
478 unsigned spi_ps_input_ena;
479 unsigned spi_ps_input_addr;
480 unsigned float_mode;
481 unsigned scratch_bytes_per_wave;
482 unsigned rsrc1;
483 unsigned rsrc2;
484 };
485
486 enum {
487 /* SPI_PS_INPUT_CNTL_i.OFFSET[0:4] */
488 EXP_PARAM_OFFSET_0 = 0,
489 EXP_PARAM_OFFSET_31 = 31,
490 /* SPI_PS_INPUT_CNTL_i.DEFAULT_VAL[0:1] */
491 EXP_PARAM_DEFAULT_VAL_0000 = 64,
492 EXP_PARAM_DEFAULT_VAL_0001,
493 EXP_PARAM_DEFAULT_VAL_1110,
494 EXP_PARAM_DEFAULT_VAL_1111,
495 EXP_PARAM_UNDEFINED = 255,
496 };
497
498 /* GCN-specific shader info. */
499 struct si_shader_info {
500 ubyte vs_output_param_offset[SI_MAX_VS_OUTPUTS];
501 ubyte num_input_sgprs;
502 ubyte num_input_vgprs;
503 char face_vgpr_index;
504 bool uses_instanceid;
505 ubyte nr_pos_exports;
506 ubyte nr_param_exports;
507 };
508
509 struct si_shader {
510 struct si_compiler_ctx_state compiler_ctx_state;
511
512 struct si_shader_selector *selector;
513 struct si_shader *next_variant;
514
515 struct si_shader_part *prolog;
516 struct si_shader_part *epilog;
517
518 struct si_pm4_state *pm4;
519 struct r600_resource *bo;
520 struct r600_resource *scratch_bo;
521 struct si_shader_key key;
522 struct util_queue_fence optimized_ready;
523 bool compilation_failed;
524 bool is_monolithic;
525 bool is_optimized;
526 bool is_binary_shared;
527 bool is_gs_copy_shader;
528
529 /* The following data is all that's needed for binary shaders. */
530 struct ac_shader_binary binary;
531 struct si_shader_config config;
532 struct si_shader_info info;
533
534 /* Shader key + LLVM IR + disassembly + statistics.
535 * Generated for debug contexts only.
536 */
537 char *shader_log;
538 size_t shader_log_size;
539 };
540
541 struct si_shader_part {
542 struct si_shader_part *next;
543 union si_shader_part_key key;
544 struct ac_shader_binary binary;
545 struct si_shader_config config;
546 };
547
548 /* si_shader.c */
549 struct si_shader *
550 si_generate_gs_copy_shader(struct si_screen *sscreen,
551 LLVMTargetMachineRef tm,
552 struct si_shader_selector *gs_selector,
553 struct pipe_debug_callback *debug);
554 int si_compile_tgsi_shader(struct si_screen *sscreen,
555 LLVMTargetMachineRef tm,
556 struct si_shader *shader,
557 bool is_monolithic,
558 struct pipe_debug_callback *debug);
559 int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
560 struct si_shader *shader,
561 struct pipe_debug_callback *debug);
562 int si_compile_llvm(struct si_screen *sscreen,
563 struct ac_shader_binary *binary,
564 struct si_shader_config *conf,
565 LLVMTargetMachineRef tm,
566 LLVMModuleRef mod,
567 struct pipe_debug_callback *debug,
568 unsigned processor,
569 const char *name);
570 void si_shader_destroy(struct si_shader *shader);
571 unsigned si_shader_io_get_unique_index(unsigned semantic_name, unsigned index);
572 unsigned si_shader_io_get_unique_index2(unsigned name, unsigned index);
573 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
574 void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
575 struct pipe_debug_callback *debug, unsigned processor,
576 FILE *f, bool check_debug_option);
577 void si_multiwave_lds_size_workaround(struct si_screen *sscreen,
578 unsigned *lds_size);
579 void si_shader_apply_scratch_relocs(struct si_context *sctx,
580 struct si_shader *shader,
581 struct si_shader_config *config,
582 uint64_t scratch_va);
583 void si_shader_binary_read_config(struct ac_shader_binary *binary,
584 struct si_shader_config *conf,
585 unsigned symbol_offset);
586 unsigned si_get_spi_shader_z_format(bool writes_z, bool writes_stencil,
587 bool writes_samplemask);
588 const char *si_get_shader_name(struct si_shader *shader, unsigned processor);
589
590 /* Inline helpers. */
591
592 /* Return the pointer to the main shader part's pointer. */
593 static inline struct si_shader **
594 si_get_main_shader_part(struct si_shader_selector *sel,
595 struct si_shader_key *key)
596 {
597 if (key->as_ls)
598 return &sel->main_shader_part_ls;
599 if (key->as_es)
600 return &sel->main_shader_part_es;
601 return &sel->main_shader_part;
602 }
603
604 #endif