glsl: Make a function to express a GLSL version ir human-readable form.

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>
This commit is contained in:
Paul Berry 2012-08-01 18:36:57 -07:00 committed by Ian Romanick
parent 53e572f15c
commit d9bfaa104e
3 changed files with 15 additions and 4 deletions

View 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. "

View 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)

View 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);