Commit 99a1e985 by Jamie Madill

Move GetUniform size validation to top layer.

BUG=angle:571 Change-Id: Ie7064cf85f6a125ccd6cdf1bff89443520e2a06d Reviewed-on: https://chromium-review.googlesource.com/212932Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 5599c8f6
...@@ -841,20 +841,10 @@ void ProgramBinary::setUniform4uiv(GLint location, GLsizei count, const GLuint * ...@@ -841,20 +841,10 @@ void ProgramBinary::setUniform4uiv(GLint location, GLsizei count, const GLuint *
} }
template <typename T> template <typename T>
bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLenum uniformType) void ProgramBinary::getUniformv(GLint location, T *params, GLenum uniformType)
{ {
LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index]; LinkedUniform *targetUniform = mUniforms[mUniformIndex[location].index];
// sized queries -- ensure the provided buffer is large enough
if (bufSize)
{
int requiredBytes = VariableExternalSize(targetUniform->type);
if (*bufSize < requiredBytes)
{
return false;
}
}
if (IsMatrixType(targetUniform->type)) if (IsMatrixType(targetUniform->type))
{ {
const int rows = VariableRowCount(targetUniform->type); const int rows = VariableRowCount(targetUniform->type);
...@@ -919,23 +909,21 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe ...@@ -919,23 +909,21 @@ bool ProgramBinary::getUniformv(GLint location, GLsizei *bufSize, T *params, GLe
default: UNREACHABLE(); default: UNREACHABLE();
} }
} }
return true;
} }
bool ProgramBinary::getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params) void ProgramBinary::getUniformfv(GLint location, GLfloat *params)
{ {
return getUniformv(location, bufSize, params, GL_FLOAT); getUniformv(location, params, GL_FLOAT);
} }
bool ProgramBinary::getUniformiv(GLint location, GLsizei *bufSize, GLint *params) void ProgramBinary::getUniformiv(GLint location, GLint *params)
{ {
return getUniformv(location, bufSize, params, GL_INT); getUniformv(location, params, GL_INT);
} }
bool ProgramBinary::getUniformuiv(GLint location, GLsizei *bufSize, GLuint *params) void ProgramBinary::getUniformuiv(GLint location, GLuint *params)
{ {
return getUniformv(location, bufSize, params, GL_UNSIGNED_INT); getUniformv(location, params, GL_UNSIGNED_INT);
} }
void ProgramBinary::dirtyAllUniforms() void ProgramBinary::dirtyAllUniforms()
......
...@@ -125,9 +125,9 @@ class ProgramBinary : public RefCountObject ...@@ -125,9 +125,9 @@ class ProgramBinary : public RefCountObject
void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value); void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
bool getUniformfv(GLint location, GLsizei *bufSize, GLfloat *params); void getUniformfv(GLint location, GLfloat *params);
bool getUniformiv(GLint location, GLsizei *bufSize, GLint *params); void getUniformiv(GLint location, GLint *params);
bool getUniformuiv(GLint location, GLsizei *bufSize, GLuint *params); void getUniformuiv(GLint location, GLuint *params);
void dirtyAllUniforms(); void dirtyAllUniforms();
void applyUniforms(); void applyUniforms();
...@@ -234,7 +234,7 @@ class ProgramBinary : public RefCountObject ...@@ -234,7 +234,7 @@ class ProgramBinary : public RefCountObject
void setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType); void setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType);
template <typename T> template <typename T>
bool getUniformv(GLint location, GLsizei *bufSize, T *params, GLenum uniformType); void getUniformv(GLint location, T *params, GLenum uniformType);
class VertexExecutable class VertexExecutable
{ {
......
...@@ -3022,10 +3022,7 @@ void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSiz ...@@ -3022,10 +3022,7 @@ void __stdcall glGetnUniformfvEXT(GLuint program, GLint location, GLsizei bufSiz
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
ASSERT(programBinary); ASSERT(programBinary);
if (!programBinary->getUniformfv(location, &bufSize, params)) programBinary->getUniformfv(location, params);
{
return gl::error(GL_INVALID_OPERATION);
}
} }
} }
...@@ -3045,10 +3042,7 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params) ...@@ -3045,10 +3042,7 @@ void __stdcall glGetUniformfv(GLuint program, GLint location, GLfloat* params)
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
ASSERT(programBinary); ASSERT(programBinary);
if (!programBinary->getUniformfv(location, NULL, params)) programBinary->getUniformfv(location, params);
{
return gl::error(GL_INVALID_OPERATION);
}
} }
} }
...@@ -3074,10 +3068,7 @@ void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSiz ...@@ -3074,10 +3068,7 @@ void __stdcall glGetnUniformivEXT(GLuint program, GLint location, GLsizei bufSiz
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
ASSERT(programBinary); ASSERT(programBinary);
if (!programBinary->getUniformiv(location, &bufSize, params)) programBinary->getUniformiv(location, params);
{
return gl::error(GL_INVALID_OPERATION);
}
} }
} }
...@@ -3097,10 +3088,7 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params) ...@@ -3097,10 +3088,7 @@ void __stdcall glGetUniformiv(GLuint program, GLint location, GLint* params)
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
ASSERT(programBinary); ASSERT(programBinary);
if (!programBinary->getUniformiv(location, NULL, params)) programBinary->getUniformiv(location, params);
{
return gl::error(GL_INVALID_OPERATION);
}
} }
} }
...@@ -6219,10 +6207,7 @@ void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params) ...@@ -6219,10 +6207,7 @@ void __stdcall glGetUniformuiv(GLuint program, GLint location, GLuint* params)
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary();
ASSERT(programBinary); ASSERT(programBinary);
if (!programBinary->getUniformuiv(location, NULL, params)) programBinary->getUniformuiv(location, params);
{
return gl::error(GL_INVALID_OPERATION);
}
} }
} }
......
...@@ -1737,6 +1737,14 @@ bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint ...@@ -1737,6 +1737,14 @@ bool ValidateGetnUniformfvEXT(const gl::Context *context, GLuint program, GLint
return gl::error(GL_INVALID_OPERATION, false); 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; return true;
} }
...@@ -1760,6 +1768,14 @@ bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint ...@@ -1760,6 +1768,14 @@ bool ValidateGetnUniformivEXT(const gl::Context *context, GLuint program, GLint
return gl::error(GL_INVALID_OPERATION, false); 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; 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