summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brian.paul@tungstengraphics.com>2008-09-16 08:55:54 -0600
committerBrian Paul <brian.paul@tungstengraphics.com>2008-09-16 08:55:54 -0600
commitea9568dfbe7415db1a529ca4ecc1b9c41cae10b1 (patch)
tree2525faae7588951f5192ae9a36ee277f15cef556 /src
parent753635f733c5548ac8e662e792f65d41b454052a (diff)
mesa: fix bug in get_uniform_rows_cols(): sometimes returned too many rows
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/shader_api.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index d8b210be53..a86ef56c65 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1108,7 +1108,8 @@ get_matrix_dims(GLenum type, GLint *rows, GLint *cols)
/**
* Determine the number of rows and columns occupied by a uniform
- * according to its datatype.
+ * according to its datatype. For non-matrix types (such as GL_FLOAT_VEC4),
+ * the number of rows = 1 and cols = number of elements in the vector.
*/
static void
get_uniform_rows_cols(const struct gl_program_parameter *p,
@@ -1117,11 +1118,17 @@ 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 */
- *rows = p->Size / 4 + 1;
- if (p->Size % 4 == 0)
- *cols = 4;
- else
- *cols = p->Size % 4;
+ if (p->Size <= 4) {
+ *rows = 1;
+ *cols = p->Size;
+ }
+ else {
+ *rows = p->Size / 4 + 1;
+ if (p->Size % 4 == 0)
+ *cols = 4;
+ else
+ *cols = p->Size % 4;
+ }
}
}