Commit 7f0c5a4b by Jamie Madill Committed by Commit Bot

Refactor sync EPs (plus one extra).

More entry point validation refactor for auto-gen. BUG=angleproject:747 Change-Id: I9462a28838df3f265e1401f66c838cc5a73d511f Reviewed-on: https://chromium-review.googlesource.com/636517Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 7e1197e0
......@@ -606,13 +606,6 @@ GLuint Context::createRenderbuffer()
return mState.mRenderbuffers->createRenderbuffer();
}
GLsync Context::createFenceSync()
{
GLuint handle = mState.mFenceSyncs->createFenceSync(mImplementation.get());
return reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle));
}
GLuint Context::createPaths(GLsizei range)
{
auto resultOrError = mState.mPaths->createPaths(mImplementation.get(), range);
......@@ -682,14 +675,13 @@ void Context::deleteRenderbuffer(GLuint renderbuffer)
mState.mRenderbuffers->deleteObject(this, renderbuffer);
}
void Context::deleteFenceSync(GLsync fenceSync)
void Context::deleteSync(GLsync sync)
{
// The spec specifies the underlying Fence object is not deleted until all current
// wait commands finish. However, since the name becomes invalid, we cannot query the fence,
// and since our API is currently designed for being called from a single thread, we can delete
// the fence immediately.
mState.mFenceSyncs->deleteObject(this,
static_cast<GLuint>(reinterpret_cast<uintptr_t>(fenceSync)));
mState.mFenceSyncs->deleteObject(this, static_cast<GLuint>(reinterpret_cast<uintptr_t>(sync)));
}
void Context::deletePaths(GLuint first, GLsizei range)
......@@ -1599,7 +1591,7 @@ void Context::getIntegervImpl(GLenum pname, GLint *params)
}
}
void Context::getInteger64v(GLenum pname, GLint64 *params)
void Context::getInteger64vImpl(GLenum pname, GLint64 *params)
{
// Queries about context capabilities and maximums are answered by Context.
// Queries about current GL state values are answered by State.
......@@ -5175,4 +5167,57 @@ void Context::uniformBlockBinding(GLuint program,
programObject->bindUniformBlock(uniformBlockIndex, uniformBlockBinding);
}
GLsync Context::fenceSync(GLenum condition, GLbitfield flags)
{
GLuint handle = mState.mFenceSyncs->createFenceSync(mImplementation.get());
GLsync fenceSync = reinterpret_cast<GLsync>(static_cast<uintptr_t>(handle));
FenceSync *fenceSyncObject = getFenceSync(fenceSync);
Error error = fenceSyncObject->set(condition, flags);
if (error.isError())
{
deleteSync(fenceSync);
handleError(error);
return nullptr;
}
return fenceSync;
}
GLboolean Context::isSync(GLsync sync)
{
return (getFenceSync(sync) != nullptr);
}
GLenum Context::clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
{
FenceSync *syncObject = getFenceSync(sync);
GLenum result = GL_WAIT_FAILED;
handleError(syncObject->clientWait(flags, timeout, &result));
return result;
}
void Context::waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
{
FenceSync *syncObject = getFenceSync(sync);
handleError(syncObject->serverWait(flags, timeout));
}
void Context::getInteger64v(GLenum pname, GLint64 *params)
{
GLenum nativeType = GL_NONE;
unsigned int numParams = 0;
getQueryParameterInfo(pname, &nativeType, &numParams);
if (nativeType == GL_INT_64_ANGLEX)
{
getInteger64vImpl(pname, params);
}
else
{
CastStateValues(this, nativeType, pname, numParams, params);
}
}
} // namespace gl
......@@ -85,7 +85,6 @@ class Context final : public ValidationContext
GLuint createTexture();
GLuint createRenderbuffer();
GLuint createSampler();
GLsync createFenceSync();
GLuint createPaths(GLsizei range);
void deleteBuffer(GLuint buffer);
......@@ -94,7 +93,6 @@ class Context final : public ValidationContext
void deleteTexture(GLuint texture);
void deleteRenderbuffer(GLuint renderbuffer);
void deleteSampler(GLuint sampler);
void deleteFenceSync(GLsync fenceSync);
void deletePaths(GLuint first, GLsizei range);
// CHROMIUM_path_rendering
......@@ -253,7 +251,7 @@ class Context final : public ValidationContext
void getFloatvImpl(GLenum pname, GLfloat *params);
void getIntegerv(GLenum pname, GLint *params);
void getIntegervImpl(GLenum pname, GLint *params);
void getInteger64v(GLenum pname, GLint64 *params);
void getInteger64vImpl(GLenum pname, GLint64 *params);
void getPointerv(GLenum pname, void **params) const;
void getBooleani_v(GLenum target, GLuint index, GLboolean *data);
void getIntegeri_v(GLenum target, GLuint index, GLint *data);
......@@ -861,6 +859,13 @@ class Context final : public ValidationContext
GLchar *uniformBlockName);
void uniformBlockBinding(GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding);
GLsync fenceSync(GLenum condition, GLbitfield flags);
GLboolean isSync(GLsync sync);
void deleteSync(GLsync sync);
GLenum clientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
void waitSync(GLsync sync, GLbitfield flags, GLuint64 timeout);
void getInteger64v(GLenum pname, GLint64 *params);
// Returns the error.
Error handleError(const Error &error) override;
......
......@@ -3373,4 +3373,128 @@ bool ValidateDrawArraysInstanced(Context *context,
return ValidateDrawArraysInstancedBase(context, mode, first, count, primcount);
}
bool ValidateFenceSync(Context *context, GLenum condition, GLbitfield flags)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
{
context->handleError(InvalidEnum());
return false;
}
if (flags != 0)
{
context->handleError(InvalidValue());
return false;
}
return true;
}
bool ValidateIsSync(Context *context, GLsync sync)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
return true;
}
bool ValidateDeleteSync(Context *context, GLsync sync)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
{
context->handleError(InvalidValue());
return false;
}
return true;
}
bool ValidateClientWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
{
context->handleError(InvalidValue());
return false;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{
context->handleError(InvalidValue());
return false;
}
return true;
}
bool ValidateWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
if (flags != 0)
{
context->handleError(InvalidValue());
return false;
}
if (timeout != GL_TIMEOUT_IGNORED)
{
context->handleError(InvalidValue());
return false;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{
context->handleError(InvalidValue());
return false;
}
return true;
}
bool ValidateGetInteger64v(Context *context, GLenum pname, GLint64 *params)
{
if (context->getClientMajorVersion() < 3)
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ES3Required);
return false;
}
GLenum nativeType = GL_NONE;
unsigned int numParams = 0;
if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
{
return false;
}
return true;
}
} // namespace gl
......@@ -552,6 +552,13 @@ bool ValidateDrawArraysInstanced(Context *context,
GLsizei count,
GLsizei primcount);
bool ValidateFenceSync(Context *context, GLenum condition, GLbitfield flags);
bool ValidateIsSync(Context *context, GLsync sync);
bool ValidateDeleteSync(Context *context, GLsync sync);
bool ValidateClientWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout);
bool ValidateWaitSync(Context *context, GLsync sync, GLbitfield flags, GLuint64 timeout);
bool ValidateGetInteger64v(Context *context, GLenum pname, GLint64 *params);
} // namespace gl
#endif // LIBANGLE_VALIDATION_ES3_H_
......@@ -1455,36 +1455,12 @@ GLsync GL_APIENTRY FenceSync_(GLenum condition, GLbitfield flags)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(InvalidOperation());
return 0;
}
if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE)
{
context->handleError(InvalidEnum());
return 0;
}
if (flags != 0)
{
context->handleError(InvalidValue());
return 0;
}
GLsync fenceSync = context->createFenceSync();
FenceSync *fenceSyncObject = context->getFenceSync(fenceSync);
Error error = fenceSyncObject->set(condition, flags);
if (error.isError())
if (!context->skipValidation() && !ValidateFenceSync(context, condition, flags))
{
context->deleteFenceSync(fenceSync);
context->handleError(error);
return nullptr;
}
return fenceSync;
return context->fenceSync(condition, flags);
}
return nullptr;
......@@ -1497,13 +1473,12 @@ GLboolean GL_APIENTRY IsSync(GLsync sync)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
if (!context->skipValidation() && !ValidateIsSync(context, sync))
{
context->handleError(InvalidOperation());
return GL_FALSE;
}
return (context->getFenceSync(sync) != nullptr);
return context->isSync(sync);
}
return GL_FALSE;
......@@ -1516,19 +1491,12 @@ void GL_APIENTRY DeleteSync(GLsync sync)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(InvalidOperation());
return;
}
if (sync != static_cast<GLsync>(0) && !context->getFenceSync(sync))
if (!context->skipValidation() && !ValidateDeleteSync(context, sync))
{
context->handleError(InvalidValue());
return;
}
context->deleteFenceSync(sync);
context->deleteSync(sync);
}
}
......@@ -1540,38 +1508,15 @@ GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeou
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(InvalidOperation());
return GL_WAIT_FAILED;
}
if ((flags & ~(GL_SYNC_FLUSH_COMMANDS_BIT)) != 0)
if (!context->skipValidation() && !ValidateClientWaitSync(context, sync, flags, timeout))
{
context->handleError(InvalidValue());
return GL_WAIT_FAILED;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{
context->handleError(InvalidValue());
return GL_WAIT_FAILED;
}
GLenum result = GL_WAIT_FAILED;
Error error = fenceSync->clientWait(flags, timeout, &result);
if (error.isError())
{
context->handleError(error);
return GL_WAIT_FAILED;
}
return result;
return context->clientWaitSync(sync, flags, timeout);
}
return GL_FALSE;
return GL_WAIT_FAILED;
}
void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
......@@ -1582,37 +1527,12 @@ void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
{
context->handleError(InvalidOperation());
return;
}
if (flags != 0)
if (!context->skipValidation() && !ValidateWaitSync(context, sync, flags, timeout))
{
context->handleError(InvalidValue());
return;
}
if (timeout != GL_TIMEOUT_IGNORED)
{
context->handleError(InvalidValue());
return;
}
FenceSync *fenceSync = context->getFenceSync(sync);
if (!fenceSync)
{
context->handleError(InvalidValue());
return;
}
Error error = fenceSync->serverWait(flags, timeout);
if (error.isError())
{
context->handleError(error);
}
context->waitSync(sync, flags, timeout);
}
}
......@@ -1623,27 +1543,12 @@ void GL_APIENTRY GetInteger64v(GLenum pname, GLint64 *params)
Context *context = GetValidGlobalContext();
if (context)
{
if (context->getClientMajorVersion() < 3)
if (!context->skipValidation() && !ValidateGetInteger64v(context, pname, params))
{
context->handleError(InvalidOperation());
return;
}
GLenum nativeType;
unsigned int numParams = 0;
if (!ValidateStateQuery(context, pname, &nativeType, &numParams))
{
return;
}
if (nativeType == GL_INT_64_ANGLEX)
{
context->getInteger64v(pname, params);
}
else
{
CastStateValues(context, nativeType, pname, numParams, params);
}
context->getInteger64v(pname, params);
}
}
......@@ -1680,6 +1585,7 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64 *data)
{
return;
}
context->getInteger64i_v(target, index, data);
}
}
......
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