gallium: add timeout parameter to fence_finish
authorMarek Olšák <maraeo@gmail.com>
Sat, 5 Mar 2011 20:23:54 +0000 (21:23 +0100)
committerMarek Olšák <maraeo@gmail.com>
Tue, 8 Mar 2011 22:52:37 +0000 (23:52 +0100)
This is a follow-up to the ARB_sync patch for st/mesa and completes
the ARB_sync implementation.

29 files changed:
src/gallium/auxiliary/util/u_simple_screen.h
src/gallium/drivers/cell/ppu/cell_fence.c
src/gallium/drivers/cell/ppu/cell_fence.h
src/gallium/drivers/galahad/glhd_screen.c
src/gallium/drivers/i915/i915_screen.c
src/gallium/drivers/i965/brw_screen.c
src/gallium/drivers/identity/id_screen.c
src/gallium/drivers/llvmpipe/lp_flush.c
src/gallium/drivers/llvmpipe/lp_screen.c
src/gallium/drivers/nouveau/nouveau_screen.c
src/gallium/drivers/r300/r300_screen.c
src/gallium/drivers/rbug/rbug_screen.c
src/gallium/drivers/softpipe/sp_fence.c
src/gallium/drivers/softpipe/sp_flush.c
src/gallium/drivers/svga/svga_context.c
src/gallium/drivers/svga/svga_screen.c
src/gallium/drivers/trace/tr_screen.c
src/gallium/include/pipe/p_defines.h
src/gallium/include/pipe/p_screen.h
src/gallium/state_trackers/egl/common/egl_g3d_api.c
src/gallium/state_trackers/egl/common/egl_g3d_sync.c
src/gallium/state_trackers/egl/common/native_helper.c
src/gallium/state_trackers/glx/xlib/xm_api.c
src/gallium/state_trackers/vega/api_context.c
src/gallium/state_trackers/xorg/xorg_dri2.c
src/gallium/state_trackers/xorg/xorg_driver.c
src/gallium/state_trackers/xorg/xorg_exa.c
src/mesa/state_tracker/st_cb_flush.c
src/mesa/state_tracker/st_cb_syncobj.c

index 7139aaabc565b5d686c4c85ca0efff2516d46993..7caeb75cd2743e49bc446cfc25b383e77633d7a4 100644 (file)
@@ -159,7 +159,8 @@ struct pipe_winsys
     */
    int (*fence_finish)( struct pipe_winsys *ws,
                         struct pipe_fence_handle *fence,
-                        unsigned flag );
+                        unsigned flags,
+                        uint64_t timeout );
 
 };
 
index e7c9fc46d9fb8fa60ee570afa34aab2bc22fb44e..3014a8a7b84bf0b9cbbd14d0e19015d891fc9f41 100644 (file)
@@ -47,7 +47,8 @@ cell_fence_init(struct cell_fence *fence)
 
 boolean
 cell_fence_signalled(const struct cell_context *cell,
-                     const struct cell_fence *fence)
+                     const struct cell_fence *fence,
+                     unsigned flags)
 {
    uint i;
    for (i = 0; i < cell->num_spus; i++) {
@@ -61,7 +62,9 @@ cell_fence_signalled(const struct cell_context *cell,
 
 void
 cell_fence_finish(const struct cell_context *cell,
-                  const struct cell_fence *fence)
+                  const struct cell_fence *fence,
+                  unsigned flags,
+                  uint64_t timeout)
 {
    while (!cell_fence_signalled(cell, fence)) {
       usleep(10);
index 536b4ba411a05fece7c8d4547e315304c6618023..3ef6cf7bbcab79096691c508fcc7307ad303a35a 100644 (file)
@@ -36,12 +36,15 @@ cell_fence_init(struct cell_fence *fence);
 
 extern boolean
 cell_fence_signalled(const struct cell_context *cell,
-                     const struct cell_fence *fence);
+                     const struct cell_fence *fence,
+                     unsigned flags);
 
 
 extern void
 cell_fence_finish(const struct cell_context *cell,
-                  const struct cell_fence *fence);
+                  const struct cell_fence *fence,
+                  unsigned flags,
+                  uint64_t timeout);
 
 
 
index b4825bef66dafb04609b78b22527b360fc062d4f..fbe19bf324b5a86807a6aaee0bc2a53ccdf07f95 100644 (file)
@@ -292,14 +292,16 @@ galahad_screen_fence_signalled(struct pipe_screen *_screen,
 static int
 galahad_screen_fence_finish(struct pipe_screen *_screen,
                              struct pipe_fence_handle *fence,
-                             unsigned flags)
+                             unsigned flags,
+                             uint64_t timeout)
 {
    struct galahad_screen *glhd_screen = galahad_screen(_screen);
    struct pipe_screen *screen = glhd_screen->screen;
 
    return screen->fence_finish(screen,
                                fence,
-                               flags);
+                               flags,
+                               timeout);
 }
 
 struct pipe_screen *
index 64c4bbab399c8ac749b5ad64e53e30f10be5447c..39f65f8c8fd25390145b0ca534b0d3fafab708d8 100644 (file)
@@ -331,7 +331,8 @@ i915_fence_signalled(struct pipe_screen *screen,
 static int
 i915_fence_finish(struct pipe_screen *screen,
                   struct pipe_fence_handle *fence,
-                  unsigned flags)
+                  unsigned flags,
+                  uint64_t timeout)
 {
    struct i915_screen *is = i915_screen(screen);
 
index bf805fd080c9e2ed33900e68f4821ab1eebae10a..367581a6b4189c1d3a0741d68bef48532eb4aee2 100644 (file)
@@ -376,7 +376,8 @@ brw_fence_signalled(struct pipe_screen *screen,
 static int
 brw_fence_finish(struct pipe_screen *screen,
                  struct pipe_fence_handle *fence,
-                 unsigned flags)
+                 unsigned flags,
+                 uint64_t timeout)
 {
    return 0;
 }
index 644481bb7480e3559ff85a86677522d880941091..b289c1e5d17b16ed56ba6ffe6defbea9d4faa757 100644 (file)
@@ -258,14 +258,16 @@ identity_screen_fence_signalled(struct pipe_screen *_screen,
 static int
 identity_screen_fence_finish(struct pipe_screen *_screen,
                              struct pipe_fence_handle *fence,
-                             unsigned flags)
+                             unsigned flags,
+                             uint64_t timeout)
 {
    struct identity_screen *id_screen = identity_screen(_screen);
    struct pipe_screen *screen = id_screen->screen;
 
    return screen->fence_finish(screen,
                                fence,
-                               flags);
+                               flags,
+                               timeout);
 }
 
 struct pipe_screen *
index 849db06acdf3f5402ec454f0584f8ab3e3496071..6118164b20b0fb4f353cec54c739471e01b4a4c6 100644 (file)
@@ -92,7 +92,7 @@ llvmpipe_finish( struct pipe_context *pipe,
    struct pipe_fence_handle *fence = NULL;
    llvmpipe_flush(pipe, 0, &fence, reason);
    if (fence) {
-      pipe->screen->fence_finish(pipe->screen, fence, 0);
+      pipe->screen->fence_finish(pipe->screen, fence, 0, PIPE_TIMEOUT_INFINITE);
       pipe->screen->fence_reference(pipe->screen, &fence, NULL);
    }
 }
index edcfbfcfac19a8c8859a59521caeb515a1a3c6cd..c600144a2da876ea72e5d9ffb7601382f64b97f4 100644 (file)
@@ -365,7 +365,8 @@ llvmpipe_fence_signalled(struct pipe_screen *screen,
 static int
 llvmpipe_fence_finish(struct pipe_screen *screen,
                       struct pipe_fence_handle *fence_handle,
-                      unsigned flag)
+                      unsigned flag,
+                      uint64_t timeout)
 {
    struct lp_fence *f = (struct lp_fence *) fence_handle;
 
index e6cd3064c9a6c729c2d287402cf5da98f0a6d033..3111bef7a22b945033056ce22dcdabf671d9bd07 100644 (file)
@@ -165,7 +165,8 @@ nouveau_screen_fence_signalled(struct pipe_screen *screen,
 static int
 nouveau_screen_fence_finish(struct pipe_screen *screen,
                            struct pipe_fence_handle *pfence,
-                           unsigned flags)
+                            unsigned flags,
+                            uint64_t timeout)
 {
        return !nouveau_fence_wait(nouveau_fence(pfence));
 }
index 2c7bca86277adee9f93f04e3e4d5cec7eb29abe6..18ed0356cae7312a93e4f1e0eb47f83040fe7a9d 100644 (file)
@@ -434,7 +434,8 @@ static int r300_fence_signalled(struct pipe_screen *screen,
 
 static int r300_fence_finish(struct pipe_screen *screen,
                              struct pipe_fence_handle *fence,
-                             unsigned flags)
+                             unsigned flags,
+                             uint64_t timeout)
 {
     struct r300_winsys_screen *rws = r300_screen(screen)->rws;
     struct r300_winsys_bo *rfence = (struct r300_winsys_bo*)fence;
index d635ce575c0c1bb43f40089d3e1486480d449a1c..d8d23bcb9c553e652ccc83a6a31b1bc6883304b8 100644 (file)
@@ -256,14 +256,16 @@ rbug_screen_fence_signalled(struct pipe_screen *_screen,
 static int
 rbug_screen_fence_finish(struct pipe_screen *_screen,
                          struct pipe_fence_handle *fence,
-                         unsigned flags)
+                         unsigned flags,
+                         uint64_t timeout)
 {
    struct rbug_screen *rb_screen = rbug_screen(_screen);
    struct pipe_screen *screen = rb_screen->screen;
 
    return screen->fence_finish(screen,
                                fence,
-                               flags);
+                               flags,
+                               timeout);
 }
 
 boolean
index 66c521411327077fed6ac13ffffcd0e0ab43458e..40d0b5970ef2896aa14d498cd1ff4ec308e33a08 100644 (file)
@@ -54,7 +54,8 @@ softpipe_fence_signalled(struct pipe_screen *screen,
 static int
 softpipe_fence_finish(struct pipe_screen *screen,
                       struct pipe_fence_handle *fence,
-                      unsigned flags)
+                      unsigned flags,
+                      uint64_t timeout)
 {
    assert(!fence);
    return 0;
index 6f7addd441a94828c807baa81e378ef07baeaca7..00a2fafdfa290152287c45ec225242feefc1781f 100644 (file)
@@ -162,7 +162,8 @@ softpipe_flush_resource(struct pipe_context *pipe,
              * This is for illustrative purposes only, as softpipe does not
              * have fences.
              */
-            pipe->screen->fence_finish(pipe->screen, fence, 0);
+            pipe->screen->fence_finish(pipe->screen, fence, 0,
+                                       PIPE_TIMEOUT_INFINITE);
             pipe->screen->fence_reference(pipe->screen, &fence, NULL);
          }
       } else {
index f0f875b2b23583ae3e8ab656599f99d7f51d3e69..e64dc94b9d8ff6f515de8a3ba68e43f61722af39 100644 (file)
@@ -241,7 +241,8 @@ void svga_context_flush( struct svga_context *svga,
 
    if (SVGA_DEBUG & DEBUG_SYNC) {
       if (fence)
-         svga->pipe.screen->fence_finish( svga->pipe.screen, fence, 0);
+         svga->pipe.screen->fence_finish( svga->pipe.screen, fence, 0,
+                                          PIPE_TIMEOUT_INFINITE);
    }
 
    if(pfence)
index ef1d3098d51155ecdd18fe717f68e528c8c8ba5c..f4029c7e36381d75f184fa175dc7d3e7ddfecb92 100644 (file)
@@ -425,7 +425,8 @@ svga_fence_signalled(struct pipe_screen *screen,
 static int
 svga_fence_finish(struct pipe_screen *screen,
                   struct pipe_fence_handle *fence,
-                  unsigned flag)
+                  unsigned flag,
+                  uint64_t timeout)
 {
    struct svga_winsys_screen *sws = svga_screen(screen)->sws;
 
index 7cfaab060f1c515c1ce9d1a41624139c94cf5c8a..17f87cb906c0713fd7efe502da6c009cb56e6238 100644 (file)
@@ -421,7 +421,8 @@ trace_screen_fence_signalled(struct pipe_screen *_screen,
 static int
 trace_screen_fence_finish(struct pipe_screen *_screen,
                           struct pipe_fence_handle *fence,
-                          unsigned flags)
+                          unsigned flags,
+                          uint64_t timeout)
 {
    struct trace_screen *tr_scr = trace_screen(_screen);
    struct pipe_screen *screen = tr_scr->screen;
@@ -432,8 +433,9 @@ trace_screen_fence_finish(struct pipe_screen *_screen,
    trace_dump_arg(ptr, screen);
    trace_dump_arg(ptr, fence);
    trace_dump_arg(uint, flags);
+   trace_dump_arg(uint, timeout);
 
-   result = screen->fence_finish(screen, fence, flags);
+   result = screen->fence_finish(screen, fence, flags, timeout);
 
    trace_dump_ret(int, result);
 
index edbaaae334a06066e7f68e3da811b334ddb6b045..9350a755d735f257ba21d1c14f5c11be260e29b3 100644 (file)
@@ -426,6 +426,8 @@ enum pipe_transfer_usage {
 #define PIPE_SWIZZLE_ONE   5
 
 
+#define PIPE_TIMEOUT_INFINITE 0xffffffffffffffffull
+
 /**
  * Implementation capabilities/limits which are queried through
  * pipe_screen::get_param() and pipe_screen::get_paramf().
index 850eb84a3c8f59728908ad076bc7fc7d988fe9e6..8e77e77db3938ede54616fe5cae37374c693d8a1 100644 (file)
@@ -193,11 +193,13 @@ struct pipe_screen {
    /**
     * Wait for the fence to finish.
     * \param flags  driver-specific meaning
+    * \param timeout  in nanoseconds
     * \return zero on success.
     */
    int (*fence_finish)( struct pipe_screen *screen,
                         struct pipe_fence_handle *fence,
-                        unsigned flags );
+                        unsigned flags,
+                        uint64_t timeout );
 
 };
 
index 2068256dff285581753ee0379f31a7a258f01a2e..61619886c3d679a6f03ef26fd0792aecd530d2ce 100644 (file)
@@ -689,7 +689,7 @@ egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
    gctx->stctxi->flush(gctx->stctxi,
          PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
    if (fence) {
-      screen->fence_finish(screen, fence, 0);
+      screen->fence_finish(screen, fence, 0, PIPE_TIMEOUT_INFINITE);
       screen->fence_reference(screen, &fence, NULL);
    }
 
index 4e6d944c1510ec38c2f7a08b67337f32c73f117a..020c696238f70ae283f52a931415cc046c73d7ca 100644 (file)
@@ -109,7 +109,7 @@ egl_g3d_wait_fence_sync(struct egl_g3d_sync *gsync, EGLTimeKHR timeout)
 
       _eglUnlockMutex(&dpy->Mutex);
       /* no timed finish? */
-      screen->fence_finish(screen, fence, 0x0);
+      screen->fence_finish(screen, fence, 0x0, PIPE_TIMEOUT_INFINITE);
       ret = EGL_CONDITION_SATISFIED_KHR;
       _eglLockMutex(&dpy->Mutex);
 
index be6713d03a853a28d2d70077cbf722048eca8c88..aaccee3e1d1dde154fd24d6997322a3224af84d0 100644 (file)
@@ -333,7 +333,7 @@ resource_surface_throttle(struct resource_surface *rsurf)
    struct pipe_fence_handle *fence = swap_fences_pop_front(rsurf);
 
    if (fence) {
-      (void) screen->fence_finish(screen, fence, 0);
+      (void) screen->fence_finish(screen, fence, 0, PIPE_TIMEOUT_INFINITE);
       screen->fence_reference(screen, &fence, NULL);
       return TRUE;
    }
index 7c47a25ceba6b70fc87c799183e00e4007b85f76..506d6ecda8ea313b1a11bc1530a427ea208dac0f 100644 (file)
@@ -1227,7 +1227,8 @@ void XMesaFlush( XMesaContext c )
 
       c->st->flush(c->st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
       if (fence) {
-         xmdpy->screen->fence_finish(xmdpy->screen, fence, 0);
+         xmdpy->screen->fence_finish(xmdpy->screen, fence, 0,
+                                     PIPE_TIMEOUT_INFINITE);
          xmdpy->screen->fence_reference(xmdpy->screen, &fence, NULL);
       }
       XFlush( c->xm_visual->display );
index d6bbda5e07520e8343383707e9754735cc6999ca..5fba56fd2114b8d74168df781061d141ce738b61 100644 (file)
@@ -74,7 +74,8 @@ void vegaFinish(void)
 
    pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
    if (fence) {
-      pipe->screen->fence_finish(pipe->screen, fence, 0);
+      pipe->screen->fence_finish(pipe->screen, fence, 0,
+                                 PIPE_TIMEOUT_INFINITE);
       pipe->screen->fence_reference(pipe->screen, &fence, NULL);
    }
 }
index 17c34b7eac851c55af0a4ca37051b20b4d7f7d96..6fc3e6514cd9bbe30d853b42d5c03e184cd45af8 100644 (file)
@@ -362,7 +362,8 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
 
        if (extents->x1 == 0 && extents->y1 == 0 &&
            extents->x2 == pDraw->width && extents->y2 == pDraw->height) {
-           ms->screen->fence_finish(ms->screen, dst_priv->fence, 0);
+            ms->screen->fence_finish(ms->screen, dst_priv->fence, 0,
+                                     PIPE_TIMEOUT_INFINITE);
            ms->screen->fence_reference(ms->screen, &dst_priv->fence, NULL);
        }
     }
index 33bcacdcc2e5e480d52fcbd0956a2d00e1787f7c..9c890ff086641e5e75415b46885d55f157218778 100644 (file)
@@ -334,7 +334,8 @@ drv_cleanup_fences(ScrnInfoPtr pScrn)
 
     for (i = 0; i < XORG_NR_FENCES; i++) {
        if (ms->fence[i]) {
-           ms->screen->fence_finish(ms->screen, ms->fence[i], 0);
+            ms->screen->fence_finish(ms->screen, ms->fence[i], 0,
+                                     PIPE_TIMEOUT_INFINITE);
            ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL);
        }
     }
@@ -555,7 +556,8 @@ void xorg_flush(ScreenPtr pScreen)
        if (ms->dirtyThrottling) {
            if (ms->fence[0])
                ms->ctx->screen->fence_finish(ms->ctx->screen,
-                                             ms->fence[0], 0);
+                                              ms->fence[0], 0,
+                                              PIPE_TIMEOUT_INFINITE);
   
            /* The amount of rendering generated by a block handler can be
             * quite small.  Let us get a fair way ahead of hardware before
index 718a3453939d3452f45e8dbff772e246359f6246..38d67d1b0b8303af1299eeec808136d535195df1 100644 (file)
@@ -1084,7 +1084,8 @@ void xorg_exa_finish(struct exa_context *exa)
 
    xorg_exa_flush(exa, PIPE_FLUSH_RENDER_CACHE, &fence);
 
-   exa->pipe->screen->fence_finish(exa->pipe->screen, fence, 0);
+   exa->pipe->screen->fence_finish(exa->pipe->screen, fence, 0,
+                                   PIPE_TIMEOUT_INFINITE);
    exa->pipe->screen->fence_reference(exa->pipe->screen, &fence, NULL);
 }
 
index 5a2343d3aec30991a542c783dff0aebce9200144..35ab00f6d015e42c4928d4aa2a6d3a3545e12f67 100644 (file)
@@ -103,7 +103,8 @@ void st_finish( struct st_context *st )
    st_flush(st, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
 
    if(fence) {
-      st->pipe->screen->fence_finish(st->pipe->screen, fence, 0);
+      st->pipe->screen->fence_finish(st->pipe->screen, fence, 0,
+                                     PIPE_TIMEOUT_INFINITE);
       st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL);
    }
 }
index 69a8678a7c076f729babbbdee279bf28db2054ad..85aad08cc7013ac2c137dd58d0ec1afa308b2c23 100644 (file)
@@ -96,8 +96,8 @@ static void st_client_wait_sync(struct gl_context *ctx,
    /* We don't care about GL_SYNC_FLUSH_COMMANDS_BIT, because flush is
     * already called when creating a fence. */
 
-   if (so->fence) {
-      screen->fence_finish(screen, so->fence, 0);
+   if (so->fence &&
+       screen->fence_finish(screen, so->fence, 0, timeout) == 0) {
       screen->fence_reference(screen, &so->fence, NULL);
       so->b.StatusFlag = GL_TRUE;
    }