Commit 78f41805 by Jamie Madill

Refactor GetUniform validator helpers.

BUG=angle:571 Change-Id: I7b36c7af38b102a24dc0e5d5d87fc042533e90af Reviewed-on: https://chromium-review.googlesource.com/212933Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 99a1e985
...@@ -1671,7 +1671,7 @@ bool ValidateFramebufferTexture2D(const gl::Context *context, GLenum target, GLe ...@@ -1671,7 +1671,7 @@ 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) bool ValidateGetUniformBase(const gl::Context *context, GLuint program, GLint location)
{ {
if (program == 0) if (program == 0)
{ {
...@@ -1694,48 +1694,24 @@ bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint loca ...@@ -1694,48 +1694,24 @@ bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint loca
return true; return true;
} }
bool ValidateGetUniformiv(const gl::Context *context, GLuint program, GLint location, GLint* params) bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint location, GLfloat* params)
{ {
if (program == 0) return ValidateGetUniformBase(context, program, location);
{
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) bool ValidateGetUniformiv(const gl::Context *context, GLuint program, GLint location, GLint* params)
{ {
if (program == 0) return ValidateGetUniformBase(context, program, location);
{ }
return gl::error(GL_INVALID_VALUE, false);
}
gl::Program *programObject = context->getProgram(program);
if (!programObject || !programObject->isLinked()) static bool ValidateSizedGetUniform(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize)
{
if (!ValidateGetUniformBase(context, program, location))
{ {
return gl::error(GL_INVALID_OPERATION, false); return false;
} }
gl::ProgramBinary *programBinary = programObject->getProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
if (!programBinary)
{
return gl::error(GL_INVALID_OPERATION, false);
}
// sized queries -- ensure the provided buffer is large enough // sized queries -- ensure the provided buffer is large enough
LinkedUniform *uniform = programBinary->getUniformByLocation(location); LinkedUniform *uniform = programBinary->getUniformByLocation(location);
...@@ -1748,35 +1724,14 @@ bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint ...@@ -1748,35 +1724,14 @@ bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint
return true; return true;
} }
bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params) bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params)
{ {
if (program == 0) return ValidateSizedGetUniform(context, program, location, bufSize);
{ }
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);
}
// sized queries -- ensure the provided buffer is large enough
LinkedUniform *uniform = programBinary->getUniformByLocation(location);
size_t requiredBytes = VariableExternalSize(uniform->type);
if (static_cast<size_t>(bufSize) < requiredBytes)
{
return gl::error(GL_INVALID_OPERATION, false);
}
return true; bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLint* params)
{
return ValidateSizedGetUniform(context, program, location, bufSize);
} }
} }
...@@ -75,6 +75,7 @@ bool ValidateFramebufferTextureBase(const gl::Context *context, GLenum target, G ...@@ -75,6 +75,7 @@ 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 ValidateGetUniformBase(const gl::Context *context, GLuint program, GLint location);
bool ValidateGetUniformfv(const gl::Context *context, GLuint program, GLint location, GLfloat* params); 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 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 ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint location, GLsizei bufSize, GLfloat* params);
......
...@@ -1215,25 +1215,7 @@ bool ValidateGetUniformuiv(const gl::Context *context, GLuint program, GLint loc ...@@ -1215,25 +1215,7 @@ bool ValidateGetUniformuiv(const gl::Context *context, GLuint program, GLint loc
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (program == 0) return ValidateGetUniformBase(context, program, location);
{
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;
} }
} }
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