1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Mesa 3-D graphics library 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Copyright © 2015 Red Hat 5bf215546Sopenharmony_ci * 6bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 7bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 8bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 9bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 10bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 11bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 12bf215546Sopenharmony_ci * 13bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 14bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 15bf215546Sopenharmony_ci * Software. 16bf215546Sopenharmony_ci * 17bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 23bf215546Sopenharmony_ci * IN THE SOFTWARE. 24bf215546Sopenharmony_ci * 25bf215546Sopenharmony_ci * Authors: 26bf215546Sopenharmony_ci * Rob Clark <robclark@freedesktop.org> 27bf215546Sopenharmony_ci */ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "shader_enums.h" 30bf215546Sopenharmony_ci#include "util/macros.h" 31bf215546Sopenharmony_ci#include "mesa/main/config.h" 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#define ENUM(x) [x] = #x 34bf215546Sopenharmony_ci#define NAME(val) ((((val) < ARRAY_SIZE(names)) && names[(val)]) ? names[(val)] : "UNKNOWN") 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ciconst char * 37bf215546Sopenharmony_cigl_shader_stage_name(gl_shader_stage stage) 38bf215546Sopenharmony_ci{ 39bf215546Sopenharmony_ci static const char *names[] = { 40bf215546Sopenharmony_ci ENUM(MESA_SHADER_VERTEX), 41bf215546Sopenharmony_ci ENUM(MESA_SHADER_TESS_CTRL), 42bf215546Sopenharmony_ci ENUM(MESA_SHADER_TESS_EVAL), 43bf215546Sopenharmony_ci ENUM(MESA_SHADER_GEOMETRY), 44bf215546Sopenharmony_ci ENUM(MESA_SHADER_FRAGMENT), 45bf215546Sopenharmony_ci ENUM(MESA_SHADER_COMPUTE), 46bf215546Sopenharmony_ci ENUM(MESA_SHADER_TASK), 47bf215546Sopenharmony_ci ENUM(MESA_SHADER_MESH), 48bf215546Sopenharmony_ci ENUM(MESA_SHADER_RAYGEN), 49bf215546Sopenharmony_ci ENUM(MESA_SHADER_ANY_HIT), 50bf215546Sopenharmony_ci ENUM(MESA_SHADER_CLOSEST_HIT), 51bf215546Sopenharmony_ci ENUM(MESA_SHADER_MISS), 52bf215546Sopenharmony_ci ENUM(MESA_SHADER_INTERSECTION), 53bf215546Sopenharmony_ci ENUM(MESA_SHADER_CALLABLE), 54bf215546Sopenharmony_ci ENUM(MESA_SHADER_KERNEL), 55bf215546Sopenharmony_ci }; 56bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == MESA_ALL_SHADER_STAGES); 57bf215546Sopenharmony_ci return NAME(stage); 58bf215546Sopenharmony_ci} 59bf215546Sopenharmony_ci 60bf215546Sopenharmony_ci/** 61bf215546Sopenharmony_ci * Translate a gl_shader_stage to a short shader stage name for debug 62bf215546Sopenharmony_ci * printouts and error messages. 63bf215546Sopenharmony_ci */ 64bf215546Sopenharmony_ciconst char * 65bf215546Sopenharmony_ci_mesa_shader_stage_to_string(unsigned stage) 66bf215546Sopenharmony_ci{ 67bf215546Sopenharmony_ci switch (stage) { 68bf215546Sopenharmony_ci case MESA_SHADER_VERTEX: return "vertex"; 69bf215546Sopenharmony_ci case MESA_SHADER_FRAGMENT: return "fragment"; 70bf215546Sopenharmony_ci case MESA_SHADER_GEOMETRY: return "geometry"; 71bf215546Sopenharmony_ci case MESA_SHADER_COMPUTE: return "compute"; 72bf215546Sopenharmony_ci case MESA_SHADER_KERNEL: return "kernel"; 73bf215546Sopenharmony_ci case MESA_SHADER_TESS_CTRL: return "tessellation control"; 74bf215546Sopenharmony_ci case MESA_SHADER_TESS_EVAL: return "tessellation evaluation"; 75bf215546Sopenharmony_ci case MESA_SHADER_TASK: return "task"; 76bf215546Sopenharmony_ci case MESA_SHADER_MESH: return "mesh"; 77bf215546Sopenharmony_ci case MESA_SHADER_RAYGEN: return "raygen"; 78bf215546Sopenharmony_ci case MESA_SHADER_ANY_HIT: return "any hit"; 79bf215546Sopenharmony_ci case MESA_SHADER_CLOSEST_HIT: return "closest hit"; 80bf215546Sopenharmony_ci case MESA_SHADER_MISS: return "miss"; 81bf215546Sopenharmony_ci case MESA_SHADER_INTERSECTION: return "intersection"; 82bf215546Sopenharmony_ci case MESA_SHADER_CALLABLE: return "callable"; 83bf215546Sopenharmony_ci } 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ci unreachable("Unknown shader stage."); 86bf215546Sopenharmony_ci} 87bf215546Sopenharmony_ci 88bf215546Sopenharmony_ci/** 89bf215546Sopenharmony_ci * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS) 90bf215546Sopenharmony_ci * for debug printouts and error messages. 91bf215546Sopenharmony_ci */ 92bf215546Sopenharmony_ciconst char * 93bf215546Sopenharmony_ci_mesa_shader_stage_to_abbrev(unsigned stage) 94bf215546Sopenharmony_ci{ 95bf215546Sopenharmony_ci switch (stage) { 96bf215546Sopenharmony_ci case MESA_SHADER_VERTEX: return "VS"; 97bf215546Sopenharmony_ci case MESA_SHADER_FRAGMENT: return "FS"; 98bf215546Sopenharmony_ci case MESA_SHADER_GEOMETRY: return "GS"; 99bf215546Sopenharmony_ci case MESA_SHADER_COMPUTE: return "CS"; 100bf215546Sopenharmony_ci case MESA_SHADER_KERNEL: return "CL"; 101bf215546Sopenharmony_ci case MESA_SHADER_TESS_CTRL: return "TCS"; 102bf215546Sopenharmony_ci case MESA_SHADER_TESS_EVAL: return "TES"; 103bf215546Sopenharmony_ci case MESA_SHADER_TASK: return "TASK"; 104bf215546Sopenharmony_ci case MESA_SHADER_MESH: return "MESH"; 105bf215546Sopenharmony_ci case MESA_SHADER_RAYGEN: return "RGEN"; 106bf215546Sopenharmony_ci case MESA_SHADER_ANY_HIT: return "RAHIT"; 107bf215546Sopenharmony_ci case MESA_SHADER_CLOSEST_HIT: return "RCHIT"; 108bf215546Sopenharmony_ci case MESA_SHADER_MISS: return "RMISS"; 109bf215546Sopenharmony_ci case MESA_SHADER_INTERSECTION: return "RINT"; 110bf215546Sopenharmony_ci case MESA_SHADER_CALLABLE: return "RCALL"; 111bf215546Sopenharmony_ci } 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_ci unreachable("Unknown shader stage."); 114bf215546Sopenharmony_ci} 115bf215546Sopenharmony_ci 116bf215546Sopenharmony_ciconst char * 117bf215546Sopenharmony_cigl_vert_attrib_name(gl_vert_attrib attrib) 118bf215546Sopenharmony_ci{ 119bf215546Sopenharmony_ci static const char *names[] = { 120bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_POS), 121bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_NORMAL), 122bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_COLOR0), 123bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_COLOR1), 124bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_FOG), 125bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_COLOR_INDEX), 126bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX0), 127bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX1), 128bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX2), 129bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX3), 130bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX4), 131bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX5), 132bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX6), 133bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_TEX7), 134bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_POINT_SIZE), 135bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC0), 136bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC1), 137bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC2), 138bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC3), 139bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC4), 140bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC5), 141bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC6), 142bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC7), 143bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC8), 144bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC9), 145bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC10), 146bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC11), 147bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC12), 148bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC13), 149bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC14), 150bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_GENERIC15), 151bf215546Sopenharmony_ci ENUM(VERT_ATTRIB_EDGEFLAG), 152bf215546Sopenharmony_ci }; 153bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == VERT_ATTRIB_MAX); 154bf215546Sopenharmony_ci return NAME(attrib); 155bf215546Sopenharmony_ci} 156bf215546Sopenharmony_ci 157bf215546Sopenharmony_ciconst char * 158bf215546Sopenharmony_cigl_varying_slot_name_for_stage(gl_varying_slot slot, gl_shader_stage stage) 159bf215546Sopenharmony_ci{ 160bf215546Sopenharmony_ci if (stage != MESA_SHADER_FRAGMENT && slot == VARYING_SLOT_PRIMITIVE_SHADING_RATE) 161bf215546Sopenharmony_ci return "VARYING_SLOT_PRIMITIVE_SHADING_RATE"; 162bf215546Sopenharmony_ci 163bf215546Sopenharmony_ci switch (stage) { 164bf215546Sopenharmony_ci case MESA_SHADER_MESH: 165bf215546Sopenharmony_ci switch (slot) { 166bf215546Sopenharmony_ci case VARYING_SLOT_PRIMITIVE_COUNT: return "VARYING_SLOT_PRIMITIVE_COUNT"; 167bf215546Sopenharmony_ci case VARYING_SLOT_PRIMITIVE_INDICES: return "VARYING_SLOT_PRIMITIVE_INDICES"; 168bf215546Sopenharmony_ci case VARYING_SLOT_CULL_PRIMITIVE: return "VARYING_SLOT_CULL_PRIMITIVE"; 169bf215546Sopenharmony_ci default: 170bf215546Sopenharmony_ci /* Not an overlapping value. */ 171bf215546Sopenharmony_ci break; 172bf215546Sopenharmony_ci } 173bf215546Sopenharmony_ci break; 174bf215546Sopenharmony_ci 175bf215546Sopenharmony_ci case MESA_SHADER_TASK: 176bf215546Sopenharmony_ci switch (slot) { 177bf215546Sopenharmony_ci case VARYING_SLOT_TASK_COUNT: return "VARYING_SLOT_TASK_COUNT"; 178bf215546Sopenharmony_ci default: 179bf215546Sopenharmony_ci /* Not an overlapping value. */ 180bf215546Sopenharmony_ci break; 181bf215546Sopenharmony_ci } 182bf215546Sopenharmony_ci break; 183bf215546Sopenharmony_ci 184bf215546Sopenharmony_ci default: 185bf215546Sopenharmony_ci break; 186bf215546Sopenharmony_ci } 187bf215546Sopenharmony_ci 188bf215546Sopenharmony_ci static const char *names[] = { 189bf215546Sopenharmony_ci ENUM(VARYING_SLOT_POS), 190bf215546Sopenharmony_ci ENUM(VARYING_SLOT_COL0), 191bf215546Sopenharmony_ci ENUM(VARYING_SLOT_COL1), 192bf215546Sopenharmony_ci ENUM(VARYING_SLOT_FOGC), 193bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX0), 194bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX1), 195bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX2), 196bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX3), 197bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX4), 198bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX5), 199bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX6), 200bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TEX7), 201bf215546Sopenharmony_ci ENUM(VARYING_SLOT_PSIZ), 202bf215546Sopenharmony_ci ENUM(VARYING_SLOT_BFC0), 203bf215546Sopenharmony_ci ENUM(VARYING_SLOT_BFC1), 204bf215546Sopenharmony_ci ENUM(VARYING_SLOT_EDGE), 205bf215546Sopenharmony_ci ENUM(VARYING_SLOT_CLIP_VERTEX), 206bf215546Sopenharmony_ci ENUM(VARYING_SLOT_CLIP_DIST0), 207bf215546Sopenharmony_ci ENUM(VARYING_SLOT_CLIP_DIST1), 208bf215546Sopenharmony_ci ENUM(VARYING_SLOT_CULL_DIST0), 209bf215546Sopenharmony_ci ENUM(VARYING_SLOT_CULL_DIST1), 210bf215546Sopenharmony_ci ENUM(VARYING_SLOT_PRIMITIVE_ID), 211bf215546Sopenharmony_ci ENUM(VARYING_SLOT_LAYER), 212bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VIEWPORT), 213bf215546Sopenharmony_ci ENUM(VARYING_SLOT_FACE), 214bf215546Sopenharmony_ci ENUM(VARYING_SLOT_PNTC), 215bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TESS_LEVEL_OUTER), 216bf215546Sopenharmony_ci ENUM(VARYING_SLOT_TESS_LEVEL_INNER), 217bf215546Sopenharmony_ci ENUM(VARYING_SLOT_BOUNDING_BOX0), 218bf215546Sopenharmony_ci ENUM(VARYING_SLOT_BOUNDING_BOX1), 219bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VIEW_INDEX), 220bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VIEWPORT_MASK), 221bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR0), 222bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR1), 223bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR2), 224bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR3), 225bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR4), 226bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR5), 227bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR6), 228bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR7), 229bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR8), 230bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR9), 231bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR10), 232bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR11), 233bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR12), 234bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR13), 235bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR14), 236bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR15), 237bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR16), 238bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR17), 239bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR18), 240bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR19), 241bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR20), 242bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR21), 243bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR22), 244bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR23), 245bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR24), 246bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR25), 247bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR26), 248bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR27), 249bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR28), 250bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR29), 251bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR30), 252bf215546Sopenharmony_ci ENUM(VARYING_SLOT_VAR31), 253bf215546Sopenharmony_ci }; 254bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == VARYING_SLOT_MAX); 255bf215546Sopenharmony_ci return NAME(slot); 256bf215546Sopenharmony_ci} 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ciconst char * 259bf215546Sopenharmony_cigl_system_value_name(gl_system_value sysval) 260bf215546Sopenharmony_ci{ 261bf215546Sopenharmony_ci static const char *names[] = { 262bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_SIZE), 263bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_INVOCATION), 264bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_EQ_MASK), 265bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_GE_MASK), 266bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_GT_MASK), 267bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_LE_MASK), 268bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_LT_MASK), 269bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_NUM_SUBGROUPS), 270bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SUBGROUP_ID), 271bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_VERTEX_ID), 272bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_INSTANCE_ID), 273bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_INSTANCE_INDEX), 274bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE), 275bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BASE_VERTEX), 276bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_FIRST_VERTEX), 277bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_IS_INDEXED_DRAW), 278bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BASE_INSTANCE), 279bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_DRAW_ID), 280bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_INVOCATION_ID), 281bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_FRAG_COORD), 282bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_POINT_COORD), 283bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_LINE_COORD), 284bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_FRONT_FACE), 285bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SAMPLE_ID), 286bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SAMPLE_POS), 287bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_SAMPLE_MASK_IN), 288bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_HELPER_INVOCATION), 289bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_COLOR0), 290bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_COLOR1), 291bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TESS_COORD), 292bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_VERTICES_IN), 293bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_PRIMITIVE_ID), 294bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TESS_LEVEL_OUTER), 295bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER), 296bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TESS_LEVEL_OUTER_DEFAULT), 297bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TESS_LEVEL_INNER_DEFAULT), 298bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_ID), 299bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_LOCAL_INVOCATION_INDEX), 300bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_GLOBAL_INVOCATION_ID), 301bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BASE_GLOBAL_INVOCATION_ID), 302bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_GLOBAL_INVOCATION_INDEX), 303bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_WORKGROUP_ID), 304bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_NUM_WORKGROUPS), 305bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_WORKGROUP_SIZE), 306bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_GLOBAL_GROUP_SIZE), 307bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_USER_DATA_AMD), 308bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_WORK_DIM), 309bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_DEVICE_INDEX), 310bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_VIEW_INDEX), 311bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_VERTEX_CNT), 312bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL), 313bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE), 314bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID), 315bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTER_RHW), 316bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL), 317bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID), 318bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE), 319bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_BARYCENTRIC_PULL_MODEL), 320bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_LAUNCH_ID), 321bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_LAUNCH_SIZE), 322bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_LAUNCH_SIZE_ADDR_AMD), 323bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_WORLD_ORIGIN), 324bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_WORLD_DIRECTION), 325bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_OBJECT_ORIGIN), 326bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_OBJECT_DIRECTION), 327bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_T_MIN), 328bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_T_MAX), 329bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_OBJECT_TO_WORLD), 330bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_WORLD_TO_OBJECT), 331bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_HIT_KIND), 332bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_FLAGS), 333bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_RAY_GEOMETRY_INDEX), 334bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_CULL_MASK), 335bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_MESH_VIEW_COUNT), 336bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_MESH_VIEW_INDICES), 337bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_GS_HEADER_IR3), 338bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_TCS_HEADER_IR3), 339bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_REL_PATCH_ID_IR3), 340bf215546Sopenharmony_ci ENUM(SYSTEM_VALUE_FRAG_SHADING_RATE), 341bf215546Sopenharmony_ci }; 342bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == SYSTEM_VALUE_MAX); 343bf215546Sopenharmony_ci return NAME(sysval); 344bf215546Sopenharmony_ci} 345bf215546Sopenharmony_ci 346bf215546Sopenharmony_ciconst char * 347bf215546Sopenharmony_ciglsl_interp_mode_name(enum glsl_interp_mode qual) 348bf215546Sopenharmony_ci{ 349bf215546Sopenharmony_ci static const char *names[] = { 350bf215546Sopenharmony_ci ENUM(INTERP_MODE_NONE), 351bf215546Sopenharmony_ci ENUM(INTERP_MODE_SMOOTH), 352bf215546Sopenharmony_ci ENUM(INTERP_MODE_FLAT), 353bf215546Sopenharmony_ci ENUM(INTERP_MODE_NOPERSPECTIVE), 354bf215546Sopenharmony_ci ENUM(INTERP_MODE_EXPLICIT), 355bf215546Sopenharmony_ci ENUM(INTERP_MODE_COLOR), 356bf215546Sopenharmony_ci }; 357bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == INTERP_MODE_COUNT); 358bf215546Sopenharmony_ci return NAME(qual); 359bf215546Sopenharmony_ci} 360bf215546Sopenharmony_ci 361bf215546Sopenharmony_ciconst char * 362bf215546Sopenharmony_cigl_frag_result_name(gl_frag_result result) 363bf215546Sopenharmony_ci{ 364bf215546Sopenharmony_ci static const char *names[] = { 365bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DEPTH), 366bf215546Sopenharmony_ci ENUM(FRAG_RESULT_STENCIL), 367bf215546Sopenharmony_ci ENUM(FRAG_RESULT_COLOR), 368bf215546Sopenharmony_ci ENUM(FRAG_RESULT_SAMPLE_MASK), 369bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA0), 370bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA1), 371bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA2), 372bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA3), 373bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA4), 374bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA5), 375bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA6), 376bf215546Sopenharmony_ci ENUM(FRAG_RESULT_DATA7), 377bf215546Sopenharmony_ci }; 378bf215546Sopenharmony_ci STATIC_ASSERT(ARRAY_SIZE(names) == FRAG_RESULT_MAX); 379bf215546Sopenharmony_ci return NAME(result); 380bf215546Sopenharmony_ci} 381bf215546Sopenharmony_ci 382bf215546Sopenharmony_ciunsigned 383bf215546Sopenharmony_cinum_mesh_vertices_per_primitive(unsigned prim) 384bf215546Sopenharmony_ci{ 385bf215546Sopenharmony_ci switch (prim) { 386bf215546Sopenharmony_ci case SHADER_PRIM_POINTS: 387bf215546Sopenharmony_ci return 1; 388bf215546Sopenharmony_ci case SHADER_PRIM_LINES: 389bf215546Sopenharmony_ci return 2; 390bf215546Sopenharmony_ci case SHADER_PRIM_TRIANGLES: 391bf215546Sopenharmony_ci return 3; 392bf215546Sopenharmony_ci default: 393bf215546Sopenharmony_ci unreachable("invalid mesh shader primitive type"); 394bf215546Sopenharmony_ci } 395bf215546Sopenharmony_ci} 396