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 | |
| 29 | /** |
| 30 | * Bitflags for system values. |
| 31 | */ |
| 32 | #define SYSTEM_BIT_SAMPLE_ID ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_ID) |
| 33 | #define SYSTEM_BIT_SAMPLE_POS ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_POS) |
| 34 | #define SYSTEM_BIT_SAMPLE_MASK_IN ((uint64_t)1 << SYSTEM_VALUE_SAMPLE_MASK_IN) |
| 35 | /** |
| 36 | * If the gl_register_file is PROGRAM_SYSTEM_VALUE, the register index will be |
| 37 | * one of these values. If a NIR variable's mode is nir_var_system_value, it |
| 38 | * will be one of these values. |
| 39 | */ |
| 40 | typedef enum |
| 41 | { |
| 42 | /** |
| 43 | * \name Vertex shader system values |
| 44 | */ |
| 45 | /*@{*/ |
| 46 | /** |
| 47 | * OpenGL-style vertex ID. |
| 48 | * |
| 49 | * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the |
| 50 | * OpenGL 3.3 core profile spec says: |
| 51 | * |
| 52 | * "gl_VertexID holds the integer index i implicitly passed by |
| 53 | * DrawArrays or one of the other drawing commands defined in section |
| 54 | * 2.8.3." |
| 55 | * |
| 56 | * Section 2.8.3 (Drawing Commands) of the same spec says: |
| 57 | * |
| 58 | * "The commands....are equivalent to the commands with the same base |
| 59 | * name (without the BaseVertex suffix), except that the ith element |
| 60 | * transferred by the corresponding draw call will be taken from |
| 61 | * element indices[i] + basevertex of each enabled array." |
| 62 | * |
| 63 | * Additionally, the overview in the GL_ARB_shader_draw_parameters spec |
| 64 | * says: |
| 65 | * |
| 66 | * "In unextended GL, vertex shaders have inputs named gl_VertexID and |
| 67 | * gl_InstanceID, which contain, respectively the index of the vertex |
| 68 | * and instance. The value of gl_VertexID is the implicitly passed |
| 69 | * index of the vertex being processed, which includes the value of |
| 70 | * baseVertex, for those commands that accept it." |
| 71 | * |
| 72 | * gl_VertexID gets basevertex added in. This differs from DirectX where |
| 73 | * SV_VertexID does \b not get basevertex added in. |
| 74 | * |
| 75 | * \note |
| 76 | * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be |
| 77 | * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus |
| 78 | * \c SYSTEM_VALUE_BASE_VERTEX. |
| 79 | * |
| 80 | * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX |
| 81 | */ |
| 82 | SYSTEM_VALUE_VERTEX_ID, |
| 83 | |
| 84 | /** |
| 85 | * Instanced ID as supplied to gl_InstanceID |
| 86 | * |
| 87 | * Values assigned to gl_InstanceID always begin with zero, regardless of |
| 88 | * the value of baseinstance. |
| 89 | * |
| 90 | * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec |
| 91 | * says: |
| 92 | * |
| 93 | * "gl_InstanceID holds the integer instance number of the current |
| 94 | * primitive in an instanced draw call (see section 10.5)." |
| 95 | * |
| 96 | * Through a big chain of pseudocode, section 10.5 describes that |
| 97 | * baseinstance is not counted by gl_InstanceID. In that section, notice |
| 98 | * |
| 99 | * "If an enabled vertex attribute array is instanced (it has a |
| 100 | * non-zero divisor as specified by VertexAttribDivisor), the element |
| 101 | * index that is transferred to the GL, for all vertices, is given by |
| 102 | * |
| 103 | * floor(instance/divisor) + baseinstance |
| 104 | * |
| 105 | * If an array corresponding to an attribute required by a vertex |
| 106 | * shader is not enabled, then the corresponding element is taken from |
| 107 | * the current attribute state (see section 10.2)." |
| 108 | * |
| 109 | * Note that baseinstance is \b not included in the value of instance. |
| 110 | */ |
| 111 | SYSTEM_VALUE_INSTANCE_ID, |
| 112 | |
| 113 | /** |
| 114 | * DirectX-style vertex ID. |
| 115 | * |
| 116 | * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include |
| 117 | * the value of basevertex. |
| 118 | * |
| 119 | * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX |
| 120 | */ |
| 121 | SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, |
| 122 | |
| 123 | /** |
| 124 | * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar |
| 125 | * functions. |
| 126 | * |
| 127 | * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE |
| 128 | */ |
| 129 | SYSTEM_VALUE_BASE_VERTEX, |
| 130 | /*@}*/ |
| 131 | |
| 132 | /** |
| 133 | * \name Geometry shader system values |
| 134 | */ |
| 135 | /*@{*/ |
| 136 | SYSTEM_VALUE_INVOCATION_ID, |
| 137 | /*@}*/ |
| 138 | |
| 139 | /** |
| 140 | * \name Fragment shader system values |
| 141 | */ |
| 142 | /*@{*/ |
| 143 | SYSTEM_VALUE_FRONT_FACE, /**< (not done yet) */ |
| 144 | SYSTEM_VALUE_SAMPLE_ID, |
| 145 | SYSTEM_VALUE_SAMPLE_POS, |
| 146 | SYSTEM_VALUE_SAMPLE_MASK_IN, |
| 147 | /*@}*/ |
| 148 | |
| 149 | SYSTEM_VALUE_MAX /**< Number of values */ |
| 150 | } gl_system_value; |
| 151 | |
| 152 | |
| 153 | /** |
| 154 | * The possible interpolation qualifiers that can be applied to a fragment |
| 155 | * shader input in GLSL. |
| 156 | * |
| 157 | * Note: INTERP_QUALIFIER_NONE must be 0 so that memsetting the |
| 158 | * gl_fragment_program data structure to 0 causes the default behavior. |
| 159 | */ |
| 160 | enum glsl_interp_qualifier |
| 161 | { |
| 162 | INTERP_QUALIFIER_NONE = 0, |
| 163 | INTERP_QUALIFIER_SMOOTH, |
| 164 | INTERP_QUALIFIER_FLAT, |
| 165 | INTERP_QUALIFIER_NOPERSPECTIVE, |
| 166 | INTERP_QUALIFIER_COUNT /**< Number of interpolation qualifiers */ |
| 167 | }; |
| 168 | |
| 169 | |
Kenneth Graunke | feafe70 | 2015-04-07 15:16:51 -0700 | [diff] [blame^] | 170 | #endif /* SHADER_ENUMS_H */ |