Make use of count in _mesa_uniform_matrix

This commit is contained in:
Bruce Merry
2007-12-21 16:04:43 +02:00
committed by Brian
parent 239be839be
commit 3f948025db

View File

@@ -1278,6 +1278,7 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
GLenum matrixType, GLint location, GLsizei count, GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose, const GLfloat *values) GLboolean transpose, const GLfloat *values)
{ {
GLsizei maxCount, i;
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram; struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
if (!shProg || !shProg->LinkStatus) { if (!shProg || !shProg->LinkStatus) {
_mesa_error(ctx, GL_INVALID_OPERATION, _mesa_error(ctx, GL_INVALID_OPERATION,
@@ -1297,6 +1298,10 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
_mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix"); _mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix");
return; return;
} }
if (count < 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glUniformMatrix(count < 0)");
return;
}
FLUSH_VERTICES(ctx, _NEW_PROGRAM); FLUSH_VERTICES(ctx, _NEW_PROGRAM);
@@ -1305,6 +1310,10 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
* the rows. * the rows.
*/ */
/* XXXX need to test 3x3 and 2x2 matrices... */ /* XXXX need to test 3x3 and 2x2 matrices... */
maxCount = shProg->Uniforms->Parameters[location].Size / (4 * cols);
if (count > maxCount)
count = maxCount;
for (i = 0; i < count; i++) {
if (transpose) { if (transpose) {
GLuint row, col; GLuint row, col;
for (col = 0; col < cols; col++) { for (col = 0; col < cols; col++) {
@@ -1323,6 +1332,9 @@ _mesa_uniform_matrix(GLcontext *ctx, GLint cols, GLint rows,
} }
} }
} }
location += cols;
values += rows * cols;
}
} }