Commit 0063c517 by Jamie Madill

Move GetUniform validation to the validation layer.

BUG=angle:571 Change-Id: Id1b7afb22d8bd52dbf7f95f4e8cac3fc8f798596 Reviewed-on: https://chromium-review.googlesource.com/212931Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 10f05630
...@@ -3014,23 +3014,13 @@ void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSiz ...@@ -3014,23 +3014,13 @@ void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSiz
if (context) 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(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary) ASSERT(programBinary);
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->getUniformfv(location, &bufSize, params)) if (!programBinary->getUniformfv(location, &bufSize, params))
{ {
...@@ -3047,23 +3037,13 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) ...@@ -3047,23 +3037,13 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
if (context) 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(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary) ASSERT(programBinary);
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->getUniformfv(location, NULL, params)) if (!programBinary->getUniformfv(location, NULL, params))
{ {
...@@ -3086,23 +3066,13 @@ void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSiz ...@@ -3086,23 +3066,13 @@ void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSiz
if (context) 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(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary) ASSERT(programBinary);
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->getUniformiv(location, &bufSize, params)) if (!programBinary->getUniformiv(location, &bufSize, params))
{ {
...@@ -3119,23 +3089,13 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) ...@@ -3119,23 +3089,13 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
if (context) 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(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary) ASSERT(programBinary);
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->getUniformiv(location, NULL, params)) if (!programBinary->getUniformiv(location, NULL, params))
{ {
...@@ -6251,28 +6211,13 @@ void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) ...@@ -6251,28 +6211,13 @@ void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
if (context) if (context)
{ {
if (context->getClientVersion() < 3) if (!ValidateGetUniformuiv(context, program, location, params))
{
return gl::error(GL_INVALID_OPERATION);
}
if (program == 0)
{ {
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(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary) ASSERT(programBinary);
{
return gl::error(GL_INVALID_OPERATION);
}
if (!programBinary->getUniformuiv(location, NULL, params)) if (!programBinary->getUniformuiv(location, NULL, params))
{ {
......
...@@ -1671,4 +1671,96 @@ bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLe ...@@ -1671,4 +1671,96 @@ bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLe
return true; 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;
}
} }
...@@ -75,6 +75,11 @@ bool ValidateFramebufferTextureBase(const gl::Context *context, GLenum target, G ...@@ -75,6 +75,11 @@ bool ValidateFramebufferTextureBase(const gl::Context *context, GLenum target, G
bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLenum attachment,
GLenum textarget, GLuint texture, GLint level); 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 #endif // LIBGLESV2_VALIDATION_ES_H
...@@ -1208,4 +1208,32 @@ bool ValidateClearBuffer(const gl::Context *context) ...@@ -1208,4 +1208,32 @@ bool ValidateClearBuffer(const gl::Context *context)
return true; 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;
}
} }
...@@ -35,6 +35,8 @@ bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target ...@@ -35,6 +35,8 @@ bool ValidateInvalidateFramebufferParameters(gl::Context *context, GLenum target
bool ValidateClearBuffer(const gl::Context *context); bool ValidateClearBuffer(const gl::Context *context);
bool ValidateGetUniformuiv(const gl::Context *context, GLuint program, GLint location, GLuint* params);
} }
#endif // LIBGLESV2_VALIDATION_ES3_H #endif // LIBGLESV2_VALIDATION_ES3_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