Commit aa981bd7 by Jamie Madill

Refactor Uniform validation to validationES.cpp.

This patch also incidentally fixes some bugged validation in the new ES3 unsigned int uniform API entry points. BUG=angle:571 Change-Id: I89bd909467bd9418fe5ce3f246561765cf27a5e9 Reviewed-on: https://chromium-review.googlesource.com/200074Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d7c7bb27
...@@ -5228,26 +5228,16 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5228,26 +5228,16 @@ void __stdcall glUniform1fv(GLint location, GLsizei count, const GLfloat* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_FLOAT, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform1fv(location, count, v)) if (!programBinary->setUniform1fv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5271,26 +5261,16 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v) ...@@ -5271,26 +5261,16 @@ void __stdcall glUniform1iv(GLint location, GLsizei count, const GLint* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_INT, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform1iv(location, count, v)) if (!programBinary->setUniform1iv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5316,26 +5296,16 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5316,26 +5296,16 @@ void __stdcall glUniform2fv(GLint location, GLsizei count, const GLfloat* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform2fv(location, count, v)) if (!programBinary->setUniform2fv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5361,26 +5331,16 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v) ...@@ -5361,26 +5331,16 @@ void __stdcall glUniform2iv(GLint location, GLsizei count, const GLint* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_INT_VEC2, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform2iv(location, count, v)) if (!programBinary->setUniform2iv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5406,26 +5366,16 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5406,26 +5366,16 @@ void __stdcall glUniform3fv(GLint location, GLsizei count, const GLfloat* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform3fv(location, count, v)) if (!programBinary->setUniform3fv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5451,26 +5401,16 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v) ...@@ -5451,26 +5401,16 @@ void __stdcall glUniform3iv(GLint location, GLsizei count, const GLint* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_INT_VEC3, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform3iv(location, count, v)) if (!programBinary->setUniform3iv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5496,26 +5436,16 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v) ...@@ -5496,26 +5436,16 @@ void __stdcall glUniform4fv(GLint location, GLsizei count, const GLfloat* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform4fv(location, count, v)) if (!programBinary->setUniform4fv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -5541,26 +5471,16 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v) ...@@ -5541,26 +5471,16 @@ void __stdcall glUniform4iv(GLint location, GLsizei count, const GLint* v)
try try
{ {
if (count < 0)
{
return gl::error(GL_INVALID_VALUE);
}
if (location == -1)
{
return;
}
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); if (!ValidateUniform(context, GL_INT_VEC4, location, count))
if (!programBinary)
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform4iv(location, count, v)) if (!programBinary->setUniform4iv(location, count, v))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -7974,17 +7894,12 @@ void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value) ...@@ -7974,17 +7894,12 @@ void __stdcall glUniform1uiv(GLint location, GLsizei count, const GLuint* value)
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!ValidateUniform(context, GL_UNSIGNED_INT, location, count))
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniform1uiv(location, count, value)) if (!programBinary->setUniform1uiv(location, count, value))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -8008,17 +7923,12 @@ void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value) ...@@ -8008,17 +7923,12 @@ void __stdcall glUniform2uiv(GLint location, GLsizei count, const GLuint* value)
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC2, location, count))
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniform2uiv(location, count, value)) if (!programBinary->setUniform2uiv(location, count, value))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -8042,17 +7952,12 @@ void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value) ...@@ -8042,17 +7952,12 @@ void __stdcall glUniform3uiv(GLint location, GLsizei count, const GLuint* value)
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC3, location, count))
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniform3uiv(location, count, value)) if (!programBinary->setUniform3uiv(location, count, value))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
...@@ -8076,17 +7981,12 @@ void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value) ...@@ -8076,17 +7981,12 @@ void __stdcall glUniform4uiv(GLint location, GLsizei count, const GLuint* value)
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!ValidateUniform(context, GL_UNSIGNED_INT_VEC4, location, count))
{ {
return gl::error(GL_INVALID_OPERATION); return;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->setUniform4uiv(location, count, value)) if (!programBinary->setUniform4uiv(location, count, value))
{ {
return gl::error(GL_INVALID_OPERATION); return gl::error(GL_INVALID_OPERATION);
......
...@@ -946,40 +946,56 @@ bool ValidateEndQuery(gl::Context *context, GLenum target) ...@@ -946,40 +946,56 @@ bool ValidateEndQuery(gl::Context *context, GLenum target)
return true; return true;
} }
bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count, static bool ValidateUniformCommonBase(gl::Context *context, GLint location, GLsizei count)
GLboolean transpose)
{ {
if (count < 0) if (count < 0)
{ {
return gl::error(GL_INVALID_VALUE, false); return gl::error(GL_INVALID_VALUE, false);
} }
// Check for ES3 uniform entry points gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
int rows = VariableRowCount(matrixType); if (!programBinary)
int cols = VariableColumnCount(matrixType);
if (rows != cols && context->getClientVersion() < 3)
{ {
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (transpose != GL_FALSE && context->getClientVersion() < 3) if (location == -1)
{ {
return gl::error(GL_INVALID_VALUE, false); // Silently ignore the uniform command
return false;
} }
gl::ProgramBinary *programBinary = context->getCurrentProgramBinary(); return true;
if (!programBinary) }
bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, GLsizei count)
{
// Check for ES3 uniform entry points
if (UniformComponentType(uniformType) == GL_UNSIGNED_INT && context->getClientVersion() < 3)
{ {
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (location == -1) return ValidateUniformCommonBase(context, location, count);
}
bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose)
{
// Check for ES3 uniform entry points
int rows = VariableRowCount(matrixType);
int cols = VariableColumnCount(matrixType);
if (rows != cols && context->getClientVersion() < 3)
{ {
// Silently ignore the uniform command return gl::error(GL_INVALID_OPERATION, false);
return false;
} }
return true; if (transpose != GL_FALSE && context->getClientVersion() < 3)
{
return gl::error(GL_INVALID_VALUE, false);
}
return ValidateUniformCommonBase(context, location, count);
} }
} }
...@@ -48,6 +48,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize ...@@ -48,6 +48,7 @@ bool ValidateReadPixelsParameters(gl::Context *context, GLint x, GLint y, GLsize
bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id); bool ValidateBeginQuery(gl::Context *context, GLenum target, GLuint id);
bool ValidateEndQuery(gl::Context *context, GLenum target); bool ValidateEndQuery(gl::Context *context, GLenum target);
bool ValidateUniform(gl::Context *context, GLenum uniformType, GLint location, GLsizei count);
bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count, bool ValidateUniformMatrix(gl::Context *context, GLenum matrixType, GLint location, GLsizei count,
GLboolean transpose); GLboolean transpose);
......
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