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) ...@@ -1961,6 +1961,15 @@ GLfloat Context::getSamplerParameterf(GLuint sampler, GLenum pname)
// clang-format on // 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() void Context::initRendererString()
{ {
std::ostringstream rendererString; std::ostringstream rendererString;
......
...@@ -147,6 +147,8 @@ class Context final : public ValidationContext ...@@ -147,6 +147,8 @@ class Context final : public ValidationContext
GLint getSamplerParameteri(GLuint sampler, GLenum pname); GLint getSamplerParameteri(GLuint sampler, GLenum pname);
GLfloat getSamplerParameterf(GLuint sampler, GLenum pname); GLfloat getSamplerParameterf(GLuint sampler, GLenum pname);
void programParameteri(GLuint program, GLenum pname, GLint value);
Buffer *getBuffer(GLuint handle) const; Buffer *getBuffer(GLuint handle) const;
FenceNV *getFenceNV(GLuint handle); FenceNV *getFenceNV(GLuint handle);
FenceSync *getFenceSync(GLsync handle) const; FenceSync *getFenceSync(GLsync handle) const;
......
...@@ -1583,11 +1583,11 @@ bool ValidateGetProgramBinary(Context *context, ...@@ -1583,11 +1583,11 @@ bool ValidateGetProgramBinary(Context *context,
return ValidateGetProgramBinaryBase(context, program, bufSize, length, binaryFormat, binary); 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) if (context->getClientVersion() < 3)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION, "Context does not support GLES3."));
return false; return false;
} }
...@@ -1599,6 +1599,12 @@ bool ValidateProgramParameter(Context *context, GLuint program, GLenum pname, GL ...@@ -1599,6 +1599,12 @@ bool ValidateProgramParameter(Context *context, GLuint program, GLenum pname, GL
switch (pname) switch (pname)
{ {
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT: 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; break;
default: default:
......
...@@ -201,7 +201,7 @@ bool ValidateGetProgramBinary(Context *context, ...@@ -201,7 +201,7 @@ bool ValidateGetProgramBinary(Context *context,
GLsizei *length, GLsizei *length,
GLenum *binaryFormat, GLenum *binaryFormat,
void *binary); 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, bool ValidateBlitFramebuffer(Context *context,
GLint srcX0, GLint srcX0,
GLint srcY0, GLint srcY0,
......
...@@ -2712,23 +2712,13 @@ void GL_APIENTRY ProgramParameteri(GLuint program, GLenum pname, GLint value) ...@@ -2712,23 +2712,13 @@ void GL_APIENTRY ProgramParameteri(GLuint program, GLenum pname, GLint value)
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (!ValidateProgramParameter(context, program, pname, value)) if (!context->skipValidation() &&
!ValidateProgramParameteri(context, program, pname, value))
{ {
return; return;
} }
gl::Program *programObject = context->getProgram(program); context->programParameteri(program, pname, value);
ASSERT(programObject != nullptr);
switch (pname)
{
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
programObject->setBinaryRetrievableHint(value != GL_FALSE);
break;
default:
UNREACHABLE();
}
} }
} }
......
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