mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 18:18:06 +02:00
added program_error2() function for better error reporting
cherry-picked from master
This commit is contained in:
parent
7b91d87540
commit
50a20d4729
1 changed files with 60 additions and 47 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue