summaryrefslogtreecommitdiff
path: root/src/mesa/shader/slang
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-11-10 12:33:17 -0700
committerBrian Paul <brian.paul@tungstengraphics.com>2008-11-10 12:39:36 -0700
commit2d76a0d77af7be9539f89cba37ce84338c1cdda4 (patch)
tree6e722f4d0f8356707ed9402dc9eeeb5dc56704b4 /src/mesa/shader/slang
parent379ff8c9567940ebff44870cf7b0202882445fa6 (diff)
mesa: track initialization status of uniform variables. Plus, asst clean-ups.
Diffstat (limited to 'src/mesa/shader/slang')
-rw-r--r--src/mesa/shader/slang/slang_codegen.c17
-rw-r--r--src/mesa/shader/slang/slang_link.c5
2 files changed, 13 insertions, 9 deletions
diff --git a/src/mesa/shader/slang/slang_codegen.c b/src/mesa/shader/slang/slang_codegen.c
index 8ab1fa8f2a..dea1fcf087 100644
--- a/src/mesa/shader/slang/slang_codegen.c
+++ b/src/mesa/shader/slang/slang_codegen.c
@@ -3715,7 +3715,7 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
/* temporary work-around */
GLenum datatype = GL_FLOAT;
GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
- totalSize, datatype);
+ totalSize, datatype, NULL);
store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
totalSize, swizzle);
@@ -3747,18 +3747,14 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
}
}
else {
- GLint uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
- totalSize, datatype);
- store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
- totalSize, swizzle);
+ GLint uniformLoc;
+ const GLfloat *initialValues = NULL;
if (var->initializer) {
_slang_simplify(var->initializer, &A->space, A->atoms);
if (var->initializer->type == SLANG_OPER_LITERAL_FLOAT ||
var->initializer->type == SLANG_OPER_LITERAL_INT) {
/* simple float/vector initializer */
- GLfloat *uniformValue =
- prog->Parameters->ParameterValues[uniformLoc];
- COPY_4V(uniformValue, var->initializer->literal);
+ initialValues = var->initializer->literal;
}
else {
/* complex initializer */
@@ -3767,6 +3763,11 @@ _slang_codegen_global_variable(slang_assemble_ctx *A, slang_variable *var,
return GL_FALSE;
}
}
+
+ uniformLoc = _mesa_add_uniform(prog->Parameters, varName,
+ totalSize, datatype, initialValues);
+ store = _slang_new_ir_storage_swz(PROGRAM_UNIFORM, uniformLoc,
+ totalSize, swizzle);
}
}
else {
diff --git a/src/mesa/shader/slang/slang_link.c b/src/mesa/shader/slang/slang_link.c
index 4361efc56e..79fd9a064f 100644
--- a/src/mesa/shader/slang/slang_link.c
+++ b/src/mesa/shader/slang/slang_link.c
@@ -193,7 +193,10 @@ link_uniform_vars(struct gl_shader_program *shProg,
if ((p->Type == PROGRAM_UNIFORM && p->Used) ||
p->Type == PROGRAM_SAMPLER) {
- _mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i);
+ struct gl_uniform *uniform =
+ _mesa_append_uniform(shProg->Uniforms, p->Name, prog->Target, i);
+ if (uniform)
+ uniform->Initialized = p->Initialized;
}
if (p->Type == PROGRAM_SAMPLER) {