From 33d63277706aede31559a24c0db76b37609e76ef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Jun 2009 09:52:31 -0600 Subject: mesa: better error message for invalid texture unit index --- src/mesa/shader/arbprogparse.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c index c7a031067e..bb4c5b38d4 100644 --- a/src/mesa/shader/arbprogparse.c +++ b/src/mesa/shader/arbprogparse.c @@ -1014,7 +1014,10 @@ parse_teximage_num (GLcontext * ctx, const GLubyte ** inst, GLint i = parse_integer (inst, Program); if ((i < 0) || (i >= (int)ctx->Const.MaxTextureImageUnits)) { - program_error(ctx, Program->Position, "Invalid texture image index"); + char s[100]; + _mesa_snprintf(s, sizeof(s), "Invalid texture image index %d (%u is max)", + i, ctx->Const.MaxTextureImageUnits); + program_error(ctx, Program->Position, s); return 1; } -- cgit v1.2.3 From 304ba4bba44057aa21f0ae434e49b1e09ab7d039 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 8 Jun 2009 13:53:33 -0600 Subject: glsl: Fix preprocessor define argument parsing for dead sections. (cherry picked from master, commit 19a54d9f1055c366fd77026dd67007a8d5921f58) --- src/mesa/shader/slang/slang_preprocess.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index ff913ad883..fd98fae360 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -1035,11 +1035,11 @@ preprocess_source (slang_string *output, const char *source, /* Parse optional macro parameters. */ while (prod[i++] != PARAM_END) { - if (state.cond.top->effective) { - pp_symbol *param; + pp_symbol *param; - id = (const char *) (&prod[i]); - idlen = _mesa_strlen (id); + id = (const char *) (&prod[i]); + idlen = _mesa_strlen (id); + if (state.cond.top->effective) { pp_annotate (output, "%s, ", id); param = pp_symbols_push (&symbol->parameters); if (param == NULL) -- cgit v1.2.3 From cb549775a577cc5c86fefdc7e208b9d5e1d25217 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 9 Jun 2009 09:14:38 -0600 Subject: glsl: Expand nested preprocessor macros. (cherry picked from master, commit ef8caec29ae73bb2bbeb48f0578d839ef29348cd) --- src/mesa/shader/slang/slang_preprocess.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'src/mesa/shader') diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index fd98fae360..0e95cdb525 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -1012,6 +1012,8 @@ preprocess_source (slang_string *output, const char *source, case TOKEN_DEFINE: { pp_symbol *symbol = NULL; + slang_string replacement; + expand_state es; /* Parse macro name. */ id = (const char *) (&prod[i]); @@ -1054,9 +1056,20 @@ preprocess_source (slang_string *output, const char *source, idlen = _mesa_strlen (id); if (state.cond.top->effective) { pp_annotate (output, ") %s", id); - slang_string_pushs (&symbol->replacement, id, idlen); } + slang_string_init(&replacement); + slang_string_pushs(&replacement, id, idlen); i += idlen + 1; + + /* Expand macro replacement. */ + es.output = &symbol->replacement; + es.input = slang_string_cstr(&replacement); + es.state = &state; + if (!expand(&es, &state.symbols)) { + slang_string_free(&replacement); + goto error; + } + slang_string_free(&replacement); } break; -- cgit v1.2.3