Commit a98a647e by Frank Henigman Committed by Commit Bot

Add uniform1iv validation functions.

Add two new validation functions: ValidateUniform1iv() and ValidateProgramUniform1iv(). No functional change, just hooks for additional sampler uniform validation that will come later. This also lets us skip the sampler test in the more generic ValidateUniformValue() function. BUG=angleproject:1711 Change-Id: Ia6b7b45c22c2cf4b49a55fac62410ca4c91d09f4 Reviewed-on: https://chromium-review.googlesource.com/436884Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent f5f74ae0
......@@ -1417,12 +1417,34 @@ bool ValidateUniformCommonBase(gl::Context *context,
return true;
}
bool ValidateUniform1ivValue(gl::Context *context,
GLenum uniformType,
GLsizei count,
const GLint *value)
{
// Value type is GL_INT, because we only get here from glUniform1i{v}.
// It is compatible with INT or BOOL.
// Do these cheap tests first, for a little extra speed.
if (GL_INT == uniformType || GL_BOOL == uniformType)
{
return true;
}
if (IsSamplerType(uniformType))
{
// TODO(fjhenigman): check values against GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS
return true;
}
context->handleError(Error(GL_INVALID_OPERATION, "wrong type of value for uniform"));
return false;
}
bool ValidateUniformValue(gl::Context *context, GLenum valueType, GLenum uniformType)
{
// Check that the value type is compatible with uniform type.
// Do the cheaper tests first, for a little extra speed.
if (valueType == uniformType || (valueType == GL_INT && IsSamplerType(uniformType)) ||
VariableBoolVectorType(valueType) == uniformType)
// Do the cheaper test first, for a little extra speed.
if (valueType == uniformType || VariableBoolVectorType(valueType) == uniformType)
{
return true;
}
......@@ -2793,6 +2815,25 @@ bool ValidateProgramUniform(gl::Context *context,
ValidateUniformValue(context, valueType, uniform->type);
}
bool ValidateProgramUniform1iv(gl::Context *context,
GLuint program,
GLint location,
GLsizei count,
const GLint *value)
{
// Check for ES31 program uniform entry points
if (context->getClientVersion() < Version(3, 1))
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
}
const LinkedUniform *uniform = nullptr;
gl::Program *programObject = GetValidProgram(context, program);
return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
ValidateUniform1ivValue(context, uniform->type, count, value);
}
bool ValidateProgramUniformMatrix(gl::Context *context,
GLenum valueType,
GLuint program,
......@@ -2828,6 +2869,14 @@ bool ValidateUniform(gl::Context *context, GLenum valueType, GLint location, GLs
ValidateUniformValue(context, valueType, uniform->type);
}
bool ValidateUniform1iv(gl::Context *context, GLint location, GLsizei count, const GLint *value)
{
const LinkedUniform *uniform = nullptr;
gl::Program *programObject = context->getGLState().getProgram();
return ValidateUniformCommonBase(context, programObject, location, count, &uniform) &&
ValidateUniform1ivValue(context, uniform->type, count, value);
}
bool ValidateUniformMatrix(gl::Context *context,
GLenum valueType,
GLint location,
......
......@@ -196,6 +196,11 @@ bool ValidateProgramUniform(Context *context,
GLuint program,
GLint location,
GLsizei count);
bool ValidateProgramUniform1iv(Context *context,
GLuint program,
GLint location,
GLsizei count,
const GLint *value);
bool ValidateProgramUniformMatrix(Context *context,
GLenum matrixType,
GLuint program,
......@@ -204,6 +209,7 @@ bool ValidateProgramUniformMatrix(Context *context,
GLboolean transpose);
bool ValidateUniform(Context *context, GLenum uniformType, GLint location, GLsizei count);
bool ValidateUniform1iv(Context *context, GLint location, GLsizei count, const GLint *value);
bool ValidateUniformMatrix(Context *context,
GLenum matrixType,
GLint location,
......
......@@ -2352,7 +2352,7 @@ void GL_APIENTRY Uniform1iv(GLint location, GLsizei count, const GLint* v)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateUniform(context, GL_INT, location, count))
if (!ValidateUniform1iv(context, location, count, v))
{
return;
}
......
......@@ -417,7 +417,7 @@ void GL_APIENTRY ProgramUniform1iv(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateProgramUniform(context, GL_INT, program, location, count))
if (!ValidateProgramUniform1iv(context, program, location, count, value))
{
return;
}
......
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