diff --git a/src/libANGLE/EGLSync.cpp b/src/libANGLE/EGLSync.cpp index f43401386..a7010a80d 100644 --- a/src/libANGLE/EGLSync.cpp +++ b/src/libANGLE/EGLSync.cpp @@ -18,7 +18,9 @@ namespace egl { Sync::Sync(rx::EGLImplFactory *factory, EGLenum type, const AttributeMap &attribs) - : mFence(factory->createSync(attribs)), mType(type) + : mFence(factory->createSync(attribs)), + mLabel(nullptr), + mType(type) {} void Sync::onDestroy(const Display *display) @@ -35,6 +37,16 @@ Error Sync::initialize(const Display *display, const gl::Context *context) return mFence->initialize(display, context, mType); } +void Sync::setLabel(EGLLabelKHR label) +{ + mLabel = label; +} + +EGLLabelKHR Sync::getLabel() const +{ + return mLabel; +} + Error Sync::clientWait(const Display *display, const gl::Context *context, EGLint flags, diff --git a/src/libANGLE/EGLSync.h b/src/libANGLE/EGLSync.h index 0a40ebe6e..986f52d5b 100644 --- a/src/libANGLE/EGLSync.h +++ b/src/libANGLE/EGLSync.h @@ -29,12 +29,15 @@ class Context; namespace egl { -class Sync final : public angle::RefCountObject +class Sync final : public angle::RefCountObject, public LabeledObject { public: Sync(rx::EGLImplFactory *factory, EGLenum type, const AttributeMap &attribs); ~Sync() override; + void setLabel(EGLLabelKHR label) override; + EGLLabelKHR getLabel() const override; + void onDestroy(const Display *display) override; Error initialize(const Display *display, const gl::Context *context); @@ -52,6 +55,8 @@ class Sync final : public angle::RefCountObject private: std::unique_ptr mFence; + EGLLabelKHR mLabel; + EGLenum mType; static constexpr EGLint mCondition = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; }; diff --git a/src/libANGLE/validationEGL.cpp b/src/libANGLE/validationEGL.cpp index 64c49e920..8c6f825ef 100644 --- a/src/libANGLE/validationEGL.cpp +++ b/src/libANGLE/validationEGL.cpp @@ -700,11 +700,9 @@ Error ValidateLabeledObject(Thread *thread, case ObjectType::Sync: { - ANGLE_TRY(ValidateDisplay(display)); - // TODO(geofflang): Implement sync objects. http://anglebug.com/2466 - UNIMPLEMENTED(); - return EglBadDisplay() << "Sync objects are unimplemented."; - + Sync *sync = static_cast(object); + ANGLE_TRY(ValidateSync(display, sync)); + *outLabeledObject = sync; break; } diff --git a/src/libANGLE/validationEGL.h b/src/libANGLE/validationEGL.h index 58aa3cc77..35018cb8b 100644 --- a/src/libANGLE/validationEGL.h +++ b/src/libANGLE/validationEGL.h @@ -43,7 +43,7 @@ Error ValidateConfig(const Display *display, const Config *config); Error ValidateContext(const Display *display, const gl::Context *context); Error ValidateImage(const Display *display, const Image *image); Error ValidateDevice(const Device *device); -Error ValidateSync(const Device *device, const Sync *sync); +Error ValidateSync(const Display *display, const Sync *sync); // Return the requested object only if it is valid (otherwise nullptr) const Thread *GetThreadIfValid(const Thread *thread); diff --git a/src/libGLESv2/entry_points_egl.cpp b/src/libGLESv2/entry_points_egl.cpp index 6db7b02ac..ce981531e 100644 --- a/src/libGLESv2/entry_points_egl.cpp +++ b/src/libGLESv2/entry_points_egl.cpp @@ -881,13 +881,13 @@ EGLint EGLAPIENTRY EGL_ClientWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateClientWaitSync(display, syncObject, flags, timeout), - "eglClientWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglClientWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); gl::Context *currentContext = thread->getContext(); EGLint syncStatus = EGL_FALSE; ANGLE_EGL_TRY_RETURN( thread, syncObject->clientWait(display, currentContext, flags, timeout, &syncStatus), - "eglClientWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglClientWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); thread->setSuccess(); return syncStatus; @@ -909,11 +909,11 @@ EGLBoolean EGLAPIENTRY EGL_GetSyncAttrib(EGLDisplay dpy, egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateGetSyncAttrib(display, syncObject, attribute, value), - "eglGetSyncAttrib", GetDisplayIfValid(display), EGL_FALSE); + "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE); EGLint valueExt; ANGLE_EGL_TRY_RETURN(thread, GetSyncAttrib(display, syncObject, attribute, &valueExt), - "eglGetSyncAttrib", GetDisplayIfValid(display), EGL_FALSE); + "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE); *value = valueExt; thread->setSuccess(); @@ -1064,11 +1064,11 @@ EGLBoolean EGLAPIENTRY EGL_WaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags) egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateWaitSync(display, context, syncObject, flags), - "eglWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); gl::Context *currentContext = thread->getContext(); ANGLE_EGL_TRY_RETURN(thread, syncObject->serverWait(display, currentContext, flags), - "eglWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); thread->setSuccess(); return EGL_TRUE; diff --git a/src/libGLESv2/entry_points_egl_ext.cpp b/src/libGLESv2/entry_points_egl_ext.cpp index 0f06286fd..dacba8906 100644 --- a/src/libGLESv2/entry_points_egl_ext.cpp +++ b/src/libGLESv2/entry_points_egl_ext.cpp @@ -938,13 +938,13 @@ ANGLE_EXPORT EGLint EGLAPIENTRY EGL_ClientWaitSyncKHR(EGLDisplay dpy, egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateClientWaitSync(display, syncObject, flags, timeout), - "eglClientWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglClientWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); gl::Context *currentContext = thread->getContext(); EGLint syncStatus = EGL_FALSE; ANGLE_EGL_TRY_RETURN( thread, syncObject->clientWait(display, currentContext, flags, timeout, &syncStatus), - "eglClientWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglClientWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); thread->setSuccess(); return syncStatus; @@ -966,10 +966,10 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY EGL_GetSyncAttribKHR(EGLDisplay dpy, egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateGetSyncAttribKHR(display, syncObject, attribute, value), - "eglGetSyncAttrib", GetDisplayIfValid(display), EGL_FALSE); + "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE); ANGLE_EGL_TRY_RETURN(thread, GetSyncAttrib(display, syncObject, attribute, value), - "eglGetSyncAttrib", GetDisplayIfValid(display), EGL_FALSE); + "eglGetSyncAttrib", GetSyncIfValid(display, syncObject), EGL_FALSE); thread->setSuccess(); return EGL_TRUE; @@ -989,11 +989,11 @@ ANGLE_EXPORT EGLBoolean EGLAPIENTRY EGL_WaitSyncKHR(EGLDisplay dpy, EGLSync sync egl::Sync *syncObject = static_cast(sync); ANGLE_EGL_TRY_RETURN(thread, ValidateWaitSync(display, context, syncObject, flags), - "eglWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); gl::Context *currentContext = thread->getContext(); ANGLE_EGL_TRY_RETURN(thread, syncObject->serverWait(display, currentContext, flags), - "eglWaitSync", GetDisplayIfValid(display), EGL_FALSE); + "eglWaitSync", GetSyncIfValid(display, syncObject), EGL_FALSE); thread->setSuccess(); return EGL_TRUE;