mesa: add Initialized field to gl_uniform struct, for debugging purposes only
authorBrian Paul <brian.paul@tungstengraphics.com>
Wed, 5 Nov 2008 16:14:19 +0000 (09:14 -0700)
committerBrian Paul <brian.paul@tungstengraphics.com>
Wed, 5 Nov 2008 16:14:19 +0000 (09:14 -0700)
src/mesa/shader/prog_uniform.c
src/mesa/shader/prog_uniform.h
src/mesa/shader/shader_api.c

index f57df3d86dcb3b129647f7c02c8dec9c029bf6ce..a0aa615c5f62c4a93596dccecaea3b500200764d 100644 (file)
@@ -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++;
    }
index 735de28705a5b3024336af8ed6568f29e50e3dac..deea7329912b2f905e2ca1f364498cbdf0e0f9d1 100644 (file)
@@ -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) */
index decdec53ed2140f374c3e38d97c16b63d3c0e12c..468fbd7ed2dbe282d6a5211b657a2735b62d8af7 100644 (file)
@@ -1507,10 +1507,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;
    }
@@ -1520,7 +1522,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;
 
@@ -1551,9 +1553,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;
       }
@@ -1562,7 +1564,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++) {
@@ -1577,7 +1580,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.0f : 0.0f;
             }
@@ -1661,6 +1664,8 @@ _mesa_uniform(GLcontext *ctx, GLint location, GLsizei count,
                              index, offset, type, count, elems, values);
       }
    }
+
+   shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
 }
 
 
@@ -1771,6 +1776,8 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
                                     count, rows, cols, transpose, values);
       }
    }
+
+   shProg->Uniforms->Uniforms[location].Initialized = GL_TRUE;
 }