egl/dri2: return the latest sync status in eglGetSyncAttribKHR
authorMarek Olšák <marek.olsak@amd.com>
Fri, 10 Apr 2015 21:35:39 +0000 (23:35 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 30 Apr 2015 12:38:38 +0000 (14:38 +0200)
src/egl/main/eglsync.c

index 3b4a88902fd21ac0e214992e5caa6869fc2a7790..8b8ab16b0d268ec3d7d0c0f3d3dae2009b2be663 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "eglsync.h"
 #include "eglcurrent.h"
+#include "egldriver.h"
 #include "egllog.h"
 
 
@@ -144,13 +145,19 @@ _eglGetSyncAttribKHR(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSync *sync,
                      EGLint attribute, EGLint *value)
 {
    if (!value)
-      return _eglError(EGL_BAD_PARAMETER, "eglGetConfigs");
+      return _eglError(EGL_BAD_PARAMETER, "eglGetSyncAttribKHR");
 
    switch (attribute) {
    case EGL_SYNC_TYPE_KHR:
       *value = sync->Type;
       break;
    case EGL_SYNC_STATUS_KHR:
+      /* update the sync status */
+      if (sync->SyncStatus != EGL_SIGNALED_KHR &&
+          (sync->Type == EGL_SYNC_FENCE_KHR ||
+           sync->Type == EGL_SYNC_CL_EVENT_KHR))
+         drv->API.ClientWaitSyncKHR(drv, dpy, sync, 0, 0);
+
       *value = sync->SyncStatus;
       break;
    case EGL_SYNC_CONDITION_KHR: