diff options
Diffstat (limited to 'src/glsl/glsl_parser_extras.cpp')
-rw-r--r-- | src/glsl/glsl_parser_extras.cpp | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp index 98627145a5b..7b827bad6f1 100644 --- a/src/glsl/glsl_parser_extras.cpp +++ b/src/glsl/glsl_parser_extras.cpp @@ -302,6 +302,41 @@ _mesa_glsl_parse_state::process_version_directive(YYLTYPE *locp, int version, } } +extern "C" { + +/** + * The most common use of _mesa_glsl_shader_target_name(), which is + * shared with C code in Mesa core to translate a GLenum to a short + * shader stage name in debug printouts. + * + * It recognizes the PROGRAM variants of the names so it can be used + * with a struct gl_program->Target, not just a struct + * gl_shader->Type. + */ +const char * +_mesa_glsl_shader_target_name(GLenum type) +{ + switch (type) { + case GL_VERTEX_SHADER: + case GL_VERTEX_PROGRAM_ARB: + return "vertex"; + case GL_FRAGMENT_SHADER: + case GL_FRAGMENT_PROGRAM_ARB: + return "fragment"; + case GL_GEOMETRY_SHADER: + return "geometry"; + default: + assert(!"Should not get here."); + return "unknown"; + } +} + +} /* extern "C" */ + +/** + * Overloaded C++ variant usable within the compiler for translating + * our internal enum into short stage names. + */ const char * _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target) { |