Commit d7c7bb27 by Jamie Madill

Refactor UniformMatrix validation.

Move the shared validation logic to validationES.cpp. BUG=angle:571 Change-Id: I2fb06a012703c647de2176914238b48665145c6f Reviewed-on: https://chromium-review.googlesource.com/200073Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 82b42271
......@@ -5580,31 +5580,16 @@ void __stdcall glUniformMatrix2fv(GLint location, GLsizei count, GLboolean trans
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (transpose != GL_FALSE && context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2, location, count, transpose))
{
return gl::error(GL_INVALID_VALUE);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -5624,31 +5609,16 @@ void __stdcall glUniformMatrix3fv(GLint location, GLsizei count, GLboolean trans
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (transpose != GL_FALSE && context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3, location, count, transpose))
{
return gl::error(GL_INVALID_VALUE);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -5668,31 +5638,16 @@ void __stdcall glUniformMatrix4fv(GLint location, GLsizei count, GLboolean trans
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (transpose != GL_FALSE && context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4, location, count, transpose))
{
return gl::error(GL_INVALID_VALUE);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6754,31 +6709,16 @@ void __stdcall glUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x3, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix2x3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6798,31 +6738,16 @@ void __stdcall glUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x2, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix3x2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6842,31 +6767,16 @@ void __stdcall glUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT2x4, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix2x4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6886,31 +6796,16 @@ void __stdcall glUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x2, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix4x2fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6930,31 +6825,16 @@ void __stdcall glUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT3x4, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix3x4fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......@@ -6974,31 +6854,16 @@ void __stdcall glUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean tra
try
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext();
if (context)
{
if (context->getClientVersion() < 3)
if (!ValidateUniformMatrix(context, GL_FLOAT_MAT4x3, location, count, transpose))
{
return gl::error(GL_INVALID_OPERATION);
return;
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniformMatrix4x3fv(location, count, transpose, value))
{
return gl::error(GL_INVALID_OPERATION);
......
......@@ -946,4 +946,40 @@ bool ValidateEndQuery(gl::Context *context, GLenum target)
return true;
}
bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose)
{
if (count < 0)
{
return gl::error(GL_INVALID_VALUE, false);
}
// Check for ES3 uniform entry points
int rows = VariableRowCount(matrixType);
int cols = VariableColumnCount(matrixType);
if (rows != cols && context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_OPERATION, false);
}
if (transpose != GL_FALSE && context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_VALUE, false);
}
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION, false);
}
if (location == -1)
{
// Silently ignore the uniform command
return false;
}
return true;
}
}
......@@ -48,6 +48,9 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id);
bool ValidateEndQuery(gl::Context *context, GLenum target);
bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose);
}
#endif // LIBGLESV2_VALIDATION_ES_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment