summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/shader_api.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2008-11-10 12:33:17 -0700
committerBrian Paul <[email protected]>2009-01-06 08:39:06 -0700
commit6b05708ce2c4120921f43d82f1751e039306e0d6 (patch)
tree700d9da432f136714c1f53ab50fe933f466b7684 /src/mesa/shader/shader_api.c
parentde445478915af41e1e078cbb8c2cbcce340f83b6 (diff)
mesa: track initialization status of uniform variables. Plus, asst clean-ups.
(cherry picked from commit 2d76a0d77af7be9539f89cba37ce84338c1cdda4)
Diffstat (limited to 'src/mesa/shader/shader_api.c')
-rw-r--r--src/mesa/shader/shader_api.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 7af502a84cb..2af97612f79 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1610,6 +1610,7 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
const GLvoid *values, GLenum type)
{
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
+ struct gl_uniform *uniform;
GLint elems, offset;
if (!shProg || !shProg->LinkStatus) {
@@ -1656,12 +1657,14 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ uniform = &shProg->Uniforms->Uniforms[location];
+
/* A uniform var may be used by both a vertex shader and a fragment
* shader. We may need to update one or both shader's uniform here:
*/
if (shProg->VertexProgram) {
/* convert uniform location to program parameter index */
- GLint index = shProg->Uniforms->Uniforms[location].VertPos;
+ GLint index = uniform->VertPos;
if (index >= 0) {
set_program_uniform(ctx, &shProg->VertexProgram->Base,
index, offset, type, count, elems, values);
@@ -1670,14 +1673,14 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
if (shProg->FragmentProgram) {
/* convert uniform location to program parameter index */
- GLint index = shProg->Uniforms->Uniforms[location].FragPos;
+ GLint index = uniform->FragPos;
if (index >= 0) {
set_program_uniform(ctx, &shProg->FragmentProgram->Base,
index, offset, type, count, elems, values);
}
}
- shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
+ uniform->Initialized = GL_TRUE;
}
@@ -1744,8 +1747,9 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose, const GLfloat *values)
{
- GLint offset;
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
+ struct gl_uniform *uniform;
+ GLint offset;
if (!shProg || !shProg->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1769,9 +1773,11 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
+ uniform = &shProg->Uniforms->Uniforms[location];
+
if (shProg->VertexProgram) {
/* convert uniform location to program parameter index */
- GLint index = shProg->Uniforms->Uniforms[location].VertPos;
+ GLint index = uniform->VertPos;
if (index >= 0) {
set_program_uniform_matrix(ctx, &shProg->VertexProgram->Base,
index, offset,
@@ -1781,7 +1787,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
if (shProg->FragmentProgram) {
/* convert uniform location to program parameter index */
- GLint index = shProg->Uniforms->Uniforms[location].FragPos;
+ GLint index = uniform->FragPos;
if (index >= 0) {
set_program_uniform_matrix(ctx, &shProg->FragmentProgram->Base,
index, offset,
@@ -1789,7 +1795,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
}
}
- shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
+ uniform->Initialized = GL_TRUE;
}