summaryrefslogtreecommitdiff
path: root/src/mesa/shader
diff options
context:
space:
mode:
authorRoland Scheidegger <sroland@vmware.com>2010-05-04 15:58:29 +0200
committerRoland Scheidegger <sroland@vmware.com>2010-05-04 15:58:29 +0200
commit0ae2f59c0287f4baec6c7de5f2f0fdf736fba26d (patch)
treeee14bf3e8bba80649541c4e13fc07c60baf6c248 /src/mesa/shader
parent7662e3519bef3802024da3050b886068281e02b1 (diff)
parent1c920c61764b17fd9fb4a89d2db7355fbe1d7565 (diff)
Merge commit 'origin/master' into gallium-msaa
Diffstat (limited to 'src/mesa/shader')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c5
-rw-r--r--src/mesa/shader/slang/slang_compile_variable.h2
-rw-r--r--src/mesa/shader/slang/slang_emit.c31
-rw-r--r--src/mesa/shader/slang/slang_ir.c8
-rw-r--r--src/mesa/shader/slang/slang_label.c2
-rw-r--r--src/mesa/shader/slang/slang_link.c5
-rw-r--r--src/mesa/shader/slang/slang_print.c8
-rw-r--r--src/mesa/shader/slang/slang_utility.c2
8 files changed, 31 insertions, 32 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index fa79632c18..4b876a460c 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -1560,7 +1560,7 @@ _slang_gen_function_call(slang_assemble_ctx *A, slang_function *fun,
char name[200];
prevFuncEndLabel = A->curFuncEndLabel;
- sprintf(name, "__endOfFunc_%s_", (char *) fun->header.a_name);
+ _mesa_snprintf(name, sizeof(name), "__endOfFunc_%s_", (char *) fun->header.a_name);
A->curFuncEndLabel = _slang_label_new(name);
assert(A->curFuncEndLabel);
@@ -4187,11 +4187,10 @@ _slang_gen_variable(slang_assemble_ctx * A, slang_operation *oper)
slang_atom name = oper->var ? oper->var->a_name : oper->a_id;
slang_variable *var = _slang_variable_locate(oper->locals, name, GL_TRUE);
slang_ir_node *n;
- if (!var) {
+ if (!var || !var->declared) {
slang_info_log_error(A->log, "undefined variable '%s'", (char *) name);
return NULL;
}
- assert(var->declared);
n = new_var(A, var);
return n;
}
diff --git a/src/mesa/shader/slang/slang_compile_variable.h b/src/mesa/shader/slang/slang_compile_variable.h
index b4585599f2..5c9d248b35 100644
--- a/src/mesa/shader/slang/slang_compile_variable.h
+++ b/src/mesa/shader/slang/slang_compile_variable.h
@@ -41,7 +41,7 @@ typedef struct slang_variable_
GLuint size; /**< Variable's size in bytes */
GLboolean is_global;
GLboolean isTemp; /**< a named temporary (__resultTmp) */
- GLboolean declared; /**< for debug */
+ GLboolean declared; /**< has the var been declared? */
struct slang_ir_storage_ *store; /**< Storage for this var */
} slang_variable;
diff --git a/src/mesa/shader/slang/slang_emit.c b/src/mesa/shader/slang/slang_emit.c
index 7c0ea0c114..974c4a3131 100644
--- a/src/mesa/shader/slang/slang_emit.c
+++ b/src/mesa/shader/slang/slang_emit.c
@@ -652,30 +652,30 @@ storage_annotation(const slang_ir_node *n, const struct gl_program *prog)
if (st->Index >= 0) {
const GLfloat *val = prog->Parameters->ParameterValues[st->Index];
if (st->Swizzle == SWIZZLE_NOOP)
- sprintf(s, "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
+ _mesa_snprintf(s, sizeof(s), "{%g, %g, %g, %g}", val[0], val[1], val[2], val[3]);
else {
- sprintf(s, "%g", val[GET_SWZ(st->Swizzle, 0)]);
+ _mesa_snprintf(s, sizeof(s), "%g", val[GET_SWZ(st->Swizzle, 0)]);
}
}
break;
case PROGRAM_TEMPORARY:
if (n->Var)
- sprintf(s, "%s", (char *) n->Var->a_name);
+ _mesa_snprintf(s, sizeof(s), "%s", (char *) n->Var->a_name);
else
- sprintf(s, "t[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "t[%d]", st->Index);
break;
case PROGRAM_STATE_VAR:
case PROGRAM_UNIFORM:
- sprintf(s, "%s", prog->Parameters->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Parameters->Parameters[st->Index].Name);
break;
case PROGRAM_VARYING:
- sprintf(s, "%s", prog->Varying->Parameters[st->Index].Name);
+ _mesa_snprintf(s, sizeof(s), "%s", prog->Varying->Parameters[st->Index].Name);
break;
case PROGRAM_INPUT:
- sprintf(s, "input[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "input[%d]", st->Index);
break;
case PROGRAM_OUTPUT:
- sprintf(s, "output[%d]", st->Index);
+ _mesa_snprintf(s, sizeof(s), "output[%d]", st->Index);
break;
default:
s[0] = 0;
@@ -752,9 +752,8 @@ instruction_annotation(gl_inst_opcode opcode, char *dstAnnot,
}
s = (char *) malloc(len);
- sprintf(s, "%s = %s %s %s %s", dstAnnot,
- srcAnnot0, operator, srcAnnot1, srcAnnot2);
- assert(strlen(s) < len);
+ _mesa_snprintf(s, len, "%s = %s %s %s %s", dstAnnot,
+ srcAnnot0, operator, srcAnnot1, srcAnnot2);
free(dstAnnot);
free(srcAnnot0);
@@ -2274,11 +2273,11 @@ emit_var_decl(slang_emit_info *emitInfo, slang_ir_node *n)
if (emitInfo->EmitComments) {
/* emit NOP with comment describing the variable's storage location */
char s[1000];
- sprintf(s, "TEMP[%d]%s = variable %s (size %d)",
- n->Store->Index,
- _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
- (n->Var ? (char *) n->Var->a_name : "anonymous"),
- n->Store->Size);
+ _mesa_snprintf(s, sizeof(s), "TEMP[%d]%s = variable %s (size %d)",
+ n->Store->Index,
+ _mesa_swizzle_string(n->Store->Swizzle, 0, GL_FALSE),
+ (n->Var ? (char *) n->Var->a_name : "anonymous"),
+ n->Store->Size);
emit_comment(emitInfo, s);
}
return NULL;
diff --git a/src/mesa/shader/slang/slang_ir.c b/src/mesa/shader/slang/slang_ir.c
index 62603503dd..c223004b22 100644
--- a/src/mesa/shader/slang/slang_ir.c
+++ b/src/mesa/shader/slang/slang_ir.c
@@ -340,13 +340,13 @@ storage_string(const slang_ir_storage *st)
assert(Elements(files) == PROGRAM_FILE_MAX);
#if 0
if (st->Size == 1)
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, "%s[%d]", files[st->File], st->Index);
else
- sprintf(s, "%s[%d..%d]", files[st->File], st->Index,
- st->Index + st->Size - 1);
+ _mesa_snprintf(s, "%s[%d..%d]", files[st->File], st->Index,
+ st->Index + st->Size - 1);
#endif
assert(st->File < (GLint) (sizeof(files) / sizeof(files[0])));
- sprintf(s, "%s[%d]", files[st->File], st->Index);
+ _mesa_snprintf(s, sizeof(s), "%s[%d]", files[st->File], st->Index);
return s;
}
diff --git a/src/mesa/shader/slang/slang_label.c b/src/mesa/shader/slang/slang_label.c
index 225612a936..8e3a8ebc1a 100644
--- a/src/mesa/shader/slang/slang_label.c
+++ b/src/mesa/shader/slang/slang_label.c
@@ -37,7 +37,7 @@ _slang_label_new_unique(const char *name)
free(l);
return NULL;
}
- sprintf(l->Name, "%s_%d", name, id);
+ _mesa_snprintf(l->Name, strlen(name) + 10, "%s_%d", name, id);
id++;
l->Location = -1;
}
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 47bc933971..b16778f8ad 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -370,8 +370,9 @@ link_uniform_vars(GLcontext *ctx,
GLuint newSampNum = *numSamplers;
if (newSampNum >= ctx->Const.MaxTextureImageUnits) {
char s[100];
- sprintf(s, "Too many texture samplers (%u, max is %u)",
- newSampNum, ctx->Const.MaxTextureImageUnits);
+ _mesa_snprintf(s, sizeof(s),
+ "Too many texture samplers (%u, max is %u)",
+ newSampNum, ctx->Const.MaxTextureImageUnits);
link_error(shProg, s);
return GL_FALSE;
}
diff --git a/src/mesa/shader/slang/slang_print.c b/src/mesa/shader/slang/slang_print.c
index 3c75523c42..6b34f395fd 100644
--- a/src/mesa/shader/slang/slang_print.c
+++ b/src/mesa/shader/slang/slang_print.c
@@ -813,7 +813,7 @@ static const char *
slang_fq_type_string(const slang_fully_specified_type *t)
{
static char str[1000];
- sprintf(str, "%s %s", slang_type_qual_string(t->qualifier),
+ _mesa_snprintf(str, sizeof(str), "%s %s", slang_type_qual_string(t->qualifier),
slang_type_string(t->specifier.type));
return str;
}
@@ -832,9 +832,9 @@ static char *
slang_var_string(const slang_variable *v)
{
static char str[1000];
- sprintf(str, "%s : %s",
- (char *) v->a_name,
- slang_fq_type_string(&v->type));
+ _mesa_snprintf(str, sizeof(str), "%s : %s",
+ (char *) v->a_name,
+ slang_fq_type_string(&v->type));
return str;
}
#endif
diff --git a/src/mesa/shader/slang/slang_utility.c b/src/mesa/shader/slang/slang_utility.c
index e77404f692..c1d57409a4 100644
--- a/src/mesa/shader/slang/slang_utility.c
+++ b/src/mesa/shader/slang/slang_utility.c
@@ -120,7 +120,7 @@ slang_string_pushi (slang_string *self, GLint i)
{
char buffer[12];
- sprintf (buffer, "%d", i);
+ _mesa_snprintf (buffer, sizeof(buffer), "%d", i);
slang_string_pushs (self, buffer, strlen (buffer));
}