glsl: Make a function to express a GLSL version ir human-readable form.
authorPaul Berry <stereotype441@gmail.com>
Thu, 2 Aug 2012 01:36:57 +0000 (18:36 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 6 Dec 2012 20:13:21 +0000 (12:13 -0800)
This will be useful in generating more helpful error messages,
especially with the addition of GLSL 3.00 ES support.

[v2, idr]: Rename ctx parameter to mem_ctx

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Acked-by: Carl Worth <cworth@cworth.org>
src/glsl/glsl_parser.yy
src/glsl/glsl_parser_extras.cpp
src/glsl/glsl_parser_extras.h

index 407dbbeebccce72d5102b38cc7c32a1a9d9352df..03e05ff1bf31559876f9d71e4b6b516a95b0c7ac 100644 (file)
@@ -290,10 +290,8 @@ version_statement:
 
           state->language_version = $2;
           state->version_string =
-             ralloc_asprintf(state, "GLSL%s %d.%02d",
-                             state->es_shader ? " ES" : "",
-                             state->language_version / 100,
-                             state->language_version % 100);
+              glsl_compute_version_string(state, state->es_shader,
+                                          state->language_version);
 
           if (!supported) {
              _mesa_glsl_error(& @2, state, "%s is not supported. "
index f1fdd3a475219b760221b3cf7e5e799543798cde..3e192037e0d9fb30d9810a61d3d016f3abbc1eab 100644 (file)
@@ -37,6 +37,16 @@ extern "C" {
 #include "ir_optimization.h"
 #include "loop_analysis.h"
 
+/**
+ * Format a short human-readable description of the given GLSL version.
+ */
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version)
+{
+   return ralloc_asprintf(mem_ctx, "GLSL%s %d.%02d", is_es ? " ES" : "",
+                          version / 100, version % 100);
+}
+
 _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
                                               GLenum target, void *mem_ctx)
  : ctx(_ctx)
index 0b208f6ca9464bd7a4101b2fe01bcc918af5e99e..5bad5a94d3cffc782d213500fd827914c452b241 100644 (file)
@@ -56,6 +56,9 @@ struct glsl_switch_state {
    bool is_switch_innermost; // if switch stmt is closest to break, ...
 };
 
+const char *
+glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
+
 struct _mesa_glsl_parse_state {
    _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
                          void *mem_ctx);