Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Mesa 3-D graphics library |
| 3 | * |
| 4 | * Copyright © 2015 Red Hat |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice (including the next |
| 14 | * paragraph) shall be included in all copies or substantial portions of the |
| 15 | * Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 18 | * 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 OTHER |
| 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
| 23 | * IN THE SOFTWARE. |
| 24 | * |
| 25 | * Authors: |
| 26 | * Rob Clark <robclark@freedesktop.org> |
| 27 | */ |
| 28 | |
Rob Clark | c9b982b | 2015-10-08 18:19:00 -0400 | [diff] [blame] | 29 | #include "shader_enums.h" |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 30 | #include "util/macros.h" |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 31 | #include "mesa/main/config.h" |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 32 | |
| 33 | #define ENUM(x) [x] = #x |
| 34 | #define NAME(val) ((((val) < ARRAY_SIZE(names)) && names[(val)]) ? names[(val)] : "UNKNOWN") |
| 35 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 36 | const char * |
| 37 | gl_shader_stage_name(gl_shader_stage stage) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 38 | { |
| 39 | static const char *names[] = { |
| 40 | ENUM(MESA_SHADER_VERTEX), |
| 41 | ENUM(MESA_SHADER_TESS_CTRL), |
| 42 | ENUM(MESA_SHADER_TESS_EVAL), |
| 43 | ENUM(MESA_SHADER_GEOMETRY), |
| 44 | ENUM(MESA_SHADER_FRAGMENT), |
| 45 | ENUM(MESA_SHADER_COMPUTE), |
| 46 | }; |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 47 | STATIC_ASSERT(ARRAY_SIZE(names) == MESA_SHADER_STAGES); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 48 | return NAME(stage); |
| 49 | } |
| 50 | |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 51 | /** |
| 52 | * Translate a gl_shader_stage to a short shader stage name for debug |
| 53 | * printouts and error messages. |
| 54 | */ |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 55 | const char * |
| 56 | _mesa_shader_stage_to_string(unsigned stage) |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 57 | { |
| 58 | switch (stage) { |
| 59 | case MESA_SHADER_VERTEX: return "vertex"; |
| 60 | case MESA_SHADER_FRAGMENT: return "fragment"; |
| 61 | case MESA_SHADER_GEOMETRY: return "geometry"; |
| 62 | case MESA_SHADER_COMPUTE: return "compute"; |
Kenneth Graunke | 4fc0185 | 2015-12-31 16:28:08 -0800 | [diff] [blame] | 63 | case MESA_SHADER_TESS_CTRL: return "tessellation control"; |
| 64 | case MESA_SHADER_TESS_EVAL: return "tessellation evaluation"; |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | unreachable("Unknown shader stage."); |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS) |
| 72 | * for debug printouts and error messages. |
| 73 | */ |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 74 | const char * |
| 75 | _mesa_shader_stage_to_abbrev(unsigned stage) |
Kristian Høgsberg Kristensen | 82ad571 | 2016-01-08 12:35:48 -0800 | [diff] [blame] | 76 | { |
| 77 | switch (stage) { |
| 78 | case MESA_SHADER_VERTEX: return "VS"; |
| 79 | case MESA_SHADER_FRAGMENT: return "FS"; |
| 80 | case MESA_SHADER_GEOMETRY: return "GS"; |
| 81 | case MESA_SHADER_COMPUTE: return "CS"; |
| 82 | case MESA_SHADER_TESS_CTRL: return "TCS"; |
| 83 | case MESA_SHADER_TESS_EVAL: return "TES"; |
| 84 | } |
| 85 | |
| 86 | unreachable("Unknown shader stage."); |
| 87 | } |
| 88 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 89 | const char * |
| 90 | gl_vert_attrib_name(gl_vert_attrib attrib) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 91 | { |
| 92 | static const char *names[] = { |
| 93 | ENUM(VERT_ATTRIB_POS), |
| 94 | ENUM(VERT_ATTRIB_WEIGHT), |
| 95 | ENUM(VERT_ATTRIB_NORMAL), |
| 96 | ENUM(VERT_ATTRIB_COLOR0), |
| 97 | ENUM(VERT_ATTRIB_COLOR1), |
| 98 | ENUM(VERT_ATTRIB_FOG), |
| 99 | ENUM(VERT_ATTRIB_COLOR_INDEX), |
| 100 | ENUM(VERT_ATTRIB_EDGEFLAG), |
| 101 | ENUM(VERT_ATTRIB_TEX0), |
| 102 | ENUM(VERT_ATTRIB_TEX1), |
| 103 | ENUM(VERT_ATTRIB_TEX2), |
| 104 | ENUM(VERT_ATTRIB_TEX3), |
| 105 | ENUM(VERT_ATTRIB_TEX4), |
| 106 | ENUM(VERT_ATTRIB_TEX5), |
| 107 | ENUM(VERT_ATTRIB_TEX6), |
| 108 | ENUM(VERT_ATTRIB_TEX7), |
| 109 | ENUM(VERT_ATTRIB_POINT_SIZE), |
| 110 | ENUM(VERT_ATTRIB_GENERIC0), |
| 111 | ENUM(VERT_ATTRIB_GENERIC1), |
| 112 | ENUM(VERT_ATTRIB_GENERIC2), |
| 113 | ENUM(VERT_ATTRIB_GENERIC3), |
| 114 | ENUM(VERT_ATTRIB_GENERIC4), |
| 115 | ENUM(VERT_ATTRIB_GENERIC5), |
| 116 | ENUM(VERT_ATTRIB_GENERIC6), |
| 117 | ENUM(VERT_ATTRIB_GENERIC7), |
| 118 | ENUM(VERT_ATTRIB_GENERIC8), |
| 119 | ENUM(VERT_ATTRIB_GENERIC9), |
| 120 | ENUM(VERT_ATTRIB_GENERIC10), |
| 121 | ENUM(VERT_ATTRIB_GENERIC11), |
| 122 | ENUM(VERT_ATTRIB_GENERIC12), |
| 123 | ENUM(VERT_ATTRIB_GENERIC13), |
| 124 | ENUM(VERT_ATTRIB_GENERIC14), |
| 125 | ENUM(VERT_ATTRIB_GENERIC15), |
| 126 | }; |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 127 | STATIC_ASSERT(ARRAY_SIZE(names) == VERT_ATTRIB_MAX); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 128 | return NAME(attrib); |
| 129 | } |
| 130 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 131 | const char * |
| 132 | gl_varying_slot_name(gl_varying_slot slot) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 133 | { |
| 134 | static const char *names[] = { |
| 135 | ENUM(VARYING_SLOT_POS), |
| 136 | ENUM(VARYING_SLOT_COL0), |
| 137 | ENUM(VARYING_SLOT_COL1), |
| 138 | ENUM(VARYING_SLOT_FOGC), |
| 139 | ENUM(VARYING_SLOT_TEX0), |
| 140 | ENUM(VARYING_SLOT_TEX1), |
| 141 | ENUM(VARYING_SLOT_TEX2), |
| 142 | ENUM(VARYING_SLOT_TEX3), |
| 143 | ENUM(VARYING_SLOT_TEX4), |
| 144 | ENUM(VARYING_SLOT_TEX5), |
| 145 | ENUM(VARYING_SLOT_TEX6), |
| 146 | ENUM(VARYING_SLOT_TEX7), |
| 147 | ENUM(VARYING_SLOT_PSIZ), |
| 148 | ENUM(VARYING_SLOT_BFC0), |
| 149 | ENUM(VARYING_SLOT_BFC1), |
| 150 | ENUM(VARYING_SLOT_EDGE), |
| 151 | ENUM(VARYING_SLOT_CLIP_VERTEX), |
| 152 | ENUM(VARYING_SLOT_CLIP_DIST0), |
| 153 | ENUM(VARYING_SLOT_CLIP_DIST1), |
| 154 | ENUM(VARYING_SLOT_PRIMITIVE_ID), |
| 155 | ENUM(VARYING_SLOT_LAYER), |
| 156 | ENUM(VARYING_SLOT_VIEWPORT), |
| 157 | ENUM(VARYING_SLOT_FACE), |
| 158 | ENUM(VARYING_SLOT_PNTC), |
| 159 | ENUM(VARYING_SLOT_TESS_LEVEL_OUTER), |
| 160 | ENUM(VARYING_SLOT_TESS_LEVEL_INNER), |
| 161 | ENUM(VARYING_SLOT_VAR0), |
| 162 | ENUM(VARYING_SLOT_VAR1), |
| 163 | ENUM(VARYING_SLOT_VAR2), |
| 164 | ENUM(VARYING_SLOT_VAR3), |
| 165 | ENUM(VARYING_SLOT_VAR4), |
| 166 | ENUM(VARYING_SLOT_VAR5), |
| 167 | ENUM(VARYING_SLOT_VAR6), |
| 168 | ENUM(VARYING_SLOT_VAR7), |
| 169 | ENUM(VARYING_SLOT_VAR8), |
| 170 | ENUM(VARYING_SLOT_VAR9), |
| 171 | ENUM(VARYING_SLOT_VAR10), |
| 172 | ENUM(VARYING_SLOT_VAR11), |
| 173 | ENUM(VARYING_SLOT_VAR12), |
| 174 | ENUM(VARYING_SLOT_VAR13), |
| 175 | ENUM(VARYING_SLOT_VAR14), |
| 176 | ENUM(VARYING_SLOT_VAR15), |
| 177 | ENUM(VARYING_SLOT_VAR16), |
| 178 | ENUM(VARYING_SLOT_VAR17), |
| 179 | ENUM(VARYING_SLOT_VAR18), |
| 180 | ENUM(VARYING_SLOT_VAR19), |
| 181 | ENUM(VARYING_SLOT_VAR20), |
| 182 | ENUM(VARYING_SLOT_VAR21), |
| 183 | ENUM(VARYING_SLOT_VAR22), |
| 184 | ENUM(VARYING_SLOT_VAR23), |
| 185 | ENUM(VARYING_SLOT_VAR24), |
| 186 | ENUM(VARYING_SLOT_VAR25), |
| 187 | ENUM(VARYING_SLOT_VAR26), |
| 188 | ENUM(VARYING_SLOT_VAR27), |
| 189 | ENUM(VARYING_SLOT_VAR28), |
| 190 | ENUM(VARYING_SLOT_VAR29), |
| 191 | ENUM(VARYING_SLOT_VAR30), |
| 192 | ENUM(VARYING_SLOT_VAR31), |
| 193 | }; |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 194 | STATIC_ASSERT(ARRAY_SIZE(names) == VARYING_SLOT_MAX); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 195 | return NAME(slot); |
| 196 | } |
| 197 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 198 | const char * |
| 199 | gl_system_value_name(gl_system_value sysval) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 200 | { |
| 201 | static const char *names[] = { |
| 202 | ENUM(SYSTEM_VALUE_VERTEX_ID), |
| 203 | ENUM(SYSTEM_VALUE_INSTANCE_ID), |
Jason Ekstrand | 22836db | 2016-03-25 10:50:11 -0700 | [diff] [blame] | 204 | ENUM(SYSTEM_VALUE_INSTANCE_INDEX), |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 205 | ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE), |
| 206 | ENUM(SYSTEM_VALUE_BASE_VERTEX), |
| 207 | ENUM(SYSTEM_VALUE_INVOCATION_ID), |
| 208 | ENUM(SYSTEM_VALUE_FRONT_FACE), |
| 209 | ENUM(SYSTEM_VALUE_SAMPLE_ID), |
| 210 | ENUM(SYSTEM_VALUE_SAMPLE_POS), |
| 211 | ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN), |
| 212 | ENUM(SYSTEM_VALUE_TESS_COORD), |
| 213 | ENUM(SYSTEM_VALUE_VERTICES_IN), |
| 214 | ENUM(SYSTEM_VALUE_PRIMITIVE_ID), |
| 215 | ENUM(SYSTEM_VALUE_TESS_LEVEL_OUTER), |
| 216 | ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER), |
| 217 | ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID), |
Jason Ekstrand | 3910314 | 2016-03-25 10:51:23 -0700 | [diff] [blame] | 218 | ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX), |
| 219 | ENUM(SYSTEM_VALUE_GLOBAL_INVOCATION_ID), |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 220 | ENUM(SYSTEM_VALUE_WORK_GROUP_ID), |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 221 | ENUM(SYSTEM_VALUE_NUM_WORK_GROUPS), |
Rob Clark | 4a121e1 | 2015-09-11 17:01:23 -0400 | [diff] [blame] | 222 | ENUM(SYSTEM_VALUE_VERTEX_CNT), |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 223 | }; |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 224 | STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 225 | return NAME(sysval); |
| 226 | } |
| 227 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 228 | const char * |
Kenneth Graunke | ac1181f | 2016-07-07 02:02:38 -0700 | [diff] [blame] | 229 | glsl_interp_mode_name(enum glsl_interp_mode qual) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 230 | { |
| 231 | static const char *names[] = { |
Kenneth Graunke | ac1181f | 2016-07-07 02:02:38 -0700 | [diff] [blame] | 232 | ENUM(INTERP_MODE_NONE), |
| 233 | ENUM(INTERP_MODE_SMOOTH), |
| 234 | ENUM(INTERP_MODE_FLAT), |
| 235 | ENUM(INTERP_MODE_NOPERSPECTIVE), |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 236 | }; |
Kenneth Graunke | ac1181f | 2016-07-07 02:02:38 -0700 | [diff] [blame] | 237 | STATIC_ASSERT(ARRAY_SIZE(names) == INTERP_MODE_COUNT); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 238 | return NAME(qual); |
| 239 | } |
| 240 | |
Matt Turner | a439788 | 2016-01-15 13:31:34 -0800 | [diff] [blame] | 241 | const char * |
| 242 | gl_frag_result_name(gl_frag_result result) |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 243 | { |
| 244 | static const char *names[] = { |
| 245 | ENUM(FRAG_RESULT_DEPTH), |
| 246 | ENUM(FRAG_RESULT_STENCIL), |
| 247 | ENUM(FRAG_RESULT_COLOR), |
| 248 | ENUM(FRAG_RESULT_SAMPLE_MASK), |
| 249 | ENUM(FRAG_RESULT_DATA0), |
| 250 | ENUM(FRAG_RESULT_DATA1), |
| 251 | ENUM(FRAG_RESULT_DATA2), |
| 252 | ENUM(FRAG_RESULT_DATA3), |
| 253 | ENUM(FRAG_RESULT_DATA4), |
| 254 | ENUM(FRAG_RESULT_DATA5), |
| 255 | ENUM(FRAG_RESULT_DATA6), |
| 256 | ENUM(FRAG_RESULT_DATA7), |
| 257 | }; |
Rob Clark | 33de998 | 2015-10-09 16:27:45 -0400 | [diff] [blame] | 258 | STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX); |
Rob Clark | f2533f2 | 2015-09-11 12:48:05 -0400 | [diff] [blame] | 259 | return NAME(result); |
| 260 | } |