intel: fix waiting of present fences
authorChia-I Wu <olv@lunarg.com>
Wed, 25 Feb 2015 22:06:15 +0000 (15:06 -0700)
committerChia-I Wu <olv@lunarg.com>
Thu, 26 Feb 2015 03:11:13 +0000 (11:11 +0800)
For presentation fences, we should wait until the server has submitted the
presentation command to the kernel _and_ the GPU has executed the command.
We failed to wait for the latter until this fix.

icd/intel/fence.c
icd/intel/fence.h
icd/intel/wsi_x11.c

index 75c2843..debcd7e 100644 (file)
@@ -81,36 +81,41 @@ void intel_fence_set_seqno(struct intel_fence *fence,
 void intel_fence_set_x11(struct intel_fence *fence,
                          struct intel_wsi_x11 *x11,
                          struct intel_wsi_x11_window *win,
-                         uint32_t serial)
+                         uint32_t serial,
+                         struct intel_bo *seqno_bo)
 {
-    if (fence->seqno_bo) {
-        intel_bo_unreference(fence->seqno_bo);
-        fence->seqno_bo = NULL;
-    }
-
 #ifdef ENABLE_WSI_X11
     fence->x11 = x11;
     fence->x11_win = win;
     fence->x11_serial = serial;
 #endif
+
+    if (fence->seqno_bo)
+        intel_bo_unreference(fence->seqno_bo);
+
+    fence->seqno_bo = seqno_bo;
+    intel_bo_reference(fence->seqno_bo);
 }
 
 XGL_RESULT intel_fence_wait(struct intel_fence *fence, int64_t timeout_ns)
 {
-    if (fence->seqno_bo) {
-        return (intel_bo_wait(fence->seqno_bo, timeout_ns)) ?
-            XGL_NOT_READY : XGL_SUCCESS;
-    }
-
 #ifdef ENABLE_WSI_X11
     if (fence->x11) {
         const bool wait = (timeout_ns != 0);
+        XGL_RESULT ret;
 
-        return intel_wsi_x11_wait(fence->x11, fence->x11_win,
+        ret = intel_wsi_x11_wait(fence->x11, fence->x11_win,
                 fence->x11_serial, wait);
+        if (ret != XGL_SUCCESS)
+            return ret;
     }
 #endif
 
+    if (fence->seqno_bo) {
+        return (intel_bo_wait(fence->seqno_bo, timeout_ns)) ?
+            XGL_NOT_READY : XGL_SUCCESS;
+    }
+
     return XGL_ERROR_UNAVAILABLE;
 }
 
index 70b4f2a..3ed450b 100644 (file)
@@ -70,6 +70,7 @@ void intel_fence_set_seqno(struct intel_fence *fence,
 void intel_fence_set_x11(struct intel_fence *fence,
                          struct intel_wsi_x11 *x11,
                          struct intel_wsi_x11_window *win,
-                         uint32_t serial);
+                         uint32_t serial,
+                         struct intel_bo *seqno_bo);
 
 #endif /* FENCE_H */
index c8dfd0a..582aa70 100644 (file)
@@ -639,8 +639,12 @@ ICD_EXPORT XGL_RESULT XGLAPI xglWsiX11QueuePresent(
     if (ret != XGL_SUCCESS)
         return ret;
 
-    if (fence)
-        intel_fence_set_x11(fence, x11, win, win->local.serial);
+    if (fence) {
+        struct intel_img *img = intel_img(pPresentInfo->srcImage);
+
+        intel_fence_set_x11(fence, x11, win, win->local.serial,
+                img->obj.mem->bo);
+    }
 
     return XGL_SUCCESS;
 }