Mesa (7.9): mesa: glGetUniform only returns a single element of an array

Ian Romanick idr at kemper.freedesktop.org
Mon Feb 21 23:07:13 UTC 2011


Module: Mesa
Branch: 7.9
Commit: ac270e43e68338834b44f3391ac4342cd75c2631
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=ac270e43e68338834b44f3391ac4342cd75c2631

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Thu Jan 27 12:24:27 2011 -0800

mesa: glGetUniform only returns a single element of an array

Also return it as the correct type.  Previously the whole array would
be returned and each element would be expanded to a vec4.

Fixes piglit test getuniform-01 and bugzilla #29823.

(cherry picked from commit 20d278a7ff0ce66e5c4ac437e1fbe52c31a1ecb3)

---

 src/mesa/main/uniforms.c |   51 ++++++++++++++++++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 13 deletions(-)

diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 5224b03..40bb44c 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -215,6 +215,36 @@ _mesa_get_active_uniform(GLcontext *ctx, GLuint program, GLuint index,
 }
 
 
+static unsigned
+get_vector_elements(GLenum type)
+{
+   switch (type) {
+   case GL_FLOAT:
+   case GL_INT:
+   case GL_BOOL:
+   case GL_UNSIGNED_INT:
+   default: /* Catch all the various sampler types. */
+      return 1;
+
+   case GL_FLOAT_VEC2:
+   case GL_INT_VEC2:
+   case GL_BOOL_VEC2:
+   case GL_UNSIGNED_INT_VEC2:
+      return 2;
+
+   case GL_FLOAT_VEC3:
+   case GL_INT_VEC3:
+   case GL_BOOL_VEC3:
+   case GL_UNSIGNED_INT_VEC3:
+      return 3;
+
+   case GL_FLOAT_VEC4:
+   case GL_INT_VEC4:
+   case GL_BOOL_VEC4:
+   case GL_UNSIGNED_INT_VEC4:
+      return 4;
+   }
+}
 
 static void
 get_matrix_dims(GLenum type, GLint *rows, GLint *cols)
@@ -273,17 +303,8 @@ get_uniform_rows_cols(const struct gl_program_parameter *p,
    get_matrix_dims(p->DataType, rows, cols);
    if (*rows == 0 && *cols == 0) {
       /* not a matrix type, probably a float or vector */
-      if (p->Size <= 4) {
-         *rows = 1;
-         *cols = p->Size;
-      }
-      else {
-         *rows = (p->Size + 3) / 4;
-         if (p->Size % 4 == 0)
-            *cols = 4;
-         else
-            *cols = p->Size % 4;
-      }
+      *rows = 1;
+      *cols = get_vector_elements(p->DataType);
    }
 }
 
@@ -407,8 +428,10 @@ _mesa_get_uniformfv(GLcontext *ctx, GLuint program, GLint location,
 
       k = 0;
       for (i = 0; i < rows; i++) {
+	 const int base = paramPos + offset + i;
+
          for (j = 0; j < cols; j++ ) {
-            params[k++] = prog->Parameters->ParameterValues[paramPos+i][j];
+            params[k++] = prog->Parameters->ParameterValues[base][j];
          }
       }
    }
@@ -440,8 +463,10 @@ _mesa_get_uniformiv(GLcontext *ctx, GLuint program, GLint location,
 
       k = 0;
       for (i = 0; i < rows; i++) {
+	 const int base = paramPos + offset + i;
+
          for (j = 0; j < cols; j++ ) {
-            params[k++] = (GLint) prog->Parameters->ParameterValues[paramPos+i][j];
+            params[k++] = (GLint) prog->Parameters->ParameterValues[base][j];
          }
       }
    }




More information about the mesa-commit mailing list