summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruce Merry <[email protected]>2007-12-21 16:04:43 +0200
committerBrian <[email protected]>2008-01-01 09:59:50 -0700
commite9ac27ee23ef3672a608b85dd3d7c6165aad4611 (patch)
treea3f704cecde49de4e9889ddbecd532fbbe6a3a04 /src
parent3f9dc9f5b6278c01120bcec0c6609bd756eb7a7b (diff)
Make use of count in _mesa_uniform_matrix
Diffstat (limited to 'src')
-rw-r--r--src/mesa/shader/shader_api.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/mesa/shader/shader_api.c b/src/mesa/shader/shader_api.c
index cdedac29c4a..8eb3e41e693 100644
--- a/src/mesa/shader/shader_api.c
+++ b/src/mesa/shader/shader_api.c
@@ -1279,6 +1279,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose, const GLfloat *values)
{
+ GLsizei maxCount, i;
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
if (!shProg || !shProg->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1298,6 +1299,10 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
_mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix");
return;
}
+ if (count < 0) {
+ _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(count < 0)");
+ return;
+ }
FLUSH_VERTICES(ctx, _NEW_PROGRAM);
@@ -1306,23 +1311,30 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
* the rows.
*/
/* XXXX need to test 3x3 and 2x2 matrices... */
- if (transpose) {
- GLuint row, col;
- for (col = 0; col < cols; col++) {
- GLfloat *v = shProg->Uniforms->ParameterValues[location + col];
- for (row = 0; row < rows; row++) {
- v[row] = values[row * cols + col];
+ maxCount = shProg->Uniforms->Parameters[location].Size / (4 * cols);
+ if (count > maxCount)
+ count = maxCount;
+ for (i = 0; i < count; i++) {
+ if (transpose) {
+ GLuint row, col;
+ for (col = 0; col < cols; col++) {
+ GLfloat *v = shProg->Uniforms->ParameterValues[location + col];
+ for (row = 0; row < rows; row++) {
+ v[row] = values[row * cols + col];
+ }
}
}
- }
- else {
- GLuint row, col;
- for (col = 0; col < cols; col++) {
- GLfloat *v = shProg->Uniforms->ParameterValues[location + col];
- for (row = 0; row < rows; row++) {
- v[row] = values[col * rows + row];
+ else {
+ GLuint row, col;
+ for (col = 0; col < cols; col++) {
+ GLfloat *v = shProg->Uniforms->ParameterValues[location + col];
+ for (row = 0; row < rows; row++) {
+ v[row] = values[col * rows + row];
+ }
}
}
+ location += cols;
+ values += rows * cols;
}
}