Mesa (master): glsl: asst. clean-ups in set_program_uniform()

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 26 20:49:44 UTC 2009


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

Author: Brian Paul <brianp at vmware.com>
Date:   Wed Aug 26 14:35:45 2009 -0600

glsl: asst. clean-ups in set_program_uniform()

Remove redunant type check for samplers (assert instead).
Move some local vars.  Update comments.

---

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

diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index 1b604f0..23aca30 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1612,10 +1612,8 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
                     GLenum type, GLsizei count, GLint elems,
                     const void *values)
 {
-   struct gl_program_parameter *param =
+   const struct gl_program_parameter *param =
       &program->Parameters->Parameters[index];
-   const GLboolean isUniformBool = is_boolean_type(param->DataType);
-   const GLboolean areIntValues = is_integer_type(type);
 
    assert(offset >= 0);
    assert(elems >= 1);
@@ -1635,17 +1633,10 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
       /* This controls which texture unit which is used by a sampler */
       GLint i;
 
-      /* data type for setting samplers must be int */
-      if (type != GL_INT) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
-                     "glUniform(only glUniform1i can be used "
-                     "to set sampler uniforms)");
-         return;
-      }
+      /* this should have been caught by the compatible_types() check */
+      ASSERT(type == GL_INT);
 
-      /* XXX arrays of samplers haven't been tested much, but it's not a
-       * common thing...
-       */
+      /* loop over number of samplers to change */
       for (i = 0; i < count; i++) {
          GLuint sampler =
             (GLuint) program->Parameters->ParameterValues[index + offset + i][0];
@@ -1674,9 +1665,11 @@ set_program_uniform(GLcontext *ctx, struct gl_program *program,
    }
    else {
       /* ordinary uniform variable */
-      GLsizei k, i;
+      const GLboolean isUniformBool = is_boolean_type(param->DataType);
+      const GLboolean areIntValues = is_integer_type(type);
       const GLint slots = (param->Size + 3) / 4;
       const GLint typeSize = sizeof_glsl_type(param->DataType);
+      GLsizei k, i;
 
       if (param->Size > typeSize) {
          /* an array */




More information about the mesa-commit mailing list