Mesa (master): mesa: add Initialized field to gl_uniform struct, for debugging purposes only

Brian Paul brianp at kemper.freedesktop.org
Wed Nov 5 23:05:53 UTC 2008


Module: Mesa
Branch: master
Commit: 949e7383b597563b5603ba9b63fcfa4b1f45cf42
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=949e7383b597563b5603ba9b63fcfa4b1f45cf42

Author: Brian Paul <brian.paul at tungstengraphics.com>
Date:   Wed Nov  5 09:17:55 2008 -0700

mesa: add Initialized field to gl_uniform struct, for debugging purposes only

---

 src/mesa/shader/prog_uniform.c |    1 +
 src/mesa/shader/prog_uniform.h |    1 +
 src/mesa/shader/shader_api.c   |   21 ++++++++++++++-------
 3 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/src/mesa/shader/prog_uniform.c b/src/mesa/shader/prog_uniform.c
index f57df3d..a0aa615 100644
--- a/src/mesa/shader/prog_uniform.c
+++ b/src/mesa/shader/prog_uniform.c
@@ -87,6 +87,7 @@ _mesa_append_uniform(struct gl_uniform_list *list,
       list->Uniforms[oldNum].Name = _mesa_strdup(name);
       list->Uniforms[oldNum].VertPos = -1;
       list->Uniforms[oldNum].FragPos = -1;
+      list->Uniforms[oldNum].Initialized = GL_FALSE;
       index = oldNum;
       list->NumUniforms++;
    }
diff --git a/src/mesa/shader/prog_uniform.h b/src/mesa/shader/prog_uniform.h
index 735de28..deea732 100644
--- a/src/mesa/shader/prog_uniform.h
+++ b/src/mesa/shader/prog_uniform.h
@@ -50,6 +50,7 @@ struct gl_uniform
    const char *Name;        /**< Null-terminated string */
    GLint VertPos;
    GLint FragPos;
+   GLboolean Initialized;   /**< For debug.  Has this uniform been set? */
 #if 0
    GLenum DataType;         /**< GL_FLOAT, GL_FLOAT_VEC2, etc */
    GLuint Size;             /**< Number of components (1..4) */
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 504d769..4fc9f3d 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1505,10 +1505,12 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
                     GLenum type, GLsizei count, GLint elems,
                     const void *values)
 {
+   struct gl_program_parameter *param =
+      &program->Parameters->Parameters[index];
+
    assert(offset >= 0);
 
-   if (!compatible_types(type,
-                         program->Parameters->Parameters[index].DataType)) {
+   if (!compatible_types(type, param->DataType)) {
       _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(type mismatch)");
       return;
    }
@@ -1518,7 +1520,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
       return;
    }
 
-   if (program->Parameters->Parameters[index].Type == PROGRAM_SAMPLER) {
+   if (param->Type == PROGRAM_SAMPLER) {
       /* This controls which texture unit which is used by a sampler */
       GLuint texUnit, sampler;
 
@@ -1549,9 +1551,9 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
    else {
       /* ordinary uniform variable */
       GLsizei k, i;
-      GLint slots = (program->Parameters->Parameters[index].Size + 3) / 4;
+      GLint slots = (param->Size + 3) / 4;
 
-      if (count * elems > (GLint) program->Parameters->Parameters[index].Size) {
+      if (count * elems > (GLint) param->Size) {
          _mesa_error(ctx, GL_INVALID_OPERATION, "glUniform(count too large)");
          return;
       }
@@ -1560,7 +1562,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
          count = slots;
 
       for (k = 0; k < count; k++) {
-         GLfloat *uniformVal = program->Parameters->ParameterValues[index + offset + k];
+         GLfloat *uniformVal =
+            program->Parameters->ParameterValues[index + offset + k];
          if (is_integer_type(type)) {
             const GLint *iValues = ((const GLint *) values) + k * elems;
             for (i = 0; i < elems; i++) {
@@ -1575,7 +1578,7 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
          }
 
          /* if the uniform is bool-valued, convert to 1.0 or 0.0 */
-         if (is_boolean_type(program->Parameters->Parameters[index].DataType)) {
+         if (is_boolean_type(param->DataType)) {
             for (i = 0; i < elems; i++) {
                uniformVal[i] = uniformVal[i] ? 1.0 : 0.0;
             }
@@ -1659,6 +1662,8 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
                              index, offset, type, count, elems, values);
       }
    }
+
+   shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
 }
 
 
@@ -1769,6 +1774,8 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
                                     count, rows, cols, transpose, values);
       }
    }
+
+   shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
 }
 
 




More information about the mesa-commit mailing list