Commit 38f2cfb8 by Geoff Lang Committed by Commit Bot

Refactor validation of glGetSynciv.

BUG=angleproject:1985 Change-Id: Idf1057e6d8d8c850643e3b2a22be5a881c8a2301 Reviewed-on: https://chromium-review.googlesource.com/474550Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 58337799
...@@ -4010,6 +4010,12 @@ void Context::renderbufferStorageMultisample(GLenum target, ...@@ -4010,6 +4010,12 @@ void Context::renderbufferStorageMultisample(GLenum target,
renderbuffer->setStorageMultisample(samples, convertedInternalFormat, width, height)); renderbuffer->setStorageMultisample(samples, convertedInternalFormat, width, height));
} }
void Context::getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values)
{
const FenceSync *syncObject = getFenceSync(sync);
handleError(QuerySynciv(syncObject, pname, values));
}
void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params) void Context::getFramebufferParameteriv(GLenum target, GLenum pname, GLint *params)
{ {
Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target); Framebuffer *framebuffer = mGLState.getTargetFramebuffer(target);
......
...@@ -571,6 +571,8 @@ class Context final : public ValidationContext ...@@ -571,6 +571,8 @@ class Context final : public ValidationContext
GLsizei width, GLsizei width,
GLsizei height); GLsizei height);
void getSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
// CHROMIUM_framebuffer_mixed_samples // CHROMIUM_framebuffer_mixed_samples
void setCoverageModulation(GLenum components); void setCoverageModulation(GLenum components);
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/Config.h" #include "libANGLE/Config.h"
#include "libANGLE/Context.h" #include "libANGLE/Context.h"
#include "libANGLE/Fence.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
...@@ -887,6 +888,33 @@ void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, G ...@@ -887,6 +888,33 @@ void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, G
} }
} }
Error QuerySynciv(const FenceSync *sync, GLenum pname, GLint *values)
{
ASSERT(sync);
switch (pname)
{
case GL_OBJECT_TYPE:
*values = ConvertToGLint(GL_SYNC_FENCE);
break;
case GL_SYNC_CONDITION:
*values = ConvertToGLint(sync->getCondition());
break;
case GL_SYNC_FLAGS:
*values = ConvertToGLint(sync->getFlags());
break;
case GL_SYNC_STATUS:
ANGLE_TRY(sync->getStatus(values));
break;
default:
UNREACHABLE();
break;
}
return NoError();
}
void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param) void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param)
{ {
SetTexParameterBase(texture, pname, &param); SetTexParameterBase(texture, pname, &param);
......
...@@ -18,6 +18,8 @@ namespace gl ...@@ -18,6 +18,8 @@ namespace gl
{ {
class Buffer; class Buffer;
class Context; class Context;
class Error;
class FenceSync;
class Framebuffer; class Framebuffer;
class Program; class Program;
class Renderbuffer; class Renderbuffer;
...@@ -95,6 +97,8 @@ void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufS ...@@ -95,6 +97,8 @@ void QueryInternalFormativ(const TextureCaps &format, GLenum pname, GLsizei bufS
void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params); void QueryFramebufferParameteriv(const Framebuffer *framebuffer, GLenum pname, GLint *params);
Error QuerySynciv(const FenceSync *sync, GLenum pname, GLint *values);
void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param); void SetTexParameterf(Texture *texture, GLenum pname, GLfloat param);
void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params); void SetTexParameterfv(Texture *texture, GLenum pname, const GLfloat *params);
void SetTexParameteri(Texture *texture, GLenum pname, GLint param); void SetTexParameteri(Texture *texture, GLenum pname, GLint param);
......
...@@ -2434,4 +2434,47 @@ bool ValidateVertexAttribIPointer(ValidationContext *context, ...@@ -2434,4 +2434,47 @@ bool ValidateVertexAttribIPointer(ValidationContext *context,
return true; return true;
} }
bool ValidateGetSynciv(Context *context,
GLsync sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(
Error(GL_INVALID_OPERATION, "GetSynciv requires OpenGL ES 3.0 or higher."));
return false;
}
if (bufSize < 0)
{
context->handleError(Error(GL_INVALID_VALUE, "bufSize cannot be negative."));
return false;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{
context->handleError(Error(GL_INVALID_VALUE, "Invalid sync object."));
return false;
}
switch (pname)
{
case GL_OBJECT_TYPE:
case GL_SYNC_CONDITION:
case GL_SYNC_FLAGS:
case GL_SYNC_STATUS:
break;
default:
context->handleError(Error(GL_INVALID_ENUM, "Invalid pname."));
return false;
}
return true;
}
} // namespace gl } // namespace gl
...@@ -384,6 +384,13 @@ bool ValidateVertexAttribIPointer(ValidationContext *context, ...@@ -384,6 +384,13 @@ bool ValidateVertexAttribIPointer(ValidationContext *context,
GLsizei stride, GLsizei stride,
const GLvoid *pointer); const GLvoid *pointer);
bool ValidateGetSynciv(Context *context,
GLsync sync,
GLenum pname,
GLsizei bufSize,
GLsizei *length,
GLint *values);
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES3_H_ #endif // LIBANGLE_VALIDATION_ES3_H_
...@@ -1700,47 +1700,13 @@ void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei* ...@@ -1700,47 +1700,13 @@ void GL_APIENTRY GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei*
Context *context = GetValidGlobalContext(); Context *context = GetValidGlobalContext();
if (context) if (context)
{ {
if (context->getClientMajorVersion() < 3) if (!context->skipValidation() &&
{ !ValidateGetSynciv(context, sync, pname, bufSize, length, values))
context->handleError(Error(GL_INVALID_OPERATION));
return;
}
if (bufSize < 0)
{
context->handleError(Error(GL_INVALID_VALUE));
return;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{ {
context->handleError(Error(GL_INVALID_VALUE));
return; return;
} }
switch (pname) context->getSynciv(sync, pname, bufSize, length, values);
{
case GL_OBJECT_TYPE: values[0] = static_cast<GLint>(GL_SYNC_FENCE); break;
case GL_SYNC_CONDITION: values[0] = static_cast<GLint>(fenceSync->getCondition()); break;
case GL_SYNC_FLAGS: values[0] = static_cast<GLint>(fenceSync->getFlags()); break;
case GL_SYNC_STATUS:
{
Error error = fenceSync->getStatus(values);
if (error.isError())
{
context->handleError(error);
return;
}
break;
}
default:
context->handleError(Error(GL_INVALID_ENUM));
return;
}
} }
} }
......
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