drivers/svga, winsys/svga/drm: Thread through timeout for fence_finish
authorSinclair Yeh <syeh@vmware.com>
Wed, 3 May 2017 18:48:25 +0000 (11:48 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 17 Jul 2017 16:09:25 +0000 (10:09 -0600)
The timeout parameter is required to implement
EGL_ANDROID_native_fence_sync.

v2
* Replaced default timeout from 0 to PIPE_TIMEOUT_INFINITE
* Add more documentation to the new timeout parameter

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
src/gallium/drivers/svga/svga_pipe_query.c
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/svga/svga_winsys.h
src/gallium/winsys/svga/drm/vmw_fence.c
src/gallium/winsys/svga/drm/vmw_fence.h
src/gallium/winsys/svga/drm/vmw_screen_svga.c

index 6703b729c6e65e0ea4fa6d706ba5cafc20639bb1..0490a4ab5fc604efbc975a6add6f0560ff620885 100644 (file)
@@ -191,7 +191,8 @@ get_query_result_vgpu9(struct svga_context *svga, struct svga_query *sq,
    if (state == SVGA3D_QUERYSTATE_PENDING) {
       if (!wait)
          return FALSE;
-      sws->fence_finish(sws, sq->fence, SVGA_FENCE_FLAG_QUERY);
+      sws->fence_finish(sws, sq->fence, PIPE_TIMEOUT_INFINITE,
+                        SVGA_FENCE_FLAG_QUERY);
       state = sq->queryResult->state;
    }
 
@@ -651,7 +652,8 @@ get_query_result_vgpu10(struct svga_context *svga, struct svga_query *sq,
        queryState == SVGA3D_QUERYSTATE_NEW) {
       if (!wait)
          return FALSE;
-      sws->fence_finish(sws, sq->fence, SVGA_FENCE_FLAG_QUERY);
+      sws->fence_finish(sws, sq->fence, PIPE_TIMEOUT_INFINITE,
+                        SVGA_FENCE_FLAG_QUERY);
       sws->query_get_result(sws, sq->gb_query, sq->offset, &queryState, result, resultLen);
    }
 
@@ -1230,7 +1232,8 @@ svga_render_condition(struct pipe_context *pipe, struct pipe_query *q,
 
       if ((mode == PIPE_RENDER_COND_WAIT ||
            mode == PIPE_RENDER_COND_BY_REGION_WAIT) && sq->fence) {
-         sws->fence_finish(sws, sq->fence, SVGA_FENCE_FLAG_QUERY);
+         sws->fence_finish(sws, sq->fence, PIPE_TIMEOUT_INFINITE,
+                           SVGA_FENCE_FLAG_QUERY);
       }
    }
    /*
index 5a684b7933b426c0c009b68ec46ebd86d916c4d4..5b82e9eb7b6c381984af9c0a896f5f7c32d4fa73 100644 (file)
@@ -128,7 +128,7 @@ svga_transfer_dma(struct svga_context *svga,
 
       if (transfer == SVGA3D_READ_HOST_VRAM) {
          svga_context_flush(svga, &fence);
-         sws->fence_finish(sws, fence, 0);
+         sws->fence_finish(sws, fence, PIPE_TIMEOUT_INFINITE, 0);
          sws->fence_reference(sws, &fence, NULL);
       }
    }
@@ -187,7 +187,7 @@ svga_transfer_dma(struct svga_context *svga,
 
          if (transfer == SVGA3D_READ_HOST_VRAM) {
             svga_context_flush(svga, &fence);
-            sws->fence_finish(sws, fence, 0);
+            sws->fence_finish(sws, fence, PIPE_TIMEOUT_INFINITE, 0);
 
             hw = sws->buffer_map(sws, st->hwbuf, PIPE_TRANSFER_READ);
             assert(hw);
index f40d151af5d696d6b94fd9bc9f1fd9fe0146b6c9..1368267d96289852ac04b1061f0a76dc664f0e4f 100644 (file)
@@ -854,7 +854,7 @@ svga_fence_finish(struct pipe_screen *screen,
       SVGA_DBG(DEBUG_DMA|DEBUG_PERF, "%s fence_ptr %p\n",
                __FUNCTION__, fence);
 
-      retVal = sws->fence_finish(sws, fence, 0) == 0;
+      retVal = sws->fence_finish(sws, fence, timeout, 0) == 0;
    }
 
    SVGA_STATS_TIME_POP(sws);
index 7c2fb70a0afa3e647c6a4191503d7c8056805ab3..c785b4f748a0c21b722247fb3664442e6cd2ec75 100644 (file)
@@ -625,11 +625,14 @@ struct svga_winsys_screen
 
    /**
     * Wait for the fence to finish.
+    * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE).
+    *                0 to return immediately, if the API suports it.
     * \param flags  driver-specific meaning
     * \return zero on success.
     */
    int (*fence_finish)( struct svga_winsys_screen *sws,
                         struct pipe_fence_handle *fence,
+                        uint64_t timeout,
                         unsigned flag );
 
 
index edf205e6239c6764a5d2d3578f9940c706b1395e..5b1ba69930bfa8b0b8e2cebb742261e955a5858d 100644 (file)
@@ -300,6 +300,7 @@ vmw_fence_signalled(struct vmw_winsys_screen *vws,
  *
  * @vws: Pointer to the winsys screen.
  * @fence: Handle to the fence object.
+ * @timeout: How long to wait before timing out.
  * @flag: Fence flags to wait for. If the fence object can't signal
  * a flag, it is assumed to be already signaled.
  *
@@ -308,6 +309,7 @@ vmw_fence_signalled(struct vmw_winsys_screen *vws,
 int
 vmw_fence_finish(struct vmw_winsys_screen *vws,
                 struct pipe_fence_handle *fence,
+                uint64_t timeout,
                 unsigned flag)
 {
    struct vmw_fence *vfence;
@@ -383,7 +385,7 @@ vmw_fence_ops_fence_finish(struct pb_fence_ops *ops,
 {
    struct vmw_winsys_screen *vws = vmw_fence_ops(ops)->vws;
 
-   return vmw_fence_finish(vws, fence, flag);
+   return vmw_fence_finish(vws, fence, PIPE_TIMEOUT_INFINITE, flag);
 }
 
 
index f6381feaa2bf9490617de857b4b63f4743caf2a5..31e1350c31675f3f89ef43c30c7b57cac8d8a44a 100644 (file)
@@ -43,6 +43,7 @@ vmw_fence_create(struct pb_fence_ops *fence_ops,
 int
 vmw_fence_finish(struct vmw_winsys_screen *vws,
                 struct pipe_fence_handle *fence,
+                uint64_t timeout,
                 unsigned flag);
 int
 vmw_fence_signalled(struct vmw_winsys_screen *vws,
index 9312f88740c665a700a884163102aef2fed69963..46335378e0abe4456e35f9a462ca42a512e43998 100644 (file)
@@ -123,11 +123,12 @@ vmw_svga_winsys_fence_signalled(struct svga_winsys_screen *sws,
 static int
 vmw_svga_winsys_fence_finish(struct svga_winsys_screen *sws,
                              struct pipe_fence_handle *fence,
+                             uint64_t timeout,
                              unsigned flag)
 {
    struct vmw_winsys_screen *vws = vmw_winsys_screen(sws);
 
-   return vmw_fence_finish(vws, fence, flag);
+   return vmw_fence_finish(vws, fence, timeout, flag);
 }