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/200074
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 99a99d0..6ed8bf6 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -5228,26 +5228,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_FLOAT, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform1fv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5271,26 +5261,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_INT, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform1iv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5316,26 +5296,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_FLOAT_VEC2, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform2fv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5361,26 +5331,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_INT_VEC2, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform2iv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5406,26 +5366,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_FLOAT_VEC3, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform3fv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5451,26 +5401,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_INT_VEC3, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform3iv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5496,26 +5436,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_FLOAT_VEC4, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform4fv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -5541,26 +5471,16 @@
try
{
- if (count < 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- if (location == -1)
- {
- return;
- }
-
gl::Context *context = gl::getNonLostContext();
if (context)
{
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary)
+ if (!ValidateUniform(context, GL_INT_VEC4, location, count))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
+ gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
if (!programBinary->setUniform4iv(location, count, v))
{
return gl::error(GL_INVALID_OPERATION);
@@ -7974,17 +7894,12 @@
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();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniform1uiv(location, count, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -8008,17 +7923,12 @@
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();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniform2uiv(location, count, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -8042,17 +7952,12 @@
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();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniform3uiv(location, count, value))
{
return gl::error(GL_INVALID_OPERATION);
@@ -8076,17 +7981,12 @@
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();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
if (!programBinary->setUniform4uiv(location, count, value))
{
return gl::error(GL_INVALID_OPERATION);