Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 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 | |
Kenneth Graunke | feafe70 | 2015-04-07 15:16:51 -0700 | [diff] [blame] | 26 | #ifndef SHADER_ENUMS_H |
| 27 | #define SHADER_ENUMS_H |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 28 | |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 29 | #ifdef __cplusplus |
| 30 | extern "C" { |
| 31 | #endif |
| 32 | |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 33 | /** |
Rob Clark | 972054f | 2016-03-29 10:49:03 -0400 | [diff] [blame] | 34 | * Shader stages. |
Kenneth Graunke | 4b27391 | 2015-04-07 15:18:43 -0700 | [diff] [blame] | 35 | * |
| 36 | * The order must match how shaders are ordered in the pipeline. |
| 37 | * The GLSL linker assumes that if i<j, then the j-th shader is |
| 38 | * executed later than the i-th shader. |
| 39 | */ |
| 40 | typedef enum |
| 41 | { |
| 42 | MESA_SHADER_VERTEX = 0, |
Fabian Bieler | a2af956 | 2014-03-07 10:19:09 +0100 | [diff] [blame] | 43 | MESA_SHADER_TESS_CTRL = 1, |
| 44 | MESA_SHADER_TESS_EVAL = 2, |
| 45 | MESA_SHADER_GEOMETRY = 3, |
| 46 | MESA_SHADER_FRAGMENT = 4, |
| 47 | MESA_SHADER_COMPUTE = 5, |
Kenneth Graunke | 4b27391 | 2015-04-07 15:18:43 -0700 | [diff] [blame] | 48 | } gl_shader_stage; |
| 49 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 50 | const char *gl_shader_stage_name(gl_shader_stage stage); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 51 | |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 52 | /** |
| 53 | * Translate a gl_shader_stage to a short shader stage name for debug |
| 54 | * printouts and error messages. |
| 55 | */ |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 56 | const char *_mesa_shader_stage_to_string(unsigned stage); |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 57 | |
| 58 | /** |
| 59 | * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS) |
| 60 | * for debug printouts and error messages. |
| 61 | */ |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 62 | const char *_mesa_shader_stage_to_abbrev(unsigned stage); |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 63 | |
Kenneth Graunke | 4b27391 | 2015-04-07 15:18:43 -0700 | [diff] [blame] | 64 | #define MESA_SHADER_STAGES (MESA_SHADER_COMPUTE + 1) |
| 65 | |
Jason Ekstrand | 47b4efc | 2015-08-31 14:55:49 -0700 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * Indexes for vertex program attributes. |
| 69 | * GL_NV_vertex_program aliases generic attributes over the conventional |
| 70 | * attributes. In GL_ARB_vertex_program shader the aliasing is optional. |
| 71 | * In GL_ARB_vertex_shader / OpenGL 2.0 the aliasing is disallowed (the |
| 72 | * generic attributes are distinct/separate). |
| 73 | */ |
| 74 | typedef enum |
| 75 | { |
| 76 | VERT_ATTRIB_POS = 0, |
| 77 | VERT_ATTRIB_WEIGHT = 1, |
| 78 | VERT_ATTRIB_NORMAL = 2, |
| 79 | VERT_ATTRIB_COLOR0 = 3, |
| 80 | VERT_ATTRIB_COLOR1 = 4, |
| 81 | VERT_ATTRIB_FOG = 5, |
| 82 | VERT_ATTRIB_COLOR_INDEX = 6, |
| 83 | VERT_ATTRIB_EDGEFLAG = 7, |
| 84 | VERT_ATTRIB_TEX0 = 8, |
| 85 | VERT_ATTRIB_TEX1 = 9, |
| 86 | VERT_ATTRIB_TEX2 = 10, |
| 87 | VERT_ATTRIB_TEX3 = 11, |
| 88 | VERT_ATTRIB_TEX4 = 12, |
| 89 | VERT_ATTRIB_TEX5 = 13, |
| 90 | VERT_ATTRIB_TEX6 = 14, |
| 91 | VERT_ATTRIB_TEX7 = 15, |
| 92 | VERT_ATTRIB_POINT_SIZE = 16, |
| 93 | VERT_ATTRIB_GENERIC0 = 17, |
| 94 | VERT_ATTRIB_GENERIC1 = 18, |
| 95 | VERT_ATTRIB_GENERIC2 = 19, |
| 96 | VERT_ATTRIB_GENERIC3 = 20, |
| 97 | VERT_ATTRIB_GENERIC4 = 21, |
| 98 | VERT_ATTRIB_GENERIC5 = 22, |
| 99 | VERT_ATTRIB_GENERIC6 = 23, |
| 100 | VERT_ATTRIB_GENERIC7 = 24, |
| 101 | VERT_ATTRIB_GENERIC8 = 25, |
| 102 | VERT_ATTRIB_GENERIC9 = 26, |
| 103 | VERT_ATTRIB_GENERIC10 = 27, |
| 104 | VERT_ATTRIB_GENERIC11 = 28, |
| 105 | VERT_ATTRIB_GENERIC12 = 29, |
| 106 | VERT_ATTRIB_GENERIC13 = 30, |
| 107 | VERT_ATTRIB_GENERIC14 = 31, |
| 108 | VERT_ATTRIB_GENERIC15 = 32, |
| 109 | VERT_ATTRIB_MAX = 33 |
| 110 | } gl_vert_attrib; |
| 111 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 112 | const char *gl_vert_attrib_name(gl_vert_attrib attrib); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 113 | |
Jason Ekstrand | 47b4efc | 2015-08-31 14:55:49 -0700 | [diff] [blame] | 114 | /** |
| 115 | * Symbolic constats to help iterating over |
| 116 | * specific blocks of vertex attributes. |
| 117 | * |
| 118 | * VERT_ATTRIB_FF |
| 119 | * includes all fixed function attributes as well as |
| 120 | * the aliased GL_NV_vertex_program shader attributes. |
| 121 | * VERT_ATTRIB_TEX |
| 122 | * include the classic texture coordinate attributes. |
| 123 | * Is a subset of VERT_ATTRIB_FF. |
| 124 | * VERT_ATTRIB_GENERIC |
| 125 | * include the OpenGL 2.0+ GLSL generic shader attributes. |
| 126 | * These alias the generic GL_ARB_vertex_shader attributes. |
| 127 | */ |
| 128 | #define VERT_ATTRIB_FF(i) (VERT_ATTRIB_POS + (i)) |
| 129 | #define VERT_ATTRIB_FF_MAX VERT_ATTRIB_GENERIC0 |
| 130 | |
| 131 | #define VERT_ATTRIB_TEX(i) (VERT_ATTRIB_TEX0 + (i)) |
| 132 | #define VERT_ATTRIB_TEX_MAX MAX_TEXTURE_COORD_UNITS |
| 133 | |
| 134 | #define VERT_ATTRIB_GENERIC(i) (VERT_ATTRIB_GENERIC0 + (i)) |
| 135 | #define VERT_ATTRIB_GENERIC_MAX MAX_VERTEX_GENERIC_ATTRIBS |
| 136 | |
| 137 | /** |
| 138 | * Bitflags for vertex attributes. |
| 139 | * These are used in bitfields in many places. |
| 140 | */ |
| 141 | /*@{*/ |
| 142 | #define VERT_BIT_POS BITFIELD64_BIT(VERT_ATTRIB_POS) |
| 143 | #define VERT_BIT_WEIGHT BITFIELD64_BIT(VERT_ATTRIB_WEIGHT) |
| 144 | #define VERT_BIT_NORMAL BITFIELD64_BIT(VERT_ATTRIB_NORMAL) |
| 145 | #define VERT_BIT_COLOR0 BITFIELD64_BIT(VERT_ATTRIB_COLOR0) |
| 146 | #define VERT_BIT_COLOR1 BITFIELD64_BIT(VERT_ATTRIB_COLOR1) |
| 147 | #define VERT_BIT_FOG BITFIELD64_BIT(VERT_ATTRIB_FOG) |
| 148 | #define VERT_BIT_COLOR_INDEX BITFIELD64_BIT(VERT_ATTRIB_COLOR_INDEX) |
| 149 | #define VERT_BIT_EDGEFLAG BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG) |
| 150 | #define VERT_BIT_TEX0 BITFIELD64_BIT(VERT_ATTRIB_TEX0) |
| 151 | #define VERT_BIT_TEX1 BITFIELD64_BIT(VERT_ATTRIB_TEX1) |
| 152 | #define VERT_BIT_TEX2 BITFIELD64_BIT(VERT_ATTRIB_TEX2) |
| 153 | #define VERT_BIT_TEX3 BITFIELD64_BIT(VERT_ATTRIB_TEX3) |
| 154 | #define VERT_BIT_TEX4 BITFIELD64_BIT(VERT_ATTRIB_TEX4) |
| 155 | #define VERT_BIT_TEX5 BITFIELD64_BIT(VERT_ATTRIB_TEX5) |
| 156 | #define VERT_BIT_TEX6 BITFIELD64_BIT(VERT_ATTRIB_TEX6) |
| 157 | #define VERT_BIT_TEX7 BITFIELD64_BIT(VERT_ATTRIB_TEX7) |
| 158 | #define VERT_BIT_POINT_SIZE BITFIELD64_BIT(VERT_ATTRIB_POINT_SIZE) |
| 159 | #define VERT_BIT_GENERIC0 BITFIELD64_BIT(VERT_ATTRIB_GENERIC0) |
| 160 | |
| 161 | #define VERT_BIT(i) BITFIELD64_BIT(i) |
| 162 | #define VERT_BIT_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_MAX) |
| 163 | |
| 164 | #define VERT_BIT_FF(i) VERT_BIT(i) |
| 165 | #define VERT_BIT_FF_ALL BITFIELD64_RANGE(0, VERT_ATTRIB_FF_MAX) |
| 166 | #define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i)) |
| 167 | #define VERT_BIT_TEX_ALL \ |
| 168 | BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX) |
| 169 | |
| 170 | #define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i)) |
| 171 | #define VERT_BIT_GENERIC_ALL \ |
| 172 | BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX) |
| 173 | /*@}*/ |
| 174 | |
| 175 | |
Kenneth Graunke | 4b27391 | 2015-04-07 15:18:43 -0700 | [diff] [blame] | 176 | /** |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 177 | * Indexes for vertex shader outputs, geometry shader inputs/outputs, and |
| 178 | * fragment shader inputs. |
| 179 | * |
| 180 | * Note that some of these values are not available to all pipeline stages. |
| 181 | * |
| 182 | * When this enum is updated, the following code must be updated too: |
| 183 | * - vertResults (in prog_print.c's arb_output_attrib_string()) |
| 184 | * - fragAttribs (in prog_print.c's arb_input_attrib_string()) |
| 185 | * - _mesa_varying_slot_in_fs() |
| 186 | */ |
| 187 | typedef enum |
| 188 | { |
| 189 | VARYING_SLOT_POS, |
| 190 | VARYING_SLOT_COL0, /* COL0 and COL1 must be contiguous */ |
| 191 | VARYING_SLOT_COL1, |
| 192 | VARYING_SLOT_FOGC, |
| 193 | VARYING_SLOT_TEX0, /* TEX0-TEX7 must be contiguous */ |
| 194 | VARYING_SLOT_TEX1, |
| 195 | VARYING_SLOT_TEX2, |
| 196 | VARYING_SLOT_TEX3, |
| 197 | VARYING_SLOT_TEX4, |
| 198 | VARYING_SLOT_TEX5, |
| 199 | VARYING_SLOT_TEX6, |
| 200 | VARYING_SLOT_TEX7, |
| 201 | VARYING_SLOT_PSIZ, /* Does not appear in FS */ |
| 202 | VARYING_SLOT_BFC0, /* Does not appear in FS */ |
| 203 | VARYING_SLOT_BFC1, /* Does not appear in FS */ |
| 204 | VARYING_SLOT_EDGE, /* Does not appear in FS */ |
| 205 | VARYING_SLOT_CLIP_VERTEX, /* Does not appear in FS */ |
| 206 | VARYING_SLOT_CLIP_DIST0, |
| 207 | VARYING_SLOT_CLIP_DIST1, |
| 208 | VARYING_SLOT_PRIMITIVE_ID, /* Does not appear in VS */ |
| 209 | VARYING_SLOT_LAYER, /* Appears as VS or GS output */ |
| 210 | VARYING_SLOT_VIEWPORT, /* Appears as VS or GS output */ |
| 211 | VARYING_SLOT_FACE, /* FS only */ |
| 212 | VARYING_SLOT_PNTC, /* FS only */ |
| 213 | VARYING_SLOT_TESS_LEVEL_OUTER, /* Only appears as TCS output. */ |
| 214 | VARYING_SLOT_TESS_LEVEL_INNER, /* Only appears as TCS output. */ |
| 215 | VARYING_SLOT_VAR0, /* First generic varying slot */ |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 216 | /* the remaining are simply for the benefit of gl_varying_slot_name() |
| 217 | * and not to be construed as an upper bound: |
| 218 | */ |
| 219 | VARYING_SLOT_VAR1, |
| 220 | VARYING_SLOT_VAR2, |
| 221 | VARYING_SLOT_VAR3, |
| 222 | VARYING_SLOT_VAR4, |
| 223 | VARYING_SLOT_VAR5, |
| 224 | VARYING_SLOT_VAR6, |
| 225 | VARYING_SLOT_VAR7, |
| 226 | VARYING_SLOT_VAR8, |
| 227 | VARYING_SLOT_VAR9, |
| 228 | VARYING_SLOT_VAR10, |
| 229 | VARYING_SLOT_VAR11, |
| 230 | VARYING_SLOT_VAR12, |
| 231 | VARYING_SLOT_VAR13, |
| 232 | VARYING_SLOT_VAR14, |
| 233 | VARYING_SLOT_VAR15, |
| 234 | VARYING_SLOT_VAR16, |
| 235 | VARYING_SLOT_VAR17, |
| 236 | VARYING_SLOT_VAR18, |
| 237 | VARYING_SLOT_VAR19, |
| 238 | VARYING_SLOT_VAR20, |
| 239 | VARYING_SLOT_VAR21, |
| 240 | VARYING_SLOT_VAR22, |
| 241 | VARYING_SLOT_VAR23, |
| 242 | VARYING_SLOT_VAR24, |
| 243 | VARYING_SLOT_VAR25, |
| 244 | VARYING_SLOT_VAR26, |
| 245 | VARYING_SLOT_VAR27, |
| 246 | VARYING_SLOT_VAR28, |
| 247 | VARYING_SLOT_VAR29, |
| 248 | VARYING_SLOT_VAR30, |
| 249 | VARYING_SLOT_VAR31, |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 250 | } gl_varying_slot; |
| 251 | |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 252 | |
| 253 | #define VARYING_SLOT_MAX (VARYING_SLOT_VAR0 + MAX_VARYING) |
| 254 | #define VARYING_SLOT_PATCH0 (VARYING_SLOT_MAX) |
| 255 | #define VARYING_SLOT_TESS_MAX (VARYING_SLOT_PATCH0 + MAX_VARYING) |
| 256 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 257 | const char *gl_varying_slot_name(gl_varying_slot slot); |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 258 | |
| 259 | /** |
| 260 | * Bitflags for varying slots. |
| 261 | */ |
| 262 | /*@{*/ |
| 263 | #define VARYING_BIT_POS BITFIELD64_BIT(VARYING_SLOT_POS) |
| 264 | #define VARYING_BIT_COL0 BITFIELD64_BIT(VARYING_SLOT_COL0) |
| 265 | #define VARYING_BIT_COL1 BITFIELD64_BIT(VARYING_SLOT_COL1) |
| 266 | #define VARYING_BIT_FOGC BITFIELD64_BIT(VARYING_SLOT_FOGC) |
| 267 | #define VARYING_BIT_TEX0 BITFIELD64_BIT(VARYING_SLOT_TEX0) |
| 268 | #define VARYING_BIT_TEX1 BITFIELD64_BIT(VARYING_SLOT_TEX1) |
| 269 | #define VARYING_BIT_TEX2 BITFIELD64_BIT(VARYING_SLOT_TEX2) |
| 270 | #define VARYING_BIT_TEX3 BITFIELD64_BIT(VARYING_SLOT_TEX3) |
| 271 | #define VARYING_BIT_TEX4 BITFIELD64_BIT(VARYING_SLOT_TEX4) |
| 272 | #define VARYING_BIT_TEX5 BITFIELD64_BIT(VARYING_SLOT_TEX5) |
| 273 | #define VARYING_BIT_TEX6 BITFIELD64_BIT(VARYING_SLOT_TEX6) |
| 274 | #define VARYING_BIT_TEX7 BITFIELD64_BIT(VARYING_SLOT_TEX7) |
| 275 | #define VARYING_BIT_TEX(U) BITFIELD64_BIT(VARYING_SLOT_TEX0 + (U)) |
| 276 | #define VARYING_BITS_TEX_ANY BITFIELD64_RANGE(VARYING_SLOT_TEX0, \ |
| 277 | MAX_TEXTURE_COORD_UNITS) |
| 278 | #define VARYING_BIT_PSIZ BITFIELD64_BIT(VARYING_SLOT_PSIZ) |
| 279 | #define VARYING_BIT_BFC0 BITFIELD64_BIT(VARYING_SLOT_BFC0) |
| 280 | #define VARYING_BIT_BFC1 BITFIELD64_BIT(VARYING_SLOT_BFC1) |
| 281 | #define VARYING_BIT_EDGE BITFIELD64_BIT(VARYING_SLOT_EDGE) |
| 282 | #define VARYING_BIT_CLIP_VERTEX BITFIELD64_BIT(VARYING_SLOT_CLIP_VERTEX) |
| 283 | #define VARYING_BIT_CLIP_DIST0 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST0) |
| 284 | #define VARYING_BIT_CLIP_DIST1 BITFIELD64_BIT(VARYING_SLOT_CLIP_DIST1) |
| 285 | #define VARYING_BIT_PRIMITIVE_ID BITFIELD64_BIT(VARYING_SLOT_PRIMITIVE_ID) |
| 286 | #define VARYING_BIT_LAYER BITFIELD64_BIT(VARYING_SLOT_LAYER) |
| 287 | #define VARYING_BIT_VIEWPORT BITFIELD64_BIT(VARYING_SLOT_VIEWPORT) |
| 288 | #define VARYING_BIT_FACE BITFIELD64_BIT(VARYING_SLOT_FACE) |
| 289 | #define VARYING_BIT_PNTC BITFIELD64_BIT(VARYING_SLOT_PNTC) |
| 290 | #define VARYING_BIT_TESS_LEVEL_OUTER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_OUTER) |
| 291 | #define VARYING_BIT_TESS_LEVEL_INNER BITFIELD64_BIT(VARYING_SLOT_TESS_LEVEL_INNER) |
| 292 | #define VARYING_BIT_VAR(V) BITFIELD64_BIT(VARYING_SLOT_VAR0 + (V)) |
| 293 | /*@}*/ |
| 294 | |
| 295 | /** |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 296 | * Bitflags for system values. |
| 297 | */ |
| 298 | #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID) |
| 299 | #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS) |
| 300 | #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN) |
Jordan Justen | bf8d6e5 | 2014-10-10 08:28:24 -0700 | [diff] [blame] | 301 | #define SYSTEM_BIT_LOCAL_INVOCATION_ID ((uint64_t)1 << SYSTEM_VALUE_LOCAL_INVOCATION_ID) |
| 302 | |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 303 | /** |
| 304 | * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be |
| 305 | * one of these values. If a NIR variable's mode is nir_var_system_value, it |
| 306 | * will be one of these values. |
| 307 | */ |
| 308 | typedef enum |
| 309 | { |
| 310 | /** |
| 311 | * \name Vertex shader system values |
| 312 | */ |
| 313 | /*@{*/ |
| 314 | /** |
| 315 | * OpenGL-style vertex ID. |
| 316 | * |
| 317 | * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the |
| 318 | * OpenGL 3.3 core profile spec says: |
| 319 | * |
| 320 | * "gl_VertexID holds the integer index i implicitly passed by |
| 321 | * DrawArrays or one of the other drawing commands defined in section |
| 322 | * 2.8.3." |
| 323 | * |
| 324 | * Section 2.8.3 (Drawing Commands) of the same spec says: |
| 325 | * |
| 326 | * "The commands....are equivalent to the commands with the same base |
| 327 | * name (without the BaseVertex suffix), except that the ith element |
| 328 | * transferred by the corresponding draw call will be taken from |
| 329 | * element indices[i] + basevertex of each enabled array." |
| 330 | * |
| 331 | * Additionally, the overview in the GL_ARB_shader_draw_parameters spec |
| 332 | * says: |
| 333 | * |
| 334 | * "In unextended GL, vertex shaders have inputs named gl_VertexID and |
| 335 | * gl_InstanceID, which contain, respectively the index of the vertex |
| 336 | * and instance. The value of gl_VertexID is the implicitly passed |
| 337 | * index of the vertex being processed, which includes the value of |
| 338 | * baseVertex, for those commands that accept it." |
| 339 | * |
| 340 | * gl_VertexID gets basevertex added in. This differs from DirectX where |
| 341 | * SV_VertexID does \b not get basevertex added in. |
| 342 | * |
| 343 | * \note |
| 344 | * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be |
| 345 | * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus |
| 346 | * \c SYSTEM_VALUE_BASE_VERTEX. |
| 347 | * |
| 348 | * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX |
| 349 | */ |
| 350 | SYSTEM_VALUE_VERTEX_ID, |
| 351 | |
| 352 | /** |
| 353 | * Instanced ID as supplied to gl_InstanceID |
| 354 | * |
| 355 | * Values assigned to gl_InstanceID always begin with zero, regardless of |
| 356 | * the value of baseinstance. |
| 357 | * |
| 358 | * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec |
| 359 | * says: |
| 360 | * |
| 361 | * "gl_InstanceID holds the integer instance number of the current |
| 362 | * primitive in an instanced draw call (see section 10.5)." |
| 363 | * |
| 364 | * Through a big chain of pseudocode, section 10.5 describes that |
| 365 | * baseinstance is not counted by gl_InstanceID. In that section, notice |
| 366 | * |
| 367 | * "If an enabled vertex attribute array is instanced (it has a |
| 368 | * non-zero divisor as specified by VertexAttribDivisor), the element |
| 369 | * index that is transferred to the GL, for all vertices, is given by |
| 370 | * |
| 371 | * floor(instance/divisor) + baseinstance |
| 372 | * |
| 373 | * If an array corresponding to an attribute required by a vertex |
| 374 | * shader is not enabled, then the corresponding element is taken from |
| 375 | * the current attribute state (see section 10.2)." |
| 376 | * |
| 377 | * Note that baseinstance is \b not included in the value of instance. |
| 378 | */ |
| 379 | SYSTEM_VALUE_INSTANCE_ID, |
| 380 | |
| 381 | /** |
Jason Ekstrand | 22836db | 2016-03-25 10:50:11 -0700 | [diff] [blame] | 382 | * Vulkan InstanceIndex. |
| 383 | * |
| 384 | * InstanceIndex = gl_InstanceID + gl_BaseInstance |
| 385 | */ |
| 386 | SYSTEM_VALUE_INSTANCE_INDEX, |
| 387 | |
| 388 | /** |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 389 | * DirectX-style vertex ID. |
| 390 | * |
| 391 | * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include |
| 392 | * the value of basevertex. |
| 393 | * |
| 394 | * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX |
| 395 | */ |
| 396 | SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, |
| 397 | |
| 398 | /** |
| 399 | * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar |
| 400 | * functions. |
| 401 | * |
| 402 | * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE |
| 403 | */ |
| 404 | SYSTEM_VALUE_BASE_VERTEX, |
Kristian Høgsberg Kristensen | 1a59aea | 2015-12-10 12:07:43 -0800 | [diff] [blame] | 405 | |
| 406 | /** |
| 407 | * Value of \c baseinstance passed to instanced draw entry points |
| 408 | * |
| 409 | * \sa SYSTEM_VALUE_INSTANCE_ID |
| 410 | */ |
| 411 | SYSTEM_VALUE_BASE_INSTANCE, |
| 412 | |
| 413 | /** |
| 414 | * From _ARB_shader_draw_parameters: |
| 415 | * |
| 416 | * "Additionally, this extension adds a further built-in variable, |
| 417 | * gl_DrawID to the shading language. This variable contains the index |
| 418 | * of the draw currently being processed by a Multi* variant of a |
| 419 | * drawing command (such as MultiDrawElements or |
| 420 | * MultiDrawArraysIndirect)." |
| 421 | * |
| 422 | * If GL_ARB_multi_draw_indirect is not supported, this is always 0. |
| 423 | */ |
| 424 | SYSTEM_VALUE_DRAW_ID, |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 425 | /*@}*/ |
| 426 | |
| 427 | /** |
| 428 | * \name Geometry shader system values |
| 429 | */ |
| 430 | /*@{*/ |
Fabian Bieler | 1036b02 | 2014-03-20 22:41:40 +0100 | [diff] [blame] | 431 | SYSTEM_VALUE_INVOCATION_ID, /**< (Also in Tessellation Control shader) */ |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 432 | /*@}*/ |
| 433 | |
| 434 | /** |
| 435 | * \name Fragment shader system values |
| 436 | */ |
| 437 | /*@{*/ |
Marek Olšák | 4191c1a | 2016-01-02 20:16:16 +0100 | [diff] [blame] | 438 | SYSTEM_VALUE_FRAG_COORD, |
| 439 | SYSTEM_VALUE_FRONT_FACE, |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 440 | SYSTEM_VALUE_SAMPLE_ID, |
| 441 | SYSTEM_VALUE_SAMPLE_POS, |
| 442 | SYSTEM_VALUE_SAMPLE_MASK_IN, |
Ilia Mirkin | 2074831 | 2015-09-14 16:13:43 -0400 | [diff] [blame] | 443 | SYSTEM_VALUE_HELPER_INVOCATION, |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 444 | /*@}*/ |
| 445 | |
Fabian Bieler | 1036b02 | 2014-03-20 22:41:40 +0100 | [diff] [blame] | 446 | /** |
| 447 | * \name Tessellation Evaluation shader system values |
| 448 | */ |
| 449 | /*@{*/ |
| 450 | SYSTEM_VALUE_TESS_COORD, |
| 451 | SYSTEM_VALUE_VERTICES_IN, /**< Tessellation vertices in input patch */ |
Kenneth Graunke | 476e6d7 | 2015-09-23 15:40:33 -0700 | [diff] [blame] | 452 | SYSTEM_VALUE_PRIMITIVE_ID, |
Fabian Bieler | 1036b02 | 2014-03-20 22:41:40 +0100 | [diff] [blame] | 453 | SYSTEM_VALUE_TESS_LEVEL_OUTER, /**< TES input */ |
| 454 | SYSTEM_VALUE_TESS_LEVEL_INNER, /**< TES input */ |
| 455 | /*@}*/ |
| 456 | |
Jordan Justen | bf8d6e5 | 2014-10-10 08:28:24 -0700 | [diff] [blame] | 457 | /** |
| 458 | * \name Compute shader system values |
| 459 | */ |
| 460 | /*@{*/ |
| 461 | SYSTEM_VALUE_LOCAL_INVOCATION_ID, |
Jason Ekstrand | 3910314 | 2016-03-25 10:51:23 -0700 | [diff] [blame^] | 462 | SYSTEM_VALUE_LOCAL_INVOCATION_INDEX, |
| 463 | SYSTEM_VALUE_GLOBAL_INVOCATION_ID, |
Jordan Justen | f5bb5a1 | 2014-10-10 08:28:24 -0700 | [diff] [blame] | 464 | SYSTEM_VALUE_WORK_GROUP_ID, |
Jordan Justen | f6ae914 | 2015-08-20 15:56:53 -0700 | [diff] [blame] | 465 | SYSTEM_VALUE_NUM_WORK_GROUPS, |
Jordan Justen | bf8d6e5 | 2014-10-10 08:28:24 -0700 | [diff] [blame] | 466 | /*@}*/ |
| 467 | |
Rob Clark | 4a121e1 | 2015-09-11 17:01:23 -0400 | [diff] [blame] | 468 | /** |
| 469 | * Driver internal vertex-count, used (for example) for drivers to |
| 470 | * calculate stride for stream-out outputs. Not externally visible. |
| 471 | */ |
| 472 | SYSTEM_VALUE_VERTEX_CNT, |
| 473 | |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 474 | SYSTEM_VALUE_MAX /**< Number of values */ |
| 475 | } gl_system_value; |
| 476 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 477 | const char *gl_system_value_name(gl_system_value sysval); |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 478 | |
| 479 | /** |
| 480 | * The possible interpolation qualifiers that can be applied to a fragment |
| 481 | * shader input in GLSL. |
| 482 | * |
| 483 | * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the |
| 484 | * gl_fragment_program data structure to 0 causes the default behavior. |
| 485 | */ |
| 486 | enum glsl_interp_qualifier |
| 487 | { |
| 488 | INTERP_QUALIFIER_NONE = 0, |
| 489 | INTERP_QUALIFIER_SMOOTH, |
| 490 | INTERP_QUALIFIER_FLAT, |
| 491 | INTERP_QUALIFIER_NOPERSPECTIVE, |
| 492 | INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */ |
| 493 | }; |
| 494 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 495 | const char *glsl_interp_qualifier_name(enum glsl_interp_qualifier qual); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 496 | |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 497 | /** |
| 498 | * Fragment program results |
| 499 | */ |
| 500 | typedef enum |
| 501 | { |
| 502 | FRAG_RESULT_DEPTH = 0, |
| 503 | FRAG_RESULT_STENCIL = 1, |
| 504 | /* If a single color should be written to all render targets, this |
| 505 | * register is written. No FRAG_RESULT_DATAn will be written. |
| 506 | */ |
| 507 | FRAG_RESULT_COLOR = 2, |
| 508 | FRAG_RESULT_SAMPLE_MASK = 3, |
| 509 | |
| 510 | /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] |
| 511 | * or ARB_fragment_program fragment.color[n]) color results. If |
| 512 | * any are written, FRAG_RESULT_COLOR will not be written. |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 513 | * FRAG_RESULT_DATA1 and up are simply for the benefit of |
| 514 | * gl_frag_result_name() and not to be construed as an upper bound |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 515 | */ |
| 516 | FRAG_RESULT_DATA0 = 4, |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 517 | FRAG_RESULT_DATA1, |
| 518 | FRAG_RESULT_DATA2, |
| 519 | FRAG_RESULT_DATA3, |
| 520 | FRAG_RESULT_DATA4, |
| 521 | FRAG_RESULT_DATA5, |
| 522 | FRAG_RESULT_DATA6, |
| 523 | FRAG_RESULT_DATA7, |
Eric Anholt | 6ff3341 | 2015-08-04 10:43:58 -0700 | [diff] [blame] | 524 | } gl_frag_result; |
Eric Anholt | a3a07d4 | 2015-03-25 12:58:51 -0700 | [diff] [blame] | 525 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 526 | const char *gl_frag_result_name(gl_frag_result result); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 527 | |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 528 | #define FRAG_RESULT_MAX (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) |
| 529 | |
Jason Ekstrand | 1661947 | 2015-10-08 15:59:56 -0700 | [diff] [blame] | 530 | /** |
| 531 | * \brief Layout qualifiers for gl_FragDepth. |
| 532 | * |
| 533 | * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with |
| 534 | * a layout qualifier. |
| 535 | * |
| 536 | * \see enum ir_depth_layout |
| 537 | */ |
| 538 | enum gl_frag_depth_layout |
| 539 | { |
| 540 | FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ |
| 541 | FRAG_DEPTH_LAYOUT_ANY, |
| 542 | FRAG_DEPTH_LAYOUT_GREATER, |
| 543 | FRAG_DEPTH_LAYOUT_LESS, |
| 544 | FRAG_DEPTH_LAYOUT_UNCHANGED |
| 545 | }; |
| 546 | |
Ilia Mirkin | 35f8488 | 2015-12-28 14:03:50 -0500 | [diff] [blame] | 547 | /** |
| 548 | * \brief Buffer access qualifiers |
| 549 | */ |
| 550 | enum gl_buffer_access_qualifier |
| 551 | { |
| 552 | ACCESS_COHERENT = 1, |
| 553 | ACCESS_RESTRICT = 2, |
| 554 | ACCESS_VOLATILE = 4, |
| 555 | }; |
| 556 | |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 557 | #ifdef __cplusplus |
| 558 | } /* extern "C" */ |
| 559 | #endif |
| 560 | |
Kenneth Graunke | feafe70 | 2015-04-07 15:16:51 -0700 | [diff] [blame] | 561 | #endif /* SHADER_ENUMS_H */ |