1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009 VMware, Inc. All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 #ifndef SHADER_ENUMS_H
27 #define SHADER_ENUMS_H
28
29 #ifndef __OPENCL_VERSION__
30 #include <stdbool.h>
31 #include "util/macros.h"
32 #include "util/u_debug.h"
33 #else
34 #include "libcl/libcl.h"
35 #define debug_printf(x, ...)
36 #endif
37
38 /* Project-wide (GL and Vulkan) maximum. */
39 #define MAX_DRAW_BUFFERS 8
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45 /**
46 * Shader stages.
47 *
48 * The order must match how shaders are ordered in the pipeline.
49 * The GLSL linker assumes that if i<j, then the j-th shader is
50 * executed later than the i-th shader.
51 */
52 typedef enum pipe_shader_type
53 {
54 MESA_SHADER_NONE = -1,
55 MESA_SHADER_VERTEX = 0,
56 PIPE_SHADER_VERTEX = MESA_SHADER_VERTEX,
57 MESA_SHADER_TESS_CTRL = 1,
58 PIPE_SHADER_TESS_CTRL = MESA_SHADER_TESS_CTRL,
59 MESA_SHADER_TESS_EVAL = 2,
60 PIPE_SHADER_TESS_EVAL = MESA_SHADER_TESS_EVAL,
61 MESA_SHADER_GEOMETRY = 3,
62 PIPE_SHADER_GEOMETRY = MESA_SHADER_GEOMETRY,
63 MESA_SHADER_FRAGMENT = 4,
64 PIPE_SHADER_FRAGMENT = MESA_SHADER_FRAGMENT,
65 MESA_SHADER_COMPUTE = 5,
66 PIPE_SHADER_COMPUTE = MESA_SHADER_COMPUTE,
67
68 PIPE_SHADER_TYPES = (PIPE_SHADER_COMPUTE + 1),
69 /* Vulkan-only stages. */
70 MESA_SHADER_TASK = 6,
71 PIPE_SHADER_TASK = MESA_SHADER_TASK,
72 MESA_SHADER_MESH = 7,
73 PIPE_SHADER_MESH = MESA_SHADER_MESH,
74 PIPE_SHADER_MESH_TYPES = (PIPE_SHADER_MESH + 1),
75
76 MESA_SHADER_RAYGEN = 8,
77 MESA_SHADER_ANY_HIT = 9,
78 MESA_SHADER_CLOSEST_HIT = 10,
79 MESA_SHADER_MISS = 11,
80 MESA_SHADER_INTERSECTION = 12,
81 MESA_SHADER_CALLABLE = 13,
82
83 /* must be last so it doesn't affect the GL pipeline */
84 MESA_SHADER_KERNEL = 14,
85 } gl_shader_stage;
86
87 static inline bool
gl_shader_stage_is_compute(gl_shader_stage stage)88 gl_shader_stage_is_compute(gl_shader_stage stage)
89 {
90 return stage == MESA_SHADER_COMPUTE || stage == MESA_SHADER_KERNEL;
91 }
92
93 static inline bool
gl_shader_stage_is_mesh(gl_shader_stage stage)94 gl_shader_stage_is_mesh(gl_shader_stage stage)
95 {
96 return stage == MESA_SHADER_TASK ||
97 stage == MESA_SHADER_MESH;
98 }
99
100 static inline bool
gl_shader_stage_uses_workgroup(gl_shader_stage stage)101 gl_shader_stage_uses_workgroup(gl_shader_stage stage)
102 {
103 return stage == MESA_SHADER_COMPUTE ||
104 stage == MESA_SHADER_KERNEL ||
105 stage == MESA_SHADER_TASK ||
106 stage == MESA_SHADER_MESH;
107 }
108
109 static inline bool
gl_shader_stage_is_callable(gl_shader_stage stage)110 gl_shader_stage_is_callable(gl_shader_stage stage)
111 {
112 return stage == MESA_SHADER_ANY_HIT ||
113 stage == MESA_SHADER_CLOSEST_HIT ||
114 stage == MESA_SHADER_MISS ||
115 stage == MESA_SHADER_INTERSECTION ||
116 stage == MESA_SHADER_CALLABLE;
117 }
118
119 static inline bool
gl_shader_stage_is_rt(gl_shader_stage stage)120 gl_shader_stage_is_rt(gl_shader_stage stage)
121 {
122 return stage == MESA_SHADER_RAYGEN || gl_shader_stage_is_callable(stage);
123 }
124
125 static inline bool
gl_shader_stage_can_set_fragment_shading_rate(gl_shader_stage stage)126 gl_shader_stage_can_set_fragment_shading_rate(gl_shader_stage stage)
127 {
128 /* According to EXT_fragment_shading_rate :
129 *
130 * "This extension adds support for setting the fragment shading rate
131 * for a primitive in vertex, geometry, and mesh shading stages"
132 */
133 return stage == MESA_SHADER_VERTEX ||
134 stage == MESA_SHADER_GEOMETRY ||
135 stage == MESA_SHADER_MESH;
136 }
137
138 /**
139 * Number of STATE_* values we need to address any GL state.
140 * Used to dimension arrays.
141 */
142 #define STATE_LENGTH 4
143
144 typedef short gl_state_index16; /* see enum gl_state_index */
145
146 const char *gl_shader_stage_name(gl_shader_stage stage);
147
148 /**
149 * Translate a gl_shader_stage to a short shader stage name for debug
150 * printouts and error messages.
151 */
152 const char *_mesa_shader_stage_to_string(unsigned stage);
153
154 /**
155 * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS)
156 * for debug printouts and error messages.
157 */
158 const char *_mesa_shader_stage_to_abbrev(unsigned stage);
159
160 /**
161 * GL related stages (not including CL)
162 */
163 #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1)
164
165 /**
166 * Vulkan stages (not including CL)
167 */
168 #define MESA_VULKAN_SHADER_STAGES (MESA_SHADER_CALLABLE + 1)
169
170 /**
171 * All stages
172 */
173 #define MESA_ALL_SHADER_STAGES (MESA_SHADER_KERNEL + 1)
174
175
176 /**
177 * Indexes for vertex program attributes.
178 * GL_NV_vertex_program aliases generic attributes over the conventional
179 * attributes. In GL_ARB_vertex_program shader the aliasing is optional.
180 * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the
181 * generic attributes are distinct/separate).
182 */
183 typedef enum
184 {
185 VERT_ATTRIB_POS,
186 VERT_ATTRIB_NORMAL,
187 VERT_ATTRIB_COLOR0,
188 VERT_ATTRIB_COLOR1,
189 VERT_ATTRIB_FOG,
190 VERT_ATTRIB_COLOR_INDEX,
191 VERT_ATTRIB_TEX0,
192 VERT_ATTRIB_TEX1,
193 VERT_ATTRIB_TEX2,
194 VERT_ATTRIB_TEX3,
195 VERT_ATTRIB_TEX4,
196 VERT_ATTRIB_TEX5,
197 VERT_ATTRIB_TEX6,
198 VERT_ATTRIB_TEX7,
199 VERT_ATTRIB_POINT_SIZE,
200 VERT_ATTRIB_GENERIC0,
201 VERT_ATTRIB_GENERIC1,
202 VERT_ATTRIB_GENERIC2,
203 VERT_ATTRIB_GENERIC3,
204 VERT_ATTRIB_GENERIC4,
205 VERT_ATTRIB_GENERIC5,
206 VERT_ATTRIB_GENERIC6,
207 VERT_ATTRIB_GENERIC7,
208 VERT_ATTRIB_GENERIC8,
209 VERT_ATTRIB_GENERIC9,
210 VERT_ATTRIB_GENERIC10,
211 VERT_ATTRIB_GENERIC11,
212 VERT_ATTRIB_GENERIC12,
213 VERT_ATTRIB_GENERIC13,
214 VERT_ATTRIB_GENERIC14,
215 VERT_ATTRIB_GENERIC15,
216 /* This must be last to keep VS inputs and vertex attributes in the same
217 * order in st/mesa, and st/mesa always adds edgeflags as the last input.
218 */
219 VERT_ATTRIB_EDGEFLAG,
220 VERT_ATTRIB_MAX
221 } gl_vert_attrib;
222
223 const char *gl_vert_attrib_name(gl_vert_attrib attrib);
224
225 /**
226 * Max number of texture coordinate units. This mainly just applies to
227 * the fixed-function vertex code. This will be difficult to raise above
228 * eight because of various vertex attribute bitvectors.
229 */
230 #define MAX_TEXTURE_COORD_UNITS 8
231 #define MAX_VERTEX_GENERIC_ATTRIBS 16
232
233 /**
234 * Symbolic constats to help iterating over
235 * specific blocks of vertex attributes.
236 *
237 * VERT_ATTRIB_TEX
238 * include the classic texture coordinate attributes.
239 * VERT_ATTRIB_GENERIC
240 * include the OpenGL 2.0+ GLSL generic shader attributes.
241 * These alias the generic GL_ARB_vertex_shader attributes.
242 * VERT_ATTRIB_MAT
243 * include the generic shader attributes used to alias
244 * varying material values for the TNL shader programs.
245 * They are located at the end of the generic attribute
246 * block not to overlap with the generic 0 attribute.
247 */
248 #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i))
249 #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS
250
251 #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i))
252 #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS
253
254 #define VERT_ATTRIB_MAT0 \
255 (VERT_ATTRIB_GENERIC_MAX - VERT_ATTRIB_MAT_MAX)
256 #define VERT_ATTRIB_MAT(i) \
257 VERT_ATTRIB_GENERIC((i) + VERT_ATTRIB_MAT0)
258 #define VERT_ATTRIB_MAT_MAX MAT_ATTRIB_MAX
259
260 /**
261 * Bitflags for vertex attributes.
262 * These are used in bitfields in many places.
263 */
264 /*@{*/
265 #define VERT_BIT_POS BITFIELD_BIT(VERT_ATTRIB_POS)
266 #define VERT_BIT_NORMAL BITFIELD_BIT(VERT_ATTRIB_NORMAL)
267 #define VERT_BIT_COLOR0 BITFIELD_BIT(VERT_ATTRIB_COLOR0)
268 #define VERT_BIT_COLOR1 BITFIELD_BIT(VERT_ATTRIB_COLOR1)
269 #define VERT_BIT_FOG BITFIELD_BIT(VERT_ATTRIB_FOG)
270 #define VERT_BIT_COLOR_INDEX BITFIELD_BIT(VERT_ATTRIB_COLOR_INDEX)
271 #define VERT_BIT_TEX0 BITFIELD_BIT(VERT_ATTRIB_TEX0)
272 #define VERT_BIT_TEX1 BITFIELD_BIT(VERT_ATTRIB_TEX1)
273 #define VERT_BIT_TEX2 BITFIELD_BIT(VERT_ATTRIB_TEX2)
274 #define VERT_BIT_TEX3 BITFIELD_BIT(VERT_ATTRIB_TEX3)
275 #define VERT_BIT_TEX4 BITFIELD_BIT(VERT_ATTRIB_TEX4)
276 #define VERT_BIT_TEX5 BITFIELD_BIT(VERT_ATTRIB_TEX5)
277 #define VERT_BIT_TEX6 BITFIELD_BIT(VERT_ATTRIB_TEX6)
278 #define VERT_BIT_TEX7 BITFIELD_BIT(VERT_ATTRIB_TEX7)
279 #define VERT_BIT_POINT_SIZE BITFIELD_BIT(VERT_ATTRIB_POINT_SIZE)
280 #define VERT_BIT_GENERIC0 BITFIELD_BIT(VERT_ATTRIB_GENERIC0)
281 #define VERT_BIT_EDGEFLAG BITFIELD_BIT(VERT_ATTRIB_EDGEFLAG)
282
283 #define VERT_BIT(i) BITFIELD_BIT(i)
284 #define VERT_BIT_ALL BITFIELD_RANGE(0, VERT_ATTRIB_MAX)
285
286 #define VERT_BIT_FF_ALL (BITFIELD_RANGE(0, VERT_ATTRIB_GENERIC0) | \
287 VERT_BIT_EDGEFLAG)
288 #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
289 #define VERT_BIT_TEX_ALL \
290 BITFIELD_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
291
292 #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
293 #define VERT_BIT_GENERIC_ALL \
294 BITFIELD_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
295
296 #define VERT_BIT_MAT(i) VERT_BIT(VERT_ATTRIB_MAT(i))
297 #define VERT_BIT_MAT_ALL \
298 BITFIELD_RANGE(VERT_ATTRIB_MAT(0), VERT_ATTRIB_MAT_MAX)
299
300 #define VERT_ATTRIB_SELECT_RESULT_OFFSET VERT_ATTRIB_GENERIC(3)
301 #define VERT_BIT_SELECT_RESULT_OFFSET VERT_BIT_GENERIC(3)
302 /*@}*/
303
304 #define MAX_VARYING 32 /**< number of float[4] vectors */
305
306 /**
307 * Indexes for vertex shader outputs, geometry shader inputs/outputs, and
308 * fragment shader inputs.
309 *
310 * Note that some of these values are not available to all pipeline stages.
311 *
312 * When this enum is updated, the following code must be updated too:
313 * - vertResults (in prog_print.c's arb_output_attrib_string())
314 * - fragAttribs (in prog_print.c's arb_input_attrib_string())
315 * - _mesa_varying_slot_in_fs()
316 * - gl_varying_slot_name_for_stage()
317 */
318 typedef enum
319 {
320 VARYING_SLOT_POS,
321 VARYING_SLOT_COL0, /* COL0 and COL1 must be contiguous */
322 VARYING_SLOT_COL1,
323 VARYING_SLOT_FOGC,
324 VARYING_SLOT_TEX0, /* TEX0-TEX7 must be contiguous */
325 VARYING_SLOT_TEX1,
326 VARYING_SLOT_TEX2,
327 VARYING_SLOT_TEX3,
328 VARYING_SLOT_TEX4,
329 VARYING_SLOT_TEX5,
330 VARYING_SLOT_TEX6,
331 VARYING_SLOT_TEX7,
332 VARYING_SLOT_PSIZ, /* Does not appear in FS */
333 VARYING_SLOT_BFC0, /* Does not appear in FS */
334 VARYING_SLOT_BFC1, /* Does not appear in FS */
335 VARYING_SLOT_EDGE, /* Does not appear in FS */
336 VARYING_SLOT_CLIP_VERTEX, /* Does not appear in FS */
337 VARYING_SLOT_CLIP_DIST0,
338 VARYING_SLOT_CLIP_DIST1,
339 VARYING_SLOT_CULL_DIST0,
340 VARYING_SLOT_CULL_DIST1,
341 VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */
342 VARYING_SLOT_LAYER, /* Appears as VS or GS output */
343 VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */
344 VARYING_SLOT_FACE, /* FS only */
345 VARYING_SLOT_PNTC, /* FS only */
346 VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */
347 VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */
348 VARYING_SLOT_BOUNDING_BOX0, /* Only appears as TCS output. */
349 VARYING_SLOT_BOUNDING_BOX1, /* Only appears as TCS output. */
350 VARYING_SLOT_VIEW_INDEX,
351 VARYING_SLOT_VIEWPORT_MASK, /* Does not appear in FS */
352 VARYING_SLOT_PRIMITIVE_SHADING_RATE = VARYING_SLOT_FACE, /* Does not appear in FS. */
353
354 VARYING_SLOT_PRIMITIVE_COUNT = VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears in MESH. */
355 VARYING_SLOT_PRIMITIVE_INDICES = VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears in MESH. */
356 VARYING_SLOT_TASK_COUNT = VARYING_SLOT_BOUNDING_BOX0, /* Only appears in TASK. */
357 VARYING_SLOT_CULL_PRIMITIVE = VARYING_SLOT_BOUNDING_BOX0, /* Only appears in MESH. */
358
359 VARYING_SLOT_VAR0 = 32, /* First generic varying slot */
360 /* the remaining are simply for the benefit of gl_varying_slot_name()
361 * and not to be construed as an upper bound:
362 */
363 VARYING_SLOT_VAR1,
364 VARYING_SLOT_VAR2,
365 VARYING_SLOT_VAR3,
366 VARYING_SLOT_VAR4,
367 VARYING_SLOT_VAR5,
368 VARYING_SLOT_VAR6,
369 VARYING_SLOT_VAR7,
370 VARYING_SLOT_VAR8,
371 VARYING_SLOT_VAR9,
372 VARYING_SLOT_VAR10,
373 VARYING_SLOT_VAR11,
374 VARYING_SLOT_VAR12,
375 VARYING_SLOT_VAR13,
376 VARYING_SLOT_VAR14,
377 VARYING_SLOT_VAR15,
378 VARYING_SLOT_VAR16,
379 VARYING_SLOT_VAR17,
380 VARYING_SLOT_VAR18,
381 VARYING_SLOT_VAR19,
382 VARYING_SLOT_VAR20,
383 VARYING_SLOT_VAR21,
384 VARYING_SLOT_VAR22,
385 VARYING_SLOT_VAR23,
386 VARYING_SLOT_VAR24,
387 VARYING_SLOT_VAR25,
388 VARYING_SLOT_VAR26,
389 VARYING_SLOT_VAR27,
390 VARYING_SLOT_VAR28,
391 VARYING_SLOT_VAR29,
392 VARYING_SLOT_VAR30,
393 VARYING_SLOT_VAR31,
394 /* Per-patch varyings for tessellation. */
395 VARYING_SLOT_PATCH0,
396 VARYING_SLOT_PATCH1,
397 VARYING_SLOT_PATCH2,
398 VARYING_SLOT_PATCH3,
399 VARYING_SLOT_PATCH4,
400 VARYING_SLOT_PATCH5,
401 VARYING_SLOT_PATCH6,
402 VARYING_SLOT_PATCH7,
403 VARYING_SLOT_PATCH8,
404 VARYING_SLOT_PATCH9,
405 VARYING_SLOT_PATCH10,
406 VARYING_SLOT_PATCH11,
407 VARYING_SLOT_PATCH12,
408 VARYING_SLOT_PATCH13,
409 VARYING_SLOT_PATCH14,
410 VARYING_SLOT_PATCH15,
411 VARYING_SLOT_PATCH16,
412 VARYING_SLOT_PATCH17,
413 VARYING_SLOT_PATCH18,
414 VARYING_SLOT_PATCH19,
415 VARYING_SLOT_PATCH20,
416 VARYING_SLOT_PATCH21,
417 VARYING_SLOT_PATCH22,
418 VARYING_SLOT_PATCH23,
419 VARYING_SLOT_PATCH24,
420 VARYING_SLOT_PATCH25,
421 VARYING_SLOT_PATCH26,
422 VARYING_SLOT_PATCH27,
423 VARYING_SLOT_PATCH28,
424 VARYING_SLOT_PATCH29,
425 VARYING_SLOT_PATCH30,
426 VARYING_SLOT_PATCH31,
427 /* 32 16-bit vec4 slots packed in 16 32-bit vec4 slots for GLES/mediump.
428 * They are really just additional generic slots used for 16-bit data to
429 * prevent conflicts between neighboring mediump and non-mediump varyings
430 * that can't be packed without breaking one or the other, which is
431 * a limitation of separate shaders. This allows linking shaders in 32 bits
432 * and then get an optimally packed 16-bit varyings by remapping the IO
433 * locations to these slots. The remapping can also be undone trivially.
434 *
435 * nir_io_semantics::high_16bit determines which half of the slot is
436 * accessed. The low and high halves share the same IO "base" number.
437 * Drivers can treat these as 32-bit slots everywhere except for FP16
438 * interpolation.
439 */
440 VARYING_SLOT_VAR0_16BIT,
441 VARYING_SLOT_VAR1_16BIT,
442 VARYING_SLOT_VAR2_16BIT,
443 VARYING_SLOT_VAR3_16BIT,
444 VARYING_SLOT_VAR4_16BIT,
445 VARYING_SLOT_VAR5_16BIT,
446 VARYING_SLOT_VAR6_16BIT,
447 VARYING_SLOT_VAR7_16BIT,
448 VARYING_SLOT_VAR8_16BIT,
449 VARYING_SLOT_VAR9_16BIT,
450 VARYING_SLOT_VAR10_16BIT,
451 VARYING_SLOT_VAR11_16BIT,
452 VARYING_SLOT_VAR12_16BIT,
453 VARYING_SLOT_VAR13_16BIT,
454 VARYING_SLOT_VAR14_16BIT,
455 VARYING_SLOT_VAR15_16BIT,
456
457 NUM_TOTAL_VARYING_SLOTS,
458 } gl_varying_slot;
459
460
461 #define VARYING_SLOT_MAX (VARYING_SLOT_VAR0 + MAX_VARYING)
462 #define VARYING_SLOT_TESS_MAX (VARYING_SLOT_PATCH0 + MAX_VARYING)
463 #define MAX_VARYINGS_INCL_PATCH (VARYING_SLOT_TESS_MAX - VARYING_SLOT_VAR0)
464
465 const char *gl_varying_slot_name_for_stage(gl_varying_slot slot,
466 gl_shader_stage stage);
467
468 /**
469 * Determine if the given gl_varying_slot appears in the fragment shader.
470 */
471 static inline bool
_mesa_varying_slot_in_fs(gl_varying_slot slot)472 _mesa_varying_slot_in_fs(gl_varying_slot slot)
473 {
474 switch (slot) {
475 case VARYING_SLOT_PSIZ:
476 case VARYING_SLOT_BFC0:
477 case VARYING_SLOT_BFC1:
478 case VARYING_SLOT_EDGE:
479 case VARYING_SLOT_CLIP_VERTEX:
480 case VARYING_SLOT_LAYER:
481 case VARYING_SLOT_TESS_LEVEL_OUTER:
482 case VARYING_SLOT_TESS_LEVEL_INNER:
483 case VARYING_SLOT_BOUNDING_BOX0:
484 case VARYING_SLOT_BOUNDING_BOX1:
485 case VARYING_SLOT_VIEWPORT_MASK:
486 return false;
487 default:
488 return true;
489 }
490 }
491
492 /**
493 * Bitflags for varying slots.
494 */
495 /*@{*/
496 #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS)
497 #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0)
498 #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1)
499 #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC)
500 #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0)
501 #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1)
502 #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2)
503 #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3)
504 #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4)
505 #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5)
506 #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6)
507 #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7)
508 #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U))
509 #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \
510 MAX_TEXTURE_COORD_UNITS)
511 #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ)
512 #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0)
513 #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1)
514 #define VARYING_BITS_COLOR (VARYING_BIT_COL0 | \
515 VARYING_BIT_COL1 | \
516 VARYING_BIT_BFC0 | \
517 VARYING_BIT_BFC1)
518 #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE)
519 #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX)
520 #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0)
521 #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1)
522 #define VARYING_BIT_CULL_DIST0 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST0)
523 #define VARYING_BIT_CULL_DIST1 BITFIELD64_BIT(VARYING_SLOT_CULL_DIST1)
524 #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID)
525 #define VARYING_BIT_PRIMITIVE_COUNT BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_COUNT)
526 #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER)
527 #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT)
528 #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE)
529 #define VARYING_BIT_PRIMITIVE_SHADING_RATE BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_SHADING_RATE)
530 #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC)
531 #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER)
532 #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER)
533 #define VARYING_BIT_BOUNDING_BOX0 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX0)
534 #define VARYING_BIT_BOUNDING_BOX1 BITFIELD64_BIT(VARYING_SLOT_BOUNDING_BOX1)
535 #define VARYING_BIT_VIEWPORT_MASK BITFIELD64_BIT(VARYING_SLOT_VIEWPORT_MASK)
536 #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V))
537 /*@}*/
538
539 /**
540 * Writemask values, 1 bit per component.
541 */
542 /*@{*/
543 #define WRITEMASK_X 0x1
544 #define WRITEMASK_Y 0x2
545 #define WRITEMASK_XY 0x3
546 #define WRITEMASK_Z 0x4
547 #define WRITEMASK_XZ 0x5
548 #define WRITEMASK_YZ 0x6
549 #define WRITEMASK_XYZ 0x7
550 #define WRITEMASK_W 0x8
551 #define WRITEMASK_XW 0x9
552 #define WRITEMASK_YW 0xa
553 #define WRITEMASK_XYW 0xb
554 #define WRITEMASK_ZW 0xc
555 #define WRITEMASK_XZW 0xd
556 #define WRITEMASK_YZW 0xe
557 #define WRITEMASK_XYZW 0xf
558 /*@}*/
559
560 /**
561 * If a NIR variable's mode is nir_var_system_value, it will be one of these
562 * values.
563 */
564 typedef enum
565 {
566 /**
567 * \name System values applicable to all shaders
568 */
569 /*@{*/
570
571 /**
572 * Builtin variables added by GL_ARB_shader_ballot.
573 */
574 /*@{*/
575
576 /**
577 * From the GL_ARB_shader-ballot spec:
578 *
579 * "A sub-group is a collection of invocations which execute in lockstep.
580 * The variable <gl_SubGroupSizeARB> is the maximum number of
581 * invocations in a sub-group. The maximum <gl_SubGroupSizeARB>
582 * supported in this extension is 64."
583 *
584 * The spec defines this as a uniform. However, it's highly unlikely that
585 * implementations actually treat it as a uniform (which is loaded from a
586 * constant buffer). Most likely, this is an implementation-wide constant,
587 * or perhaps something that depends on the shader stage.
588 */
589 SYSTEM_VALUE_SUBGROUP_SIZE,
590
591 /**
592 * From the GL_ARB_shader_ballot spec:
593 *
594 * "The variable <gl_SubGroupInvocationARB> holds the index of the
595 * invocation within sub-group. This variable is in the range 0 to
596 * <gl_SubGroupSizeARB>-1, where <gl_SubGroupSizeARB> is the total
597 * number of invocations in a sub-group."
598 */
599 SYSTEM_VALUE_SUBGROUP_INVOCATION,
600
601 /**
602 * From the GL_ARB_shader_ballot spec:
603 *
604 * "The <gl_SubGroup??MaskARB> variables provide a bitmask for all
605 * invocations, with one bit per invocation starting with the least
606 * significant bit, according to the following table,
607 *
608 * variable equation for bit values
609 * -------------------- ------------------------------------
610 * gl_SubGroupEqMaskARB bit index == gl_SubGroupInvocationARB
611 * gl_SubGroupGeMaskARB bit index >= gl_SubGroupInvocationARB
612 * gl_SubGroupGtMaskARB bit index > gl_SubGroupInvocationARB
613 * gl_SubGroupLeMaskARB bit index <= gl_SubGroupInvocationARB
614 * gl_SubGroupLtMaskARB bit index < gl_SubGroupInvocationARB
615 */
616 SYSTEM_VALUE_SUBGROUP_EQ_MASK,
617 SYSTEM_VALUE_SUBGROUP_GE_MASK,
618 SYSTEM_VALUE_SUBGROUP_GT_MASK,
619 SYSTEM_VALUE_SUBGROUP_LE_MASK,
620 SYSTEM_VALUE_SUBGROUP_LT_MASK,
621 /*@}*/
622
623 /**
624 * Builtin variables added by VK_KHR_subgroups
625 */
626 /*@{*/
627 SYSTEM_VALUE_NUM_SUBGROUPS,
628 SYSTEM_VALUE_SUBGROUP_ID,
629 /*@}*/
630
631 /*@}*/
632
633 /**
634 * \name Vertex shader system values
635 */
636 /*@{*/
637 /**
638 * OpenGL-style vertex ID.
639 *
640 * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the
641 * OpenGL 3.3 core profile spec says:
642 *
643 * "gl_VertexID holds the integer index i implicitly passed by
644 * DrawArrays or one of the other drawing commands defined in section
645 * 2.8.3."
646 *
647 * Section 2.8.3 (Drawing Commands) of the same spec says:
648 *
649 * "The commands....are equivalent to the commands with the same base
650 * name (without the BaseVertex suffix), except that the ith element
651 * transferred by the corresponding draw call will be taken from
652 * element indices[i] + basevertex of each enabled array."
653 *
654 * Additionally, the overview in the GL_ARB_shader_draw_parameters spec
655 * says:
656 *
657 * "In unextended GL, vertex shaders have inputs named gl_VertexID and
658 * gl_InstanceID, which contain, respectively the index of the vertex
659 * and instance. The value of gl_VertexID is the implicitly passed
660 * index of the vertex being processed, which includes the value of
661 * baseVertex, for those commands that accept it."
662 *
663 * gl_VertexID gets basevertex added in. This differs from DirectX where
664 * SV_VertexID does \b not get basevertex added in.
665 *
666 * \note
667 * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be
668 * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus
669 * \c SYSTEM_VALUE_BASE_VERTEX.
670 *
671 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX
672 */
673 SYSTEM_VALUE_VERTEX_ID,
674
675 /**
676 * Instanced ID as supplied to gl_InstanceID
677 *
678 * Values assigned to gl_InstanceID always begin with zero, regardless of
679 * the value of baseinstance.
680 *
681 * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec
682 * says:
683 *
684 * "gl_InstanceID holds the integer instance number of the current
685 * primitive in an instanced draw call (see section 10.5)."
686 *
687 * Through a big chain of pseudocode, section 10.5 describes that
688 * baseinstance is not counted by gl_InstanceID. In that section, notice
689 *
690 * "If an enabled vertex attribute array is instanced (it has a
691 * non-zero divisor as specified by VertexAttribDivisor), the element
692 * index that is transferred to the GL, for all vertices, is given by
693 *
694 * floor(instance/divisor) + baseinstance
695 *
696 * If an array corresponding to an attribute required by a vertex
697 * shader is not enabled, then the corresponding element is taken from
698 * the current attribute state (see section 10.2)."
699 *
700 * Note that baseinstance is \b not included in the value of instance.
701 */
702 SYSTEM_VALUE_INSTANCE_ID,
703
704 /**
705 * Vulkan InstanceIndex.
706 *
707 * InstanceIndex = gl_InstanceID + gl_BaseInstance
708 */
709 SYSTEM_VALUE_INSTANCE_INDEX,
710
711 /**
712 * DirectX-style vertex ID.
713 *
714 * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include
715 * the value of basevertex.
716 *
717 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX
718 */
719 SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
720
721 /**
722 * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar
723 * functions.
724 *
725 * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE
726 */
727 SYSTEM_VALUE_BASE_VERTEX,
728
729 /**
730 * Depending on the type of the draw call (indexed or non-indexed),
731 * is the value of \c basevertex passed to \c glDrawElementsBaseVertex and
732 * similar, or is the value of \c first passed to \c glDrawArrays and
733 * similar.
734 *
735 * \note
736 * It can be used to calculate the \c SYSTEM_VALUE_VERTEX_ID as
737 * \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus \c SYSTEM_VALUE_FIRST_VERTEX.
738 *
739 * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_VERTEX_ID
740 */
741 SYSTEM_VALUE_FIRST_VERTEX,
742
743 /**
744 * If the Draw command used to start the rendering was an indexed draw
745 * or not (~0/0). Useful to calculate \c SYSTEM_VALUE_BASE_VERTEX as
746 * \c SYSTEM_VALUE_IS_INDEXED_DRAW & \c SYSTEM_VALUE_FIRST_VERTEX.
747 */
748 SYSTEM_VALUE_IS_INDEXED_DRAW,
749
750 /**
751 * Value of \c baseinstance passed to instanced draw entry points
752 *
753 * \sa SYSTEM_VALUE_INSTANCE_ID
754 */
755 SYSTEM_VALUE_BASE_INSTANCE,
756
757 /**
758 * From _ARB_shader_draw_parameters:
759 *
760 * "Additionally, this extension adds a further built-in variable,
761 * gl_DrawID to the shading language. This variable contains the index
762 * of the draw currently being processed by a Multi* variant of a
763 * drawing command (such as MultiDrawElements or
764 * MultiDrawArraysIndirect)."
765 *
766 * If GL_ARB_multi_draw_indirect is not supported, this is always 0.
767 */
768 SYSTEM_VALUE_DRAW_ID,
769 /*@}*/
770
771 /**
772 * \name Geometry shader system values
773 */
774 /*@{*/
775 SYSTEM_VALUE_INVOCATION_ID, /**< (Also in Tessellation Control shader) */
776 /*@}*/
777
778 /**
779 * \name Fragment shader system values
780 */
781 /*@{*/
782 SYSTEM_VALUE_FRAG_COORD,
783 SYSTEM_VALUE_PIXEL_COORD,
784 SYSTEM_VALUE_POINT_COORD,
785 SYSTEM_VALUE_LINE_COORD, /**< Coord along axis perpendicular to line */
786 SYSTEM_VALUE_FRONT_FACE,
787 SYSTEM_VALUE_FRONT_FACE_FSIGN,
788 SYSTEM_VALUE_SAMPLE_ID,
789 SYSTEM_VALUE_SAMPLE_POS,
790 SYSTEM_VALUE_SAMPLE_POS_OR_CENTER,
791 SYSTEM_VALUE_SAMPLE_MASK_IN,
792 SYSTEM_VALUE_LAYER_ID,
793 SYSTEM_VALUE_HELPER_INVOCATION,
794 SYSTEM_VALUE_COLOR0,
795 SYSTEM_VALUE_COLOR1,
796 /*@}*/
797
798 /**
799 * \name Tessellation Evaluation shader system values
800 */
801 /*@{*/
802 SYSTEM_VALUE_TESS_COORD,
803 SYSTEM_VALUE_VERTICES_IN, /**< Tessellation vertices in input patch */
804 SYSTEM_VALUE_PRIMITIVE_ID,
805 SYSTEM_VALUE_TESS_LEVEL_OUTER, /**< TES input */
806 SYSTEM_VALUE_TESS_LEVEL_INNER, /**< TES input */
807 SYSTEM_VALUE_TESS_LEVEL_OUTER_DEFAULT, /**< TCS input for passthru TCS */
808 SYSTEM_VALUE_TESS_LEVEL_INNER_DEFAULT, /**< TCS input for passthru TCS */
809 /*@}*/
810
811 /**
812 * \name Compute shader system values
813 */
814 /*@{*/
815 SYSTEM_VALUE_LOCAL_INVOCATION_ID,
816 SYSTEM_VALUE_LOCAL_INVOCATION_INDEX,
817 SYSTEM_VALUE_GLOBAL_INVOCATION_ID,
818 SYSTEM_VALUE_BASE_GLOBAL_INVOCATION_ID,
819 SYSTEM_VALUE_GLOBAL_INVOCATION_INDEX,
820 SYSTEM_VALUE_WORKGROUP_ID,
821 SYSTEM_VALUE_BASE_WORKGROUP_ID,
822 SYSTEM_VALUE_WORKGROUP_INDEX,
823 SYSTEM_VALUE_NUM_WORKGROUPS,
824 SYSTEM_VALUE_WORKGROUP_SIZE,
825 SYSTEM_VALUE_GLOBAL_GROUP_SIZE,
826 SYSTEM_VALUE_WORK_DIM,
827 SYSTEM_VALUE_USER_DATA_AMD,
828 /*@}*/
829
830 /** Required for VK_KHR_device_group */
831 SYSTEM_VALUE_DEVICE_INDEX,
832
833 /** Required for VK_KHX_multiview */
834 SYSTEM_VALUE_VIEW_INDEX,
835
836 /**
837 * Driver internal vertex-count, used (for example) for drivers to
838 * calculate stride for stream-out outputs. Not externally visible.
839 */
840 SYSTEM_VALUE_VERTEX_CNT,
841
842 /**
843 * Required for AMD_shader_explicit_vertex_parameter and also used for
844 * varying-fetch instructions.
845 *
846 * The _SIZE value is "primitive size", used to scale i/j in primitive
847 * space to pixel space.
848 */
849 SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL,
850 SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE,
851 SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID,
852 SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTER_RHW,
853 SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL,
854 SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID,
855 SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE,
856 SYSTEM_VALUE_BARYCENTRIC_PULL_MODEL,
857
858 /**
859 * \name VK_KHR_fragment_shader_barycentric
860 */
861 /*@{*/
862 SYSTEM_VALUE_BARYCENTRIC_PERSP_COORD,
863 SYSTEM_VALUE_BARYCENTRIC_LINEAR_COORD,
864 /*@}*/
865
866 /**
867 * \name Ray tracing shader system values
868 */
869 /*@{*/
870 SYSTEM_VALUE_RAY_LAUNCH_ID,
871 SYSTEM_VALUE_RAY_LAUNCH_SIZE,
872 SYSTEM_VALUE_RAY_WORLD_ORIGIN,
873 SYSTEM_VALUE_RAY_WORLD_DIRECTION,
874 SYSTEM_VALUE_RAY_OBJECT_ORIGIN,
875 SYSTEM_VALUE_RAY_OBJECT_DIRECTION,
876 SYSTEM_VALUE_RAY_T_MIN,
877 SYSTEM_VALUE_RAY_T_MAX,
878 SYSTEM_VALUE_RAY_OBJECT_TO_WORLD,
879 SYSTEM_VALUE_RAY_WORLD_TO_OBJECT,
880 SYSTEM_VALUE_RAY_HIT_KIND,
881 SYSTEM_VALUE_RAY_FLAGS,
882 SYSTEM_VALUE_RAY_GEOMETRY_INDEX,
883 SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX,
884 SYSTEM_VALUE_CULL_MASK,
885 SYSTEM_VALUE_RAY_TRIANGLE_VERTEX_POSITIONS,
886 /*@}*/
887
888 /**
889 * \name Task/Mesh shader system values
890 */
891 /*@{*/
892 SYSTEM_VALUE_MESH_VIEW_COUNT,
893 SYSTEM_VALUE_MESH_VIEW_INDICES,
894 /*@}*/
895
896 /**
897 * IR3 specific geometry shader and tesselation control shader system
898 * values that packs invocation id, thread id and vertex id. Having this
899 * as a nir level system value lets us do the unpacking in nir.
900 */
901 SYSTEM_VALUE_GS_HEADER_IR3,
902 SYSTEM_VALUE_TCS_HEADER_IR3,
903
904 /* IR3 specific system value that contains the patch id for the current
905 * subdraw.
906 */
907 SYSTEM_VALUE_REL_PATCH_ID_IR3,
908
909 /**
910 * Fragment shading rate used for KHR_fragment_shading_rate (Vulkan).
911 */
912 SYSTEM_VALUE_FRAG_SHADING_RATE,
913
914 /*
915 * Rasterized fragment is fully covered by the generating primitive
916 * (SPV_EXT_fragment_fully_covered).
917 */
918 SYSTEM_VALUE_FULLY_COVERED,
919
920 /*
921 * Fragment size and invocation count used for
922 * EXT_fragment_invocation_density (Vulkan).
923 */
924 SYSTEM_VALUE_FRAG_SIZE,
925 SYSTEM_VALUE_FRAG_INVOCATION_COUNT,
926
927 /* SPV_AMDX_shader_enqueue */
928 SYSTEM_VALUE_SHADER_INDEX,
929 SYSTEM_VALUE_COALESCED_INPUT_COUNT,
930
931 /* SPV_NV_shader_sm_builtins */
932 SYSTEM_VALUE_WARPS_PER_SM_NV,
933 SYSTEM_VALUE_SM_COUNT_NV,
934 SYSTEM_VALUE_WARP_ID_NV,
935 SYSTEM_VALUE_SM_ID_NV,
936
937 SYSTEM_VALUE_MAX /**< Number of values */
938 } gl_system_value;
939
940 const char *gl_system_value_name(gl_system_value sysval);
941
942 /**
943 * The possible interpolation qualifiers that can be applied to a fragment
944 * shader input in GLSL.
945 *
946 * Note: INTERP_MODE_NONE must be 0 so that memsetting the
947 * ir_variable data structure to 0 causes the default behavior.
948 */
949 enum glsl_interp_mode
950 {
951 INTERP_MODE_NONE = 0,
952 INTERP_MODE_SMOOTH,
953 INTERP_MODE_FLAT,
954 INTERP_MODE_NOPERSPECTIVE,
955 INTERP_MODE_EXPLICIT,
956 INTERP_MODE_COUNT /**< Number of interpolation qualifiers */
957 };
958
959 enum glsl_interface_packing {
960 GLSL_INTERFACE_PACKING_STD140,
961 GLSL_INTERFACE_PACKING_SHARED,
962 GLSL_INTERFACE_PACKING_PACKED,
963 GLSL_INTERFACE_PACKING_STD430
964 };
965
966 const char *glsl_interp_mode_name(enum glsl_interp_mode qual);
967
968 /**
969 * Fragment program results
970 */
971 typedef enum
972 {
973 FRAG_RESULT_DEPTH = 0,
974 FRAG_RESULT_STENCIL = 1,
975 /* If a single color should be written to all render targets, this
976 * register is written. No FRAG_RESULT_DATAn will be written.
977 */
978 FRAG_RESULT_COLOR = 2,
979 FRAG_RESULT_SAMPLE_MASK = 3,
980
981 /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n]
982 * or ARB_fragment_program fragment.color[n]) color results. If
983 * any are written, FRAG_RESULT_COLOR will not be written.
984 * FRAG_RESULT_DATA1 and up are simply for the benefit of
985 * gl_frag_result_name() and not to be construed as an upper bound
986 */
987 FRAG_RESULT_DATA0 = 4,
988 FRAG_RESULT_DATA1,
989 FRAG_RESULT_DATA2,
990 FRAG_RESULT_DATA3,
991 FRAG_RESULT_DATA4,
992 FRAG_RESULT_DATA5,
993 FRAG_RESULT_DATA6,
994 FRAG_RESULT_DATA7,
995 } gl_frag_result;
996
997 const char *gl_frag_result_name(gl_frag_result result);
998
999 #define FRAG_RESULT_MAX (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS)
1000
1001 /**
1002 * \brief Layout qualifiers for gl_FragDepth.
1003 *
1004 * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with
1005 * a layout qualifier.
1006 *
1007 * \see enum ir_depth_layout
1008 */
1009 enum gl_frag_depth_layout
1010 {
1011 FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */
1012 FRAG_DEPTH_LAYOUT_ANY,
1013 FRAG_DEPTH_LAYOUT_GREATER,
1014 FRAG_DEPTH_LAYOUT_LESS,
1015 FRAG_DEPTH_LAYOUT_UNCHANGED
1016 };
1017
1018 /**
1019 * \brief Layout qualifiers for AMD_shader_early_and_late_fragment_tests.
1020 */
1021 enum gl_frag_stencil_layout
1022 {
1023 FRAG_STENCIL_LAYOUT_NONE, /**< No layout is specified. */
1024 FRAG_STENCIL_LAYOUT_ANY,
1025 FRAG_STENCIL_LAYOUT_GREATER,
1026 FRAG_STENCIL_LAYOUT_LESS,
1027 FRAG_STENCIL_LAYOUT_UNCHANGED
1028 };
1029
1030 /**
1031 * \brief Memory access qualifiers
1032 */
1033 enum gl_access_qualifier
1034 {
1035 /**
1036 * This means that the memory scope is the current device. It indicates
1037 * that reads and writes are coherent with reads and writes from other
1038 * shader invocations and other workgroups.
1039 */
1040 ACCESS_COHERENT = (1 << 0),
1041
1042 /**
1043 * This means non-aliased. It indicates that the accessed address is not
1044 * accessible through any other memory resource in the shader.
1045 */
1046 ACCESS_RESTRICT = (1 << 1),
1047
1048 /**
1049 * The access cannot be eliminated, duplicated, or combined with other
1050 * accesses.
1051 */
1052 ACCESS_VOLATILE = (1 << 2),
1053
1054 /* The memory used by the access/variable is not read. */
1055 ACCESS_NON_READABLE = (1 << 3),
1056
1057 /* The memory used by the access/variable is not written. */
1058 ACCESS_NON_WRITEABLE = (1 << 4),
1059
1060 /**
1061 * The access may use a non-uniform buffer or image index.
1062 *
1063 * This is not allowed in either OpenGL or OpenGL ES, or Vulkan unless
1064 * VK_EXT_descriptor_indexing is supported and the appropriate capability is
1065 * enabled.
1066 *
1067 * Some GL spec archaeology justifying this:
1068 *
1069 * Up through at least GLSL ES 3.20 and GLSL 4.50, "Opaque Types" says "When
1070 * aggregated into arrays within a shader, opaque types can only be indexed
1071 * with a dynamically uniform integral expression (see section 3.9.3) unless
1072 * otherwise noted; otherwise, results are undefined."
1073 *
1074 * The original GL_AB_shader_image_load_store specification for desktop GL
1075 * didn't have this restriction ("Images may be aggregated into arrays within
1076 * a shader (using square brackets [ ]) and can be indexed with general
1077 * integer expressions.") At the same time,
1078 * GL_ARB_shader_storage_buffer_objects *did* have the uniform restriction
1079 * ("A uniform or shader storage block array can only be indexed with a
1080 * dynamically uniform integral expression, otherwise results are
1081 * undefined"), just like ARB_gpu_shader5 did when it first introduced a
1082 * non-constant indexing of an opaque type with samplers. So, we assume that
1083 * this was an oversight in the original image_load_store spec, and was
1084 * considered a correction in the merge to core.
1085 */
1086 ACCESS_NON_UNIFORM = (1 << 5),
1087
1088 /* This has the same semantics as NIR_INTRINSIC_CAN_REORDER, only to be
1089 * used with loads. In other words, it means that the load can be
1090 * arbitrarily reordered, or combined with other loads to the same address.
1091 * It is implied by ACCESS_NON_WRITEABLE and a lack of ACCESS_VOLATILE.
1092 */
1093 ACCESS_CAN_REORDER = (1 << 6),
1094
1095 /**
1096 * Hints that the accessed address is not likely to be accessed again
1097 * in the near future. This reduces data retention in caches.
1098 */
1099 ACCESS_NON_TEMPORAL = (1 << 7),
1100
1101 /** Execute instruction also in helpers. */
1102 ACCESS_INCLUDE_HELPERS = (1 << 8),
1103
1104 /**
1105 * Whether the address bits are swizzled by the hw. This practically means
1106 * that loads can't be vectorized and must be exactly 32 bits on some chips.
1107 * The swizzle amount is determined by the descriptor.
1108 */
1109 ACCESS_IS_SWIZZLED_AMD = (1 << 9),
1110
1111 /**
1112 * Whether an AMD-specific buffer intrinsic uses a format conversion.
1113 *
1114 * If unset, the intrinsic will access raw memory without any conversion.
1115 *
1116 * If set, the memory opcode performs a format conversion according to
1117 * the format determined by the descriptor (in a manner identical to image
1118 * buffers and sampler buffers).
1119 */
1120 ACCESS_USES_FORMAT_AMD = (1 << 10),
1121
1122 /**
1123 * Whether a multi sample image load intrinsic uses sample index extracted
1124 * from fragment mask buffer.
1125 */
1126 ACCESS_FMASK_LOWERED_AMD = (1 << 11),
1127
1128 /**
1129 * Whether it is safe to speculatively execute this load. This allows
1130 * hoisting loads out of conditional control flow (including out of software
1131 * bounds checks). Setting this optimally depends on knowledge of the
1132 * hardware. Speculation is safe if out-of-bounds access does not trigger
1133 * undefined behaviour (even though the returned value of the speculated load
1134 * is bogus). This is the case if there is hardware-level bounds checking, or
1135 * if MMU faults are suppressed for the load.
1136 */
1137 ACCESS_CAN_SPECULATE = (1 << 12),
1138
1139 /**
1140 * Whether coherency with CP (command processor) or GE (geometry engine)
1141 * is required.
1142 */
1143 ACCESS_CP_GE_COHERENT_AMD = (1 << 13),
1144
1145 /* Guarantee that an image_load is in bounds so we can skip robustness code
1146 * on AGX, used for some internal shaders.
1147 */
1148 ACCESS_IN_BOUNDS_AGX = (1 << 14),
1149
1150 /**
1151 * Disallow vectorization.
1152 *
1153 * On some hw (AMD), sparse buffer loads return 0 for all components if
1154 * a sparse load starts on a non-resident page, crosses the page boundary,
1155 * and ends on a resident page. Sometimes we want it to return 0 only for
1156 * the portion of the load that's non-resident, and load values for
1157 * the portion that's resident. The workaround is to scalarize such loads
1158 * and disallow vectorization. This is used by an internal copy_buffer
1159 * shader where the API wants to copy all bytes that are resident.
1160 */
1161 ACCESS_KEEP_SCALAR = (1 << 15),
1162
1163 /**
1164 * Indicates that this load will use SMEM.
1165 */
1166 ACCESS_SMEM_AMD = (1 << 16),
1167 };
1168
1169 /**
1170 * \brief Blend support qualifiers
1171 */
1172 enum gl_advanced_blend_mode
1173 {
1174 BLEND_MODE_NONE = 0,
1175 BLEND_MULTIPLY,
1176 BLEND_SCREEN,
1177 BLEND_OVERLAY,
1178 BLEND_DARKEN,
1179 BLEND_LIGHTEN,
1180 BLEND_COLORDODGE,
1181 BLEND_COLORBURN,
1182 BLEND_HARDLIGHT,
1183 BLEND_SOFTLIGHT,
1184 BLEND_DIFFERENCE,
1185 BLEND_EXCLUSION,
1186 BLEND_HSL_HUE,
1187 BLEND_HSL_SATURATION,
1188 BLEND_HSL_COLOR,
1189 BLEND_HSL_LUMINOSITY,
1190 };
1191
1192 enum gl_tess_spacing
1193 {
1194 TESS_SPACING_UNSPECIFIED,
1195 TESS_SPACING_EQUAL,
1196 TESS_SPACING_FRACTIONAL_ODD,
1197 TESS_SPACING_FRACTIONAL_EVEN,
1198 };
1199
1200 enum tess_primitive_mode
1201 {
1202 TESS_PRIMITIVE_UNSPECIFIED,
1203 TESS_PRIMITIVE_TRIANGLES,
1204 TESS_PRIMITIVE_QUADS,
1205 TESS_PRIMITIVE_ISOLINES,
1206 };
1207
1208 static inline void
mesa_count_tess_level_components(const enum tess_primitive_mode mode,unsigned * outer,unsigned * inner)1209 mesa_count_tess_level_components(const enum tess_primitive_mode mode,
1210 unsigned *outer, unsigned *inner)
1211 {
1212 switch (mode) {
1213 case TESS_PRIMITIVE_ISOLINES:
1214 *outer = 2;
1215 *inner = 0;
1216 break;
1217 case TESS_PRIMITIVE_TRIANGLES:
1218 *outer = 3;
1219 *inner = 1;
1220 break;
1221 case TESS_PRIMITIVE_QUADS:
1222 default:
1223 *outer = 4;
1224 *inner = 2;
1225 break;
1226 }
1227 }
1228
1229 /**
1230 * Mesa primitive types for both GL and Vulkan:
1231 */
1232 enum ENUM_PACKED mesa_prim
1233 {
1234 MESA_PRIM_POINTS,
1235 MESA_PRIM_LINES,
1236 MESA_PRIM_LINE_LOOP,
1237 MESA_PRIM_LINE_STRIP,
1238 MESA_PRIM_TRIANGLES,
1239 MESA_PRIM_TRIANGLE_STRIP,
1240 MESA_PRIM_TRIANGLE_FAN,
1241 MESA_PRIM_QUADS,
1242 MESA_PRIM_QUAD_STRIP,
1243 MESA_PRIM_POLYGON,
1244 MESA_PRIM_LINES_ADJACENCY,
1245 MESA_PRIM_LINE_STRIP_ADJACENCY,
1246 MESA_PRIM_TRIANGLES_ADJACENCY,
1247 MESA_PRIM_TRIANGLE_STRIP_ADJACENCY,
1248 MESA_PRIM_PATCHES,
1249 MESA_PRIM_MAX = MESA_PRIM_PATCHES,
1250 MESA_PRIM_COUNT = MESA_PRIM_MAX +1,
1251 MESA_PRIM_UNKNOWN = (MESA_PRIM_MAX * 2),
1252 };
1253
1254 /**
1255 * Number of vertices per primitive as seen by a geometry or mesh shader.
1256 */
1257 static inline unsigned
mesa_vertices_per_prim(enum mesa_prim prim)1258 mesa_vertices_per_prim(enum mesa_prim prim)
1259 {
1260 switch(prim) {
1261 case MESA_PRIM_POINTS:
1262 return 1;
1263 case MESA_PRIM_LINES:
1264 case MESA_PRIM_LINE_LOOP:
1265 case MESA_PRIM_LINE_STRIP:
1266 return 2;
1267 case MESA_PRIM_TRIANGLES:
1268 case MESA_PRIM_TRIANGLE_STRIP:
1269 case MESA_PRIM_TRIANGLE_FAN:
1270 return 3;
1271 case MESA_PRIM_LINES_ADJACENCY:
1272 case MESA_PRIM_LINE_STRIP_ADJACENCY:
1273 return 4;
1274 case MESA_PRIM_TRIANGLES_ADJACENCY:
1275 case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
1276 return 6;
1277
1278 case MESA_PRIM_QUADS:
1279 case MESA_PRIM_QUAD_STRIP:
1280 /* These won't be seen from geometry shaders but prim assembly might for
1281 * prim id.
1282 */
1283 return 4;
1284
1285 /* The following primitives should never be used with geometry or mesh
1286 * shaders and their size is undefined.
1287 */
1288 case MESA_PRIM_POLYGON:
1289 default:
1290 debug_printf("Unrecognized geometry or mesh shader primitive");
1291 return 3;
1292 }
1293 }
1294
1295 /**
1296 * Returns the number of decomposed primitives for the given
1297 * vertex count.
1298 * Parts of the pipline are invoked once for each triangle in
1299 * triangle strip, triangle fans and triangles and once
1300 * for each line in line strip, line loop, lines. Also
1301 * statistics depend on knowing the exact number of decomposed
1302 * primitives for a set of vertices.
1303 */
1304 static inline unsigned
u_decomposed_prims_for_vertices(enum mesa_prim primitive,int vertices)1305 u_decomposed_prims_for_vertices(enum mesa_prim primitive, int vertices)
1306 {
1307 switch (primitive) {
1308 case MESA_PRIM_POINTS:
1309 return vertices;
1310 case MESA_PRIM_LINES:
1311 return vertices / 2;
1312 case MESA_PRIM_LINE_LOOP:
1313 return (vertices >= 2) ? vertices : 0;
1314 case MESA_PRIM_LINE_STRIP:
1315 return (vertices >= 2) ? vertices - 1 : 0;
1316 case MESA_PRIM_TRIANGLES:
1317 return vertices / 3;
1318 case MESA_PRIM_TRIANGLE_STRIP:
1319 return (vertices >= 3) ? vertices - 2 : 0;
1320 case MESA_PRIM_TRIANGLE_FAN:
1321 return (vertices >= 3) ? vertices - 2 : 0;
1322 case MESA_PRIM_LINES_ADJACENCY:
1323 return vertices / 4;
1324 case MESA_PRIM_LINE_STRIP_ADJACENCY:
1325 return (vertices >= 4) ? vertices - 3 : 0;
1326 case MESA_PRIM_TRIANGLES_ADJACENCY:
1327 return vertices / 6;
1328 case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
1329 return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0;
1330 case MESA_PRIM_QUADS:
1331 return vertices / 4;
1332 case MESA_PRIM_QUAD_STRIP:
1333 return (vertices >= 4) ? (vertices - 2) / 2 : 0;
1334 /* Polygons can't be decomposed
1335 * because the number of their vertices isn't known so
1336 * for them and whatever else we don't recognize just
1337 * return 1 if the number of vertices is greater than
1338 * or equal to 3 and zero otherwise */
1339 case MESA_PRIM_POLYGON:
1340 default:
1341 debug_printf("Invalid decomposition primitive!\n");
1342 return (vertices >= 3) ? 1 : 0;
1343 }
1344 }
1345
1346 /**
1347 * Decompose a primitive that is a loop, a strip, or a fan. Return the
1348 * original primitive if it is already decomposed.
1349 */
1350 static inline enum mesa_prim
u_decomposed_prim(enum mesa_prim prim)1351 u_decomposed_prim(enum mesa_prim prim)
1352 {
1353 switch (prim) {
1354 case MESA_PRIM_LINE_LOOP:
1355 case MESA_PRIM_LINE_STRIP:
1356 return MESA_PRIM_LINES;
1357 case MESA_PRIM_TRIANGLE_STRIP:
1358 case MESA_PRIM_TRIANGLE_FAN:
1359 return MESA_PRIM_TRIANGLES;
1360 case MESA_PRIM_QUAD_STRIP:
1361 return MESA_PRIM_QUADS;
1362 case MESA_PRIM_LINE_STRIP_ADJACENCY:
1363 return MESA_PRIM_LINES_ADJACENCY;
1364 case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY:
1365 return MESA_PRIM_TRIANGLES_ADJACENCY;
1366 default:
1367 return prim;
1368 }
1369 }
1370
1371 /**
1372 * Reduce a primitive to one of MESA_PRIM_POINTS, MESA_PRIM_LINES, and
1373 * MESA_PRIM_TRIANGLES.
1374 */
1375 static inline enum mesa_prim
u_reduced_prim(enum mesa_prim prim)1376 u_reduced_prim(enum mesa_prim prim)
1377 {
1378 switch (prim) {
1379 case MESA_PRIM_POINTS:
1380 return MESA_PRIM_POINTS;
1381 case MESA_PRIM_LINES:
1382 case MESA_PRIM_LINE_LOOP:
1383 case MESA_PRIM_LINE_STRIP:
1384 case MESA_PRIM_LINES_ADJACENCY:
1385 case MESA_PRIM_LINE_STRIP_ADJACENCY:
1386 return MESA_PRIM_LINES;
1387 default:
1388 return MESA_PRIM_TRIANGLES;
1389 }
1390 }
1391
1392 static inline bool
mesa_prim_has_adjacency(enum mesa_prim prim)1393 mesa_prim_has_adjacency(enum mesa_prim prim)
1394 {
1395 static_assert(MESA_PRIM_LINE_STRIP_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 1, "");
1396 static_assert(MESA_PRIM_TRIANGLES_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 2, "");
1397 static_assert(MESA_PRIM_TRIANGLE_STRIP_ADJACENCY == MESA_PRIM_LINES_ADJACENCY + 3, "");
1398
1399 /* Adjacency primitives are together so we can do a simple comparison */
1400 return prim >= MESA_PRIM_LINES_ADJACENCY &&
1401 prim <= MESA_PRIM_TRIANGLE_STRIP_ADJACENCY;
1402 }
1403
1404 /**
1405 * A compare function enum for use in compiler lowering passes. This is in
1406 * the same order as GL's compare functions (shifted down by GL_NEVER), and is
1407 * exactly the same as gallium's PIPE_FUNC_*.
1408 */
1409 enum compare_func
1410 {
1411 COMPARE_FUNC_NEVER,
1412 COMPARE_FUNC_LESS,
1413 COMPARE_FUNC_EQUAL,
1414 COMPARE_FUNC_LEQUAL,
1415 COMPARE_FUNC_GREATER,
1416 COMPARE_FUNC_NOTEQUAL,
1417 COMPARE_FUNC_GEQUAL,
1418 COMPARE_FUNC_ALWAYS,
1419 };
1420
1421 /**
1422 * Arrangements for grouping invocations from NV_compute_shader_derivatives.
1423 *
1424 * The extension provides new layout qualifiers that support two different
1425 * arrangements of compute shader invocations for the purpose of derivative
1426 * computation. When specifying
1427 *
1428 * layout(derivative_group_quadsNV) in;
1429 *
1430 * compute shader invocations are grouped into 2x2x1 arrays whose four local
1431 * invocation ID values follow the pattern:
1432 *
1433 * +-----------------+------------------+
1434 * | (2x+0, 2y+0, z) | (2x+1, 2y+0, z) |
1435 * +-----------------+------------------+
1436 * | (2x+0, 2y+1, z) | (2x+1, 2y+1, z) |
1437 * +-----------------+------------------+
1438 *
1439 * where Y increases from bottom to top. When specifying
1440 *
1441 * layout(derivative_group_linearNV) in;
1442 *
1443 * compute shader invocations are grouped into 2x2x1 arrays whose four local
1444 * invocation index values follow the pattern:
1445 *
1446 * +------+------+
1447 * | 4n+0 | 4n+1 |
1448 * +------+------+
1449 * | 4n+2 | 4n+3 |
1450 * +------+------+
1451 *
1452 * If neither layout qualifier is specified, derivatives in compute shaders
1453 * return zero, which is consistent with the handling of built-in texture
1454 * functions like texture() in GLSL 4.50 compute shaders.
1455 */
1456 enum gl_derivative_group {
1457 DERIVATIVE_GROUP_NONE = 0,
1458 DERIVATIVE_GROUP_QUADS,
1459 DERIVATIVE_GROUP_LINEAR,
1460 };
1461
1462 enum float_controls
1463 {
1464 /* The order of these matters. For float_controls2, only the first 9 bits
1465 * are used and stored per-instruction in nir_alu_instr::fp_fast_math.
1466 * Any changes in this enum need to be synchronized with that.
1467 */
1468 FLOAT_CONTROLS_DEFAULT_FLOAT_CONTROL_MODE = 0,
1469 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 = BITFIELD_BIT(0),
1470 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 = BITFIELD_BIT(1),
1471 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64 = BITFIELD_BIT(2),
1472 FLOAT_CONTROLS_INF_PRESERVE_FP16 = BITFIELD_BIT(3),
1473 FLOAT_CONTROLS_INF_PRESERVE_FP32 = BITFIELD_BIT(4),
1474 FLOAT_CONTROLS_INF_PRESERVE_FP64 = BITFIELD_BIT(5),
1475 FLOAT_CONTROLS_NAN_PRESERVE_FP16 = BITFIELD_BIT(6),
1476 FLOAT_CONTROLS_NAN_PRESERVE_FP32 = BITFIELD_BIT(7),
1477 FLOAT_CONTROLS_NAN_PRESERVE_FP64 = BITFIELD_BIT(8),
1478 FLOAT_CONTROLS_DENORM_PRESERVE_FP16 = BITFIELD_BIT(9),
1479 FLOAT_CONTROLS_DENORM_PRESERVE_FP32 = BITFIELD_BIT(10),
1480 FLOAT_CONTROLS_DENORM_PRESERVE_FP64 = BITFIELD_BIT(11),
1481 FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16 = BITFIELD_BIT(12),
1482 FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32 = BITFIELD_BIT(13),
1483 FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP64 = BITFIELD_BIT(14),
1484 FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16 = BITFIELD_BIT(15),
1485 FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32 = BITFIELD_BIT(16),
1486 FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64 = BITFIELD_BIT(17),
1487 FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16 = BITFIELD_BIT(18),
1488 FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32 = BITFIELD_BIT(19),
1489 FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64 = BITFIELD_BIT(20),
1490
1491 FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP16 =
1492 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 |
1493 FLOAT_CONTROLS_INF_PRESERVE_FP16 |
1494 FLOAT_CONTROLS_NAN_PRESERVE_FP16,
1495
1496 FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP32 =
1497 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 |
1498 FLOAT_CONTROLS_INF_PRESERVE_FP32 |
1499 FLOAT_CONTROLS_NAN_PRESERVE_FP32,
1500
1501 FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP64 =
1502 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64 |
1503 FLOAT_CONTROLS_INF_PRESERVE_FP64 |
1504 FLOAT_CONTROLS_NAN_PRESERVE_FP64,
1505
1506 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE =
1507 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 |
1508 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 |
1509 FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64,
1510
1511 FLOAT_CONTROLS_INF_PRESERVE =
1512 FLOAT_CONTROLS_INF_PRESERVE_FP16 |
1513 FLOAT_CONTROLS_INF_PRESERVE_FP32 |
1514 FLOAT_CONTROLS_INF_PRESERVE_FP64,
1515
1516 FLOAT_CONTROLS_NAN_PRESERVE =
1517 FLOAT_CONTROLS_NAN_PRESERVE_FP16 |
1518 FLOAT_CONTROLS_NAN_PRESERVE_FP32 |
1519 FLOAT_CONTROLS_NAN_PRESERVE_FP64,
1520 };
1521
1522 /**
1523 * Enums to describe sampler properties used by OpenCL's inline constant samplers.
1524 * These values match the meanings described in the SPIR-V spec.
1525 */
1526 enum cl_sampler_addressing_mode {
1527 SAMPLER_ADDRESSING_MODE_NONE = 0,
1528 SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = 1,
1529 SAMPLER_ADDRESSING_MODE_CLAMP = 2,
1530 SAMPLER_ADDRESSING_MODE_REPEAT = 3,
1531 SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED = 4,
1532 };
1533
1534 enum cl_sampler_filter_mode {
1535 SAMPLER_FILTER_MODE_NEAREST = 0,
1536 SAMPLER_FILTER_MODE_LINEAR = 1,
1537 };
1538
1539 /**
1540 * \name Bit flags used for updating material values.
1541 */
1542 /*@{*/
1543 #define MAT_ATTRIB_FRONT_AMBIENT 0
1544 #define MAT_ATTRIB_BACK_AMBIENT 1
1545 #define MAT_ATTRIB_FRONT_DIFFUSE 2
1546 #define MAT_ATTRIB_BACK_DIFFUSE 3
1547 #define MAT_ATTRIB_FRONT_SPECULAR 4
1548 #define MAT_ATTRIB_BACK_SPECULAR 5
1549 #define MAT_ATTRIB_FRONT_EMISSION 6
1550 #define MAT_ATTRIB_BACK_EMISSION 7
1551 #define MAT_ATTRIB_FRONT_SHININESS 8
1552 #define MAT_ATTRIB_BACK_SHININESS 9
1553 #define MAT_ATTRIB_FRONT_INDEXES 10
1554 #define MAT_ATTRIB_BACK_INDEXES 11
1555 #define MAT_ATTRIB_MAX 12
1556
1557 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f))
1558 #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f))
1559 #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f))
1560 #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f))
1561 #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f))
1562 #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f))
1563
1564 #define MAT_BIT_FRONT_AMBIENT (1<<MAT_ATTRIB_FRONT_AMBIENT)
1565 #define MAT_BIT_BACK_AMBIENT (1<<MAT_ATTRIB_BACK_AMBIENT)
1566 #define MAT_BIT_FRONT_DIFFUSE (1<<MAT_ATTRIB_FRONT_DIFFUSE)
1567 #define MAT_BIT_BACK_DIFFUSE (1<<MAT_ATTRIB_BACK_DIFFUSE)
1568 #define MAT_BIT_FRONT_SPECULAR (1<<MAT_ATTRIB_FRONT_SPECULAR)
1569 #define MAT_BIT_BACK_SPECULAR (1<<MAT_ATTRIB_BACK_SPECULAR)
1570 #define MAT_BIT_FRONT_EMISSION (1<<MAT_ATTRIB_FRONT_EMISSION)
1571 #define MAT_BIT_BACK_EMISSION (1<<MAT_ATTRIB_BACK_EMISSION)
1572 #define MAT_BIT_FRONT_SHININESS (1<<MAT_ATTRIB_FRONT_SHININESS)
1573 #define MAT_BIT_BACK_SHININESS (1<<MAT_ATTRIB_BACK_SHININESS)
1574 #define MAT_BIT_FRONT_INDEXES (1<<MAT_ATTRIB_FRONT_INDEXES)
1575 #define MAT_BIT_BACK_INDEXES (1<<MAT_ATTRIB_BACK_INDEXES)
1576
1577 /** An enum representing what kind of input gl_SubgroupSize is. */
1578 enum ENUM_PACKED gl_subgroup_size
1579 {
1580 /** Actual subgroup size, whatever that happens to be */
1581 SUBGROUP_SIZE_VARYING = 0,
1582
1583 /** Subgroup size must appear to be draw or dispatch-uniform
1584 *
1585 * This is the OpenGL behavior
1586 */
1587 SUBGROUP_SIZE_UNIFORM,
1588
1589 /** Subgroup size must appear to be the API advertised constant
1590 *
1591 * This is the default Vulkan 1.1 behavior
1592 */
1593 SUBGROUP_SIZE_API_CONSTANT,
1594
1595 /** Subgroup size must actually be the API advertised constant
1596 *
1597 * Not only must the subgroup size match the API advertised constant as
1598 * with SUBGROUP_SIZE_API_CONSTANT but it must also be dispatched such that
1599 * all the subgroups are full if there are enough invocations.
1600 */
1601 SUBGROUP_SIZE_FULL_SUBGROUPS,
1602
1603 /* These enums are specifically chosen so that the value of the enum is
1604 * also the subgroup size. If any new values are added, they must respect
1605 * this invariant.
1606 */
1607 SUBGROUP_SIZE_REQUIRE_4 = 4, /**< VK_EXT_subgroup_size_control */
1608 SUBGROUP_SIZE_REQUIRE_8 = 8, /**< VK_EXT_subgroup_size_control */
1609 SUBGROUP_SIZE_REQUIRE_16 = 16, /**< VK_EXT_subgroup_size_control */
1610 SUBGROUP_SIZE_REQUIRE_32 = 32, /**< VK_EXT_subgroup_size_control */
1611 SUBGROUP_SIZE_REQUIRE_64 = 64, /**< VK_EXT_subgroup_size_control */
1612 SUBGROUP_SIZE_REQUIRE_128 = 128, /**< VK_EXT_subgroup_size_control */
1613 };
1614
1615 /* Ordered from narrower to wider scope. */
1616 typedef enum {
1617 SCOPE_NONE,
1618 SCOPE_INVOCATION,
1619 SCOPE_SUBGROUP,
1620 SCOPE_SHADER_CALL,
1621 SCOPE_WORKGROUP,
1622 SCOPE_QUEUE_FAMILY,
1623 SCOPE_DEVICE,
1624 } mesa_scope;
1625
1626 const char *mesa_scope_name(mesa_scope scope);
1627
1628 /* This is defined here to be available to OpenCL */
1629 enum glsl_sampler_dim {
1630 GLSL_SAMPLER_DIM_1D = 0,
1631 GLSL_SAMPLER_DIM_2D,
1632 GLSL_SAMPLER_DIM_3D,
1633 GLSL_SAMPLER_DIM_CUBE,
1634 GLSL_SAMPLER_DIM_RECT,
1635 GLSL_SAMPLER_DIM_BUF,
1636 GLSL_SAMPLER_DIM_EXTERNAL,
1637 GLSL_SAMPLER_DIM_MS,
1638 GLSL_SAMPLER_DIM_SUBPASS, /* for vulkan input attachments */
1639 GLSL_SAMPLER_DIM_SUBPASS_MS, /* for multisampled vulkan input attachments */
1640 };
1641
1642 #ifdef __cplusplus
1643 } /* extern "C" */
1644 #endif
1645
1646 #endif /* SHADER_ENUMS_H */
1647