summaryrefslogtreecommitdiffstats
path: root/src/mesa/main/uniforms.c
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2011-01-27 12:24:27 -0800
committerIan Romanick <[email protected]>2011-02-01 09:48:41 -0800
commit20d278a7ff0ce66e5c4ac437e1fbe52c31a1ecb3 (patch)
tree02fa330ee33adf263a8545b56379470631eeb6ac /src/mesa/main/uniforms.c
parent3c701f1d61b33a5ffaddd4199ac277da8e287f30 (diff)
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.
Diffstat (limited to 'src/mesa/main/uniforms.c')
-rw-r--r--src/mesa/main/uniforms.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index aee2e6b4e9b..eb289722d1a 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -450,6 +450,36 @@ _mesa_get_active_uniform(struct gl_context *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)
@@ -508,17 +538,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);
}
}
@@ -642,8 +663,10 @@ _mesa_get_uniformfv(struct gl_context *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];
}
}
}
@@ -675,8 +698,10 @@ _mesa_get_uniformiv(struct gl_context *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];
}
}
}
@@ -709,8 +734,10 @@ _mesa_get_uniformuiv(struct gl_context *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++] = (GLuint) prog->Parameters->ParameterValues[paramPos+i][j];
+ params[k++] = (GLuint) prog->Parameters->ParameterValues[base][j];
}
}
}