Commit f0fee07a by Olli Etuaho Committed by Commit Bot

Fix ProgramParameteri validation

dEQP tests suggest that passing a value other than GL_FALSE or GL_TRUE to ProgramParameteri generates INVALID_VALUE. The code is also refactored so that the implementation of ProgramParameteri is in the Context object. BUG=angleproject:1101 TEST=dEQP-GLES3.functional.negative_api.shader.program_parameteri Change-Id: I432d19fb574e58a7e0059189ab5b1863de029cdc Reviewed-on: https://chromium-review.googlesource.com/336163Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 0c0d8006
......@@ -1961,6 +1961,15 @@ GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
// clang-format on
}
void Context::programParameteri(GLuint program, GLenum pname, GLint value)
{
gl::Program *programObject = getProgram(program);
ASSERT(programObject != nullptr);
ASSERT(pname == GL_PROGRAM_BINARY_RETRIEVABLE_HINT);
programObject->setBinaryRetrievableHint(value != GL_FALSE);
}
void Context::initRendererString()
{
std::ostringstream rendererString;
......
......@@ -147,6 +147,8 @@ class Context final : public ValidationContext
GLint getSamplerParameteri(GLuint sampler, GLenum pname);
GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
void programParameteri(GLuint program, GLenum pname, GLint value);
Buffer *getBuffer(GLuint handle) const;
FenceNV *getFenceNV(GLuint handle);
FenceSync *getFenceSync(GLsync handle) const;
......
......@@ -1583,11 +1583,11 @@ bool ValidateGetProgramBinary(Context *context,
return ValidateGetProgramBinaryBase(context, program, bufSize, length, binaryFormat, binary);
}
bool ValidateProgramParameter(Context *context, GLuint program, GLenum pname, GLint value)
bool ValidateProgramParameteri(Context *context, GLuint program, GLenum pname, GLint value)
{
if (context->getClientVersion() < 3)
{
context->recordError(Error(GL_INVALID_OPERATION));
context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false;
}
......@@ -1599,6 +1599,12 @@ bool ValidateProgramParameter(Context *context, GLuint program, GLenum pname, GL
switch (pname)
{
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
if (value != GL_FALSE && value != GL_TRUE)
{
context->recordError(Error(
GL_INVALID_VALUE, "Invalid value, expected GL_FALSE or GL_TRUE: %i", value));
return false;
}
break;
default:
......
......@@ -201,7 +201,7 @@ bool ValidateGetProgramBinary(Context *context,
GLsizei *length,
GLenum *binaryFormat,
void *binary);
bool ValidateProgramParameter(Context *context, GLuint program, GLenum pname, GLint value);
bool ValidateProgramParameteri(Context *context, GLuint program, GLenum pname, GLint value);
bool ValidateBlitFramebuffer(Context *context,
GLint srcX0,
GLint srcY0,
......
......@@ -2712,23 +2712,13 @@ void GL_APIENTRY ProgramParameteri(GLuint program, GLenum pname, GLint value)
Context *context = GetValidGlobalContext();
if (context)
{
if (!ValidateProgramParameter(context, program, pname, value))
if (!context->skipValidation() &&
!ValidateProgramParameteri(context, program, pname, value))
{
return;
}
gl::Program *programObject = context->getProgram(program);
ASSERT(programObject != nullptr);
switch (pname)
{
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
programObject->setBinaryRetrievableHint(value != GL_FALSE);
break;
default:
UNREACHABLE();
}
context->programParameteri(program, pname, value);
}
}
......
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