From 7555d1bafb089bc5130f86602a23725e184c490e Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Wed, 18 Feb 2015 17:35:41 -0800 Subject: [PATCH] glsl: Create a _mesa_shader_stage_to_abbrev() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This is similar to _mesa_shader_stage_to_string(), but returns "VS" instead of "vertex". v2: Use unreachable() and add MESA_SHADER_COMPUTE (requested by Ian). Signed-off-by: Kenneth Graunke Reviewed-by: Jason Ekstrand Reviewed-by: Ian Romanick Reviewed-by: Kristian Høgsberg Reviewed-by: Anuj Phogat --- src/glsl/glsl_parser_extras.cpp | 17 +++++++++++++++++ src/glsl/glsl_parser_extras.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 29e6dd2ff7d..2e44dc1567a 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -376,6 +376,23 @@ _mesa_shader_stage_to_string(unsigned stage) return "unknown"; } +/** + * Translate a gl_shader_stage to a shader stage abbreviation (VS, GS, FS) + * for debug printouts and error messages. + */ +const char * +_mesa_shader_stage_to_abbrev(unsigned stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: return "VS"; + case MESA_SHADER_FRAGMENT: return "FS"; + case MESA_SHADER_GEOMETRY: return "GS"; + case MESA_SHADER_COMPUTE: return "CS"; + } + + unreachable("Unknown shader stage."); +} + /* This helper function will append the given message to the shader's info log and report it via GL_ARB_debug_output. Per that extension, 'type' is one of the enum values classifying the message, and diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h index ea53270eddc..0975c86ed7a 100644 --- a/src/glsl/glsl_parser_extras.h +++ b/src/glsl/glsl_parser_extras.h @@ -583,6 +583,9 @@ extern "C" { extern const char * _mesa_shader_stage_to_string(unsigned stage); +extern const char * +_mesa_shader_stage_to_abbrev(unsigned stage); + extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log, const struct gl_extensions *extensions, struct gl_context *gl_ctx); -- 2.30.2