summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-03-27 15:51:07 -0600
committerBrian <brian.paul@tungstengraphics.com>2008-03-27 15:51:07 -0600
commit50a20d472956d54e3dc66e6501f1e5fb8581c84f (patch)
treeea1a4713b59df5cd3062c65751892566706f1ac6 /src/mesa/shader
parent7b91d875401e039635718d1bc1e96d37ec66777c (diff)
added program_error2() function for better error reporting
cherry-picked from master
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/arbprogparse.c107
1 files changed, 60 insertions, 47 deletions
diff --git a/src/mesa/shader/arbprogparse.c b/src/mesa/shader/arbprogparse.c
index 83fc195142..38e174f3ad 100644
--- a/src/mesa/shader/arbprogparse.c
+++ b/src/mesa/shader/arbprogparse.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 6.5.3
+ * Version: 7.1
*
* Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
*
@@ -634,6 +634,41 @@ program_error(GLcontext *ctx, GLint position, const char *descrip)
}
+/**
+ * As above, but with an extra string parameter for more info.
+ */
+static void
+program_error2(GLcontext *ctx, GLint position, const char *descrip,
+ const char *var)
+{
+ if (descrip) {
+ const char *prefix = "glProgramString(", *suffix = ")";
+ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) +
+ _mesa_strlen(": ") +
+ _mesa_strlen(var) +
+ _mesa_strlen(prefix) +
+ _mesa_strlen(suffix) + 1);
+ if (str) {
+ _mesa_sprintf(str, "%s%s: %s%s", prefix, descrip, var, suffix);
+ _mesa_error(ctx, GL_INVALID_OPERATION, str);
+ _mesa_free(str);
+ }
+ }
+ {
+ char *str = (char *) _mesa_malloc(_mesa_strlen(descrip) +
+ _mesa_strlen(": ") +
+ _mesa_strlen(var) + 1);
+ if (str) {
+ _mesa_sprintf(str, "%s: %s", descrip, var);
+ }
+ _mesa_set_program_error(ctx, position, str);
+ if (str) {
+ _mesa_free(str);
+ }
+ }
+}
+
+
/**
* constructs an integer from 4 GLubytes in LE format
@@ -1692,18 +1727,14 @@ parse_attrib (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head
struct arb_program *Program)
{
GLuint found;
- char *error_msg;
struct var_cache *attrib_var;
attrib_var = parse_string (inst, vc_head, Program, &found);
Program->Position = parse_position (inst);
if (found) {
- error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) attrib_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- attrib_var->name);
- program_error(ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) attrib_var->name);
return 1;
}
@@ -1883,12 +1914,9 @@ parse_param (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
Program->Position = parse_position (inst);
if (found) {
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) param_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- param_var->name);
- program_error (ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) param_var->name);
return 1;
}
@@ -1983,12 +2011,9 @@ parse_temp (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
temp_var = parse_string (inst, vc_head, Program, &found);
Program->Position = parse_position (inst);
if (found) {
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- temp_var->name);
- program_error(ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) temp_var->name);
return 1;
}
@@ -2029,12 +2054,9 @@ parse_output (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head
output_var = parse_string (inst, vc_head, Program, &found);
Program->Position = parse_position (inst);
if (found) {
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) output_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- output_var->name);
- program_error (ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) output_var->name);
return 1;
}
@@ -2060,12 +2082,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
Program->Position = parse_position (inst);
if (found) {
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- temp_var->name);
- program_error(ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) temp_var->name);
return 1;
}
@@ -2075,12 +2094,9 @@ parse_alias (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_head,
if (!found)
{
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
- _mesa_sprintf (error_msg, "Alias value %s is not defined",
- temp_var->alias_binding->name);
- program_error (ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Undefined alias value",
+ (char *) temp_var->alias_binding->name);
return 1;
}
@@ -2103,12 +2119,9 @@ parse_address (GLcontext * ctx, const GLubyte ** inst, struct var_cache **vc_hea
temp_var = parse_string (inst, vc_head, Program, &found);
Program->Position = parse_position (inst);
if (found) {
- char *error_msg = (char *)
- _mesa_malloc (_mesa_strlen ((char *) temp_var->name) + 40);
- _mesa_sprintf (error_msg, "Duplicate Variable Declaration: %s",
- temp_var->name);
- program_error (ctx, Program->Position, error_msg);
- _mesa_free (error_msg);
+ program_error2(ctx, Program->Position,
+ "Duplicate variable declaration",
+ (char *) temp_var->name);
return 1;
}
@@ -2461,9 +2474,9 @@ parse_src_reg (GLcontext * ctx, const GLubyte ** inst,
Program->Position = parse_position (inst);
if (!found) {
- char s[1000];
- sprintf(s, "Undefined variable: %s", src->name);
- program_error(ctx, Program->Position, s);
+ program_error2(ctx, Program->Position,
+ "Undefined variable",
+ (char *) src->name);
return 1;
}