[Mesa-dev] [PATCH 03/26] glsl: Make a function to express a GLSL version ir human-readable form.
Ian Romanick
idr at freedesktop.org
Fri Nov 30 10:07:18 PST 2012
From: Paul Berry <stereotype441 at gmail.com>
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 at intel.com>
---
src/glsl/glsl_parser.yy | 6 ++----
src/glsl/glsl_parser_extras.cpp | 10 ++++++++++
src/glsl/glsl_parser_extras.h | 3 +++
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/glsl/glsl_parser.yy b/src/glsl/glsl_parser.yy
index 407dbbe..03e05ff 100644
--- a/src/glsl/glsl_parser.yy
+++ b/src/glsl/glsl_parser.yy
@@ -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. "
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index f1fdd3a..3e19203 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -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)
diff --git a/src/glsl/glsl_parser_extras.h b/src/glsl/glsl_parser_extras.h
index 0b208f6..5bad5a9 100644
--- a/src/glsl/glsl_parser_extras.h
+++ b/src/glsl/glsl_parser_extras.h
@@ -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);
--
1.7.11.7
More information about the mesa-dev
mailing list