Move GetUniform validation to the validation layer.
BUG=angle:571
Change-Id: Id1b7afb22d8bd52dbf7f95f4e8cac3fc8f798596
Reviewed-on: https://chromium-review.googlesource.com/212931
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 103d4ff..a2fea54 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -3014,23 +3014,13 @@
if (context)
{
- if (program == 0)
+ if (!ValidateGetnUniformfvEXT(context, program, location, bufSize, params))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
+ gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
+ ASSERT(programBinary);
if (!programBinary->getUniformfv(location, &bufSize, params))
{
@@ -3047,23 +3037,13 @@
if (context)
{
- if (program == 0)
+ if (!ValidateGetUniformfv(context, program, location, params))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
+ gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
+ ASSERT(programBinary);
if (!programBinary->getUniformfv(location, NULL, params))
{
@@ -3086,23 +3066,13 @@
if (context)
{
- if (program == 0)
+ if (!ValidateGetnUniformivEXT(context, program, location, bufSize, params))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
+ gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
+ ASSERT(programBinary);
if (!programBinary->getUniformiv(location, &bufSize, params))
{
@@ -3119,23 +3089,13 @@
if (context)
{
- if (program == 0)
+ if (!ValidateGetUniformiv(context, program, location, params))
{
- return gl::error(GL_INVALID_VALUE);
+ return;
}
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
+ gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
+ ASSERT(programBinary);
if (!programBinary->getUniformiv(location, NULL, params))
{
@@ -6251,28 +6211,13 @@
if (context)
{
- if (context->getClientVersion() < 3)
+ if (!ValidateGetUniformuiv(context, program, location, params))
{
- return gl::error(GL_INVALID_OPERATION);
+ return;
}
- if (program == 0)
- {
- return gl::error(GL_INVALID_VALUE);
- }
-
- gl::Program *programObject = context->getProgram(program);
-
- if (!programObject || !programObject->isLinked())
- {
- return gl::error(GL_INVALID_OPERATION);
- }
-
- gl::ProgramBinary *programBinary = programObject->getProgramBinary();
- if (!programBinary)
- {
- return gl::error(GL_INVALID_OPERATION);
- }
+ gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
+ ASSERT(programBinary);
if (!programBinary->getUniformuiv(location, NULL, params))
{
diff --git a/src/libGLESv2/validationES.cpp b/src/libGLESv2/validationES.cpp
index 8225df9..6981e29 100644
--- a/src/libGLESv2/validationES.cpp
+++ b/src/libGLESv2/validationES.cpp
@@ -1671,4 +1671,96 @@
return true;
}
+bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint location, GLfloat* params)
+{
+ if (program == 0)
+ {
+ return gl::error(GL_INVALID_VALUE, false);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ gl::ProgramBinary *programBinary = programObject->getProgramBinary();
+ if (!programBinary)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ return true;
+}
+
+bool ValidateGetUniformiv(const gl::Context *context, GLuint program, GLint location, GLint* params)
+{
+ if (program == 0)
+ {
+ return gl::error(GL_INVALID_VALUE, false);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ gl::ProgramBinary *programBinary = programObject->getProgramBinary();
+ if (!programBinary)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ return true;
+}
+
+bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
+{
+ if (program == 0)
+ {
+ return gl::error(GL_INVALID_VALUE, false);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ gl::ProgramBinary *programBinary = programObject->getProgramBinary();
+ if (!programBinary)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ return true;
+}
+
+bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params)
+{
+ if (program == 0)
+ {
+ return gl::error(GL_INVALID_VALUE, false);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ gl::ProgramBinary *programBinary = programObject->getProgramBinary();
+ if (!programBinary)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ return true;
+}
+
}
diff --git a/src/libGLESv2/validationES.h b/src/libGLESv2/validationES.h
index 7266cd4..b04e5cd 100644
--- a/src/libGLESv2/validationES.h
+++ b/src/libGLESv2/validationES.h
@@ -75,6 +75,11 @@
bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level);
+bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint location, GLfloat* params);
+bool ValidateGetUniformiv(const gl::Context *context, GLuint program, GLint location, GLint* params);
+bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params);
+bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params);
+
}
#endif // LIBGLESV2_VALIDATION_ES_H
diff --git a/src/libGLESv2/validationES3.cpp b/src/libGLESv2/validationES3.cpp
index 66c41e6..c534b3a 100644
--- a/src/libGLESv2/validationES3.cpp
+++ b/src/libGLESv2/validationES3.cpp
@@ -1208,4 +1208,32 @@
return true;
}
+bool ValidateGetUniformuiv(const gl::Context *context, GLuint program, GLint location, GLuint* params)
+{
+ if (context->getClientVersion() < 3)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ if (program == 0)
+ {
+ return gl::error(GL_INVALID_VALUE, false);
+ }
+
+ gl::Program *programObject = context->getProgram(program);
+
+ if (!programObject || !programObject->isLinked())
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ gl::ProgramBinary *programBinary = programObject->getProgramBinary();
+ if (!programBinary)
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
+ return true;
+}
+
}
diff --git a/src/libGLESv2/validationES3.h b/src/libGLESv2/validationES3.h
index 4d068bd..9d20000 100644
--- a/src/libGLESv2/validationES3.h
+++ b/src/libGLESv2/validationES3.h
@@ -35,6 +35,8 @@
bool ValidateClearBuffer(const gl::Context *context);
+bool ValidateGetUniformuiv(const gl::Context *context, GLuint program, GLint location, GLuint* params);
+
}
#endif // LIBGLESV2_VALIDATION_ES3_H