From 54272e18a682c8b82d4a86b2c07b51c303d8cead Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 6 Aug 2016 16:41:42 +0200 Subject: [PATCH] gallium: add a pipe_context parameter to fence_finish MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit required by glClientWaitSync (GL 4.5 Core spec) that can optionally flush the context Reviewed-by: Rob Clark Reviewed-by: Nicolai Hähnle --- src/gallium/docs/source/context.rst | 10 ++++------ src/gallium/drivers/ddebug/dd_draw.c | 2 +- src/gallium/drivers/ddebug/dd_screen.c | 4 +++- src/gallium/drivers/freedreno/freedreno_fence.c | 1 + src/gallium/drivers/freedreno/freedreno_fence.h | 1 + src/gallium/drivers/i915/i915_screen.c | 1 + src/gallium/drivers/ilo/ilo_screen.c | 1 + src/gallium/drivers/llvmpipe/lp_flush.c | 3 ++- src/gallium/drivers/llvmpipe/lp_screen.c | 1 + src/gallium/drivers/nouveau/nouveau_screen.c | 1 + src/gallium/drivers/r300/r300_screen.c | 1 + src/gallium/drivers/radeon/r600_pipe_common.c | 1 + src/gallium/drivers/radeon/r600_query.c | 2 +- src/gallium/drivers/rbug/rbug_screen.c | 6 +++--- src/gallium/drivers/softpipe/sp_fence.c | 1 + src/gallium/drivers/softpipe/sp_flush.c | 2 +- src/gallium/drivers/svga/svga_context.c | 4 ++-- src/gallium/drivers/svga/svga_screen.c | 1 + src/gallium/drivers/swr/swr_context.cpp | 4 ++-- src/gallium/drivers/swr/swr_draw.cpp | 2 +- src/gallium/drivers/swr/swr_fence.cpp | 1 + src/gallium/drivers/swr/swr_fence.h | 1 + src/gallium/drivers/swr/swr_query.cpp | 4 ++-- src/gallium/drivers/swr/swr_screen.cpp | 6 +++--- src/gallium/drivers/swr/swr_state.cpp | 2 +- src/gallium/drivers/trace/tr_screen.c | 5 ++++- src/gallium/drivers/vc4/vc4_fence.c | 1 + src/gallium/drivers/virgl/virgl_screen.c | 1 + src/gallium/include/pipe/p_screen.h | 15 ++++++++++++--- src/gallium/state_trackers/clover/core/event.cpp | 4 ++-- src/gallium/state_trackers/dri/dri2.c | 6 +++--- src/gallium/state_trackers/dri/dri_drawable.c | 2 +- src/gallium/state_trackers/glx/xlib/xm_api.c | 2 +- src/gallium/state_trackers/nine/swapchain9.c | 6 +++--- src/gallium/state_trackers/vdpau/presentation.c | 4 ++-- src/gallium/state_trackers/xa/xa_context.c | 2 +- src/gallium/state_trackers/xvmc/surface.c | 2 +- src/mesa/state_tracker/st_cb_flush.c | 2 +- src/mesa/state_tracker/st_cb_syncobj.c | 4 ++-- 39 files changed, 73 insertions(+), 46 deletions(-) diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst index 7fddabffeb4..1b045fa6ec0 100644 --- a/src/gallium/docs/source/context.rst +++ b/src/gallium/docs/source/context.rst @@ -467,12 +467,10 @@ Flushing PIPE_FLUSH_END_OF_FRAME: Whether the flush marks the end of frame. PIPE_FLUSH_DEFERRED: It is not required to flush right away, but it is required -to return a valid fence. The behavior of fence_finish or any other call isn't -changed. The only side effect can be that fence_finish will wait a little -longer. No guidance is given as to how drivers should implement fence_finish -with deferred flushes. If some drivers can't do deferred flushes safely, they -should just ignore the flag. - +to return a valid fence. If fence_finish is called with the returned fence +and the context is still unflushed, and the ctx parameter of fence_finish is +equal to the context where the fence was created, fence_finish will flush +the context. ``flush_resource`` diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c index 7abcf877a3b..3124d0552d0 100644 --- a/src/gallium/drivers/ddebug/dd_draw.c +++ b/src/gallium/drivers/ddebug/dd_draw.c @@ -548,7 +548,7 @@ dd_flush_and_check_hang(struct dd_context *dctx, if (!fence) return false; - idle = screen->fence_finish(screen, fence, timeout_ms * 1000000); + idle = screen->fence_finish(screen, NULL, fence, timeout_ms * 1000000); screen->fence_reference(screen, &fence, NULL); if (!idle) fprintf(stderr, "dd: GPU hang detected!\n"); diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c index 412ea365ce2..3deba0a6e27 100644 --- a/src/gallium/drivers/ddebug/dd_screen.c +++ b/src/gallium/drivers/ddebug/dd_screen.c @@ -263,12 +263,14 @@ dd_screen_fence_reference(struct pipe_screen *_screen, static boolean dd_screen_fence_finish(struct pipe_screen *_screen, + struct pipe_context *_ctx, struct pipe_fence_handle *fence, uint64_t timeout) { struct pipe_screen *screen = dd_screen(_screen)->screen; + struct pipe_context *ctx = _ctx ? dd_context(_ctx)->pipe : NULL; - return screen->fence_finish(screen, fence, timeout); + return screen->fence_finish(screen, ctx, fence, timeout); } diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index 5125f091860..df4cf4dd560 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -51,6 +51,7 @@ fd_screen_fence_ref(struct pipe_screen *pscreen, } boolean fd_screen_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/freedreno/freedreno_fence.h b/src/gallium/drivers/freedreno/freedreno_fence.h index 06c314a6116..df7664bf8cd 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.h +++ b/src/gallium/drivers/freedreno/freedreno_fence.h @@ -35,6 +35,7 @@ void fd_screen_fence_ref(struct pipe_screen *pscreen, struct pipe_fence_handle **ptr, struct pipe_fence_handle *pfence); boolean fd_screen_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *pfence, uint64_t timeout); struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx, diff --git a/src/gallium/drivers/i915/i915_screen.c b/src/gallium/drivers/i915/i915_screen.c index 6b5218bc467..ab3d4a6b277 100644 --- a/src/gallium/drivers/i915/i915_screen.c +++ b/src/gallium/drivers/i915/i915_screen.c @@ -500,6 +500,7 @@ i915_fence_reference(struct pipe_screen *screen, static boolean i915_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/ilo/ilo_screen.c b/src/gallium/drivers/ilo/ilo_screen.c index 448f512d7d1..e98b6f20c39 100644 --- a/src/gallium/drivers/ilo/ilo_screen.c +++ b/src/gallium/drivers/ilo/ilo_screen.c @@ -696,6 +696,7 @@ ilo_screen_fence_reference(struct pipe_screen *screen, static boolean ilo_screen_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/llvmpipe/lp_flush.c b/src/gallium/drivers/llvmpipe/lp_flush.c index 241c2ccafb7..452753f8810 100644 --- a/src/gallium/drivers/llvmpipe/lp_flush.c +++ b/src/gallium/drivers/llvmpipe/lp_flush.c @@ -82,7 +82,8 @@ llvmpipe_finish( struct pipe_context *pipe, struct pipe_fence_handle *fence = NULL; llvmpipe_flush(pipe, &fence, reason); if (fence) { - pipe->screen->fence_finish(pipe->screen, fence, PIPE_TIMEOUT_INFINITE); + pipe->screen->fence_finish(pipe->screen, NULL, fence, + PIPE_TIMEOUT_INFINITE); pipe->screen->fence_reference(pipe->screen, &fence, NULL); } } diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 61c3fb7a410..1c00aa91034 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -572,6 +572,7 @@ llvmpipe_fence_reference(struct pipe_screen *screen, */ static boolean llvmpipe_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence_handle, uint64_t timeout) { diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c index 2c421cc748c..f59e101cafb 100644 --- a/src/gallium/drivers/nouveau/nouveau_screen.c +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -70,6 +70,7 @@ nouveau_screen_fence_ref(struct pipe_screen *pscreen, static boolean nouveau_screen_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *pfence, uint64_t timeout) { diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index 7d2ea4a4767..b69e5246ef0 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -698,6 +698,7 @@ static void r300_fence_reference(struct pipe_screen *screen, } static boolean r300_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c b/src/gallium/drivers/radeon/r600_pipe_common.c index 2d05e16fc15..4dd2b3b7575 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.c +++ b/src/gallium/drivers/radeon/r600_pipe_common.c @@ -954,6 +954,7 @@ static void r600_fence_reference(struct pipe_screen *screen, } static boolean r600_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c index 87352032ad7..592cec1c2c0 100644 --- a/src/gallium/drivers/radeon/r600_query.c +++ b/src/gallium/drivers/radeon/r600_query.c @@ -215,7 +215,7 @@ static bool r600_query_sw_get_result(struct r600_common_context *rctx, return true; case PIPE_QUERY_GPU_FINISHED: { struct pipe_screen *screen = rctx->b.screen; - result->b = screen->fence_finish(screen, query->fence, + result->b = screen->fence_finish(screen, NULL, query->fence, wait ? PIPE_TIMEOUT_INFINITE : 0); return result->b; } diff --git a/src/gallium/drivers/rbug/rbug_screen.c b/src/gallium/drivers/rbug/rbug_screen.c index c2950e4a703..8d216691fdb 100644 --- a/src/gallium/drivers/rbug/rbug_screen.c +++ b/src/gallium/drivers/rbug/rbug_screen.c @@ -229,15 +229,15 @@ rbug_screen_fence_reference(struct pipe_screen *_screen, static boolean rbug_screen_fence_finish(struct pipe_screen *_screen, + struct pipe_context *_ctx, struct pipe_fence_handle *fence, uint64_t timeout) { struct rbug_screen *rb_screen = rbug_screen(_screen); struct pipe_screen *screen = rb_screen->screen; + struct pipe_context *ctx = _ctx ? rbug_context(_ctx)->pipe : NULL; - return screen->fence_finish(screen, - fence, - timeout); + return screen->fence_finish(screen, ctx, fence, timeout); } boolean diff --git a/src/gallium/drivers/softpipe/sp_fence.c b/src/gallium/drivers/softpipe/sp_fence.c index 6168236ec96..1861b0da07e 100644 --- a/src/gallium/drivers/softpipe/sp_fence.c +++ b/src/gallium/drivers/softpipe/sp_fence.c @@ -42,6 +42,7 @@ softpipe_fence_reference(struct pipe_screen *screen, static boolean softpipe_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index 29fcf7f1628..656d8a3257a 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -153,7 +153,7 @@ 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, + pipe->screen->fence_finish(pipe->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); pipe->screen->fence_reference(pipe->screen, &fence, NULL); } diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index c7f4aae246d..f623caf9401 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -348,7 +348,7 @@ void svga_context_flush( struct svga_context *svga, if (SVGA_DEBUG & DEBUG_SYNC) { if (fence) - svga->pipe.screen->fence_finish( svga->pipe.screen, fence, + svga->pipe.screen->fence_finish( svga->pipe.screen, NULL, fence, PIPE_TIMEOUT_INFINITE); } @@ -369,7 +369,7 @@ svga_context_finish(struct svga_context *svga) struct pipe_fence_handle *fence = NULL; svga_context_flush(svga, &fence); - screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); + screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE); screen->fence_reference(screen, &fence, NULL); } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 13253aca43f..7c4e305f504 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -804,6 +804,7 @@ svga_fence_reference(struct pipe_screen *screen, static boolean svga_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index 1083c9de194..835c35393f0 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -128,7 +128,7 @@ swr_transfer_map(struct pipe_context *pipe, if (!swr_is_fence_pending(screen->flush_fence)) swr_fence_submit(swr_context(pipe), screen->flush_fence); - swr_fence_finish(pipe->screen, screen->flush_fence, 0); + swr_fence_finish(pipe->screen, NULL, screen->flush_fence, 0); swr_resource_unused(resource); } } @@ -205,7 +205,7 @@ swr_resource_copy(struct pipe_context *pipe, swr_store_dirty_resource(pipe, src, SWR_TILE_RESOLVED); swr_store_dirty_resource(pipe, dst, SWR_TILE_RESOLVED); - swr_fence_finish(pipe->screen, screen->flush_fence, 0); + swr_fence_finish(pipe->screen, NULL, screen->flush_fence, 0); swr_resource_unused(src); swr_resource_unused(dst); diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index ab8d2750623..0f6a8c6d88c 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -239,7 +239,7 @@ swr_finish(struct pipe_context *pipe) struct pipe_fence_handle *fence = nullptr; swr_flush(pipe, &fence, 0); - swr_fence_finish(pipe->screen, fence, 0); + swr_fence_finish(pipe->screen, NULL, fence, 0); swr_fence_reference(pipe->screen, &fence, NULL); } diff --git a/src/gallium/drivers/swr/swr_fence.cpp b/src/gallium/drivers/swr/swr_fence.cpp index 8a8e864397d..7fe24700bfa 100644 --- a/src/gallium/drivers/swr/swr_fence.cpp +++ b/src/gallium/drivers/swr/swr_fence.cpp @@ -111,6 +111,7 @@ swr_fence_reference(struct pipe_screen *screen, */ boolean swr_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence_handle, uint64_t timeout) { diff --git a/src/gallium/drivers/swr/swr_fence.h b/src/gallium/drivers/swr/swr_fence.h index 47f4d2e7c9f..80a4345af87 100644 --- a/src/gallium/drivers/swr/swr_fence.h +++ b/src/gallium/drivers/swr/swr_fence.h @@ -69,6 +69,7 @@ void swr_fence_reference(struct pipe_screen *screen, struct pipe_fence_handle *f); boolean swr_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence_handle, uint64_t timeout); diff --git a/src/gallium/drivers/swr/swr_query.cpp b/src/gallium/drivers/swr/swr_query.cpp index 7867db3fc12..5b8f059cdae 100644 --- a/src/gallium/drivers/swr/swr_query.cpp +++ b/src/gallium/drivers/swr/swr_query.cpp @@ -63,7 +63,7 @@ swr_destroy_query(struct pipe_context *pipe, struct pipe_query *q) if (pq->fence) { if (swr_is_fence_pending(pq->fence)) - swr_fence_finish(pipe->screen, pq->fence, 0); + swr_fence_finish(pipe->screen, NULL, pq->fence, 0); swr_fence_reference(pipe->screen, &pq->fence, NULL); } @@ -128,7 +128,7 @@ swr_get_query_result(struct pipe_context *pipe, if (!wait && !swr_is_fence_done(pq->fence)) return FALSE; - swr_fence_finish(pipe->screen, pq->fence, 0); + swr_fence_finish(pipe->screen, NULL, pq->fence, 0); swr_fence_reference(pipe->screen, &pq->fence, NULL); } diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index e0e59fa674c..df44967feee 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -657,7 +657,7 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt) if (!swr_is_fence_pending(screen->flush_fence)) swr_fence_submit(swr_context(pipe), screen->flush_fence); - swr_fence_finish(p_screen, screen->flush_fence, 0); + swr_fence_finish(p_screen, NULL, screen->flush_fence, 0); swr_resource_unused(pt); } @@ -692,7 +692,7 @@ swr_flush_frontbuffer(struct pipe_screen *p_screen, struct pipe_context *pipe = screen->pipe; if (pipe) { - swr_fence_finish(p_screen, screen->flush_fence, 0); + swr_fence_finish(p_screen, NULL, screen->flush_fence, 0); swr_resource_unused(resource); SwrEndFrame(swr_context(pipe)->swrContext); } @@ -712,7 +712,7 @@ swr_destroy_screen(struct pipe_screen *p_screen) fprintf(stderr, "SWR destroy screen!\n"); - swr_fence_finish(p_screen, screen->flush_fence, 0); + swr_fence_finish(p_screen, NULL, screen->flush_fence, 0); swr_fence_reference(p_screen, &screen->flush_fence, NULL); JitDestroyContext(screen->hJitMgr); diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index dac95ce42e7..2df79855358 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1390,7 +1390,7 @@ swr_update_derived(struct pipe_context *pipe, /* Ensure that any in-progress attachment change StoreTiles finish */ if (swr_is_fence_pending(screen->flush_fence)) - swr_fence_finish(pipe->screen, screen->flush_fence, 0); + swr_fence_finish(pipe->screen, NULL, screen->flush_fence, 0); /* Finally, update the in-use status of all resources involved in draw */ swr_update_resource_status(pipe, p_draw_info); diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index 260f1df5ce7..67241ca2ba1 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -402,20 +402,23 @@ trace_screen_fence_reference(struct pipe_screen *_screen, static boolean trace_screen_fence_finish(struct pipe_screen *_screen, + struct pipe_context *_ctx, struct pipe_fence_handle *fence, uint64_t timeout) { struct trace_screen *tr_scr = trace_screen(_screen); struct pipe_screen *screen = tr_scr->screen; + struct pipe_context *ctx = _ctx ? trace_context(_ctx)->pipe : NULL; int result; trace_dump_call_begin("pipe_screen", "fence_finish"); trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, ctx); trace_dump_arg(ptr, fence); trace_dump_arg(uint, timeout); - result = screen->fence_finish(screen, fence, timeout); + result = screen->fence_finish(screen, ctx, fence, timeout); trace_dump_ret(bool, result); diff --git a/src/gallium/drivers/vc4/vc4_fence.c b/src/gallium/drivers/vc4/vc4_fence.c index b6fb2a8a460..f61e7c6a5e8 100644 --- a/src/gallium/drivers/vc4/vc4_fence.c +++ b/src/gallium/drivers/vc4/vc4_fence.c @@ -61,6 +61,7 @@ vc4_fence_reference(struct pipe_screen *pscreen, static boolean vc4_fence_finish(struct pipe_screen *pscreen, + struct pipe_context *ctx, struct pipe_fence_handle *pf, uint64_t timeout_ns) { diff --git a/src/gallium/drivers/virgl/virgl_screen.c b/src/gallium/drivers/virgl/virgl_screen.c index fd3d35dc745..e01b5b405af 100644 --- a/src/gallium/drivers/virgl/virgl_screen.c +++ b/src/gallium/drivers/virgl/virgl_screen.c @@ -524,6 +524,7 @@ static void virgl_fence_reference(struct pipe_screen *screen, } static boolean virgl_fence_finish(struct pipe_screen *screen, + struct pipe_context *ctx, struct pipe_fence_handle *fence, uint64_t timeout) { diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h index 755291ae501..dd40e07b7ee 100644 --- a/src/gallium/include/pipe/p_screen.h +++ b/src/gallium/include/pipe/p_screen.h @@ -242,11 +242,20 @@ struct pipe_screen { /** * Wait for the fence to finish. + * + * If the fence was created with PIPE_FLUSH_DEFERRED, and the context is + * still unflushed, and the ctx parameter of fence_finish is equal to + * the context where the fence was created, fence_finish will flush + * the context prior to waiting for the fence. + * + * In all other cases, the ctx parameter has no effect. + * * \param timeout in nanoseconds (may be PIPE_TIMEOUT_INFINITE). */ - boolean (*fence_finish)( struct pipe_screen *screen, - struct pipe_fence_handle *fence, - uint64_t timeout ); + boolean (*fence_finish)(struct pipe_screen *screen, + struct pipe_context *ctx, + struct pipe_fence_handle *fence, + uint64_t timeout); /** * Returns a driver-specific query. diff --git a/src/gallium/state_trackers/clover/core/event.cpp b/src/gallium/state_trackers/clover/core/event.cpp index d75b8397794..8275e16a4dd 100644 --- a/src/gallium/state_trackers/clover/core/event.cpp +++ b/src/gallium/state_trackers/clover/core/event.cpp @@ -141,7 +141,7 @@ hard_event::status() const { else if (!_fence) return CL_QUEUED; - else if (!screen->fence_finish(screen, _fence, 0)) + else if (!screen->fence_finish(screen, NULL, _fence, 0)) return CL_SUBMITTED; else @@ -168,7 +168,7 @@ hard_event::wait() const { queue()->flush(); if (!_fence || - !screen->fence_finish(screen, _fence, PIPE_TIMEOUT_INFINITE)) + !screen->fence_finish(screen, NULL, _fence, PIPE_TIMEOUT_INFINITE)) throw error(CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LIST); } diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c index c22a8cdc430..9803b0e1971 100644 --- a/src/gallium/state_trackers/dri/dri2.c +++ b/src/gallium/state_trackers/dri/dri2.c @@ -1252,7 +1252,7 @@ dri2_blit_image(__DRIcontext *context, __DRIimage *dst, __DRIimage *src, screen = dri_screen(ctx->sPriv)->base.screen; pipe->flush_resource(pipe, dst->texture); ctx->st->flush(ctx->st, 0, &fence); - (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); + (void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE); screen->fence_reference(screen, &fence, NULL); } } @@ -1451,13 +1451,13 @@ dri2_client_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags, /* No need to flush. The context was flushed when the fence was created. */ if (fence->pipe_fence) - return screen->fence_finish(screen, fence->pipe_fence, timeout); + return screen->fence_finish(screen, NULL, fence->pipe_fence, timeout); else if (fence->cl_event) { struct pipe_fence_handle *pipe_fence = driscreen->opencl_dri_event_get_fence(fence->cl_event); if (pipe_fence) - return screen->fence_finish(screen, pipe_fence, timeout); + return screen->fence_finish(screen, NULL, pipe_fence, timeout); else return driscreen->opencl_dri_event_wait(fence->cl_event, timeout); } diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index adc51284767..edcd0e68439 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -525,7 +525,7 @@ dri_flush(__DRIcontext *cPriv, fence = swap_fences_pop_front(drawable); if (fence) { - (void) screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); + (void) screen->fence_finish(screen, NULL, fence, PIPE_TIMEOUT_INFINITE); screen->fence_reference(screen, &fence, NULL); } diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 5799cce033c..8d1b36056ee 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -1376,7 +1376,7 @@ void XMesaFlush( XMesaContext c ) c->st->flush(c->st, ST_FLUSH_FRONT, &fence); if (fence) { - xmdpy->screen->fence_finish(xmdpy->screen, fence, + xmdpy->screen->fence_finish(xmdpy->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); xmdpy->screen->fence_reference(xmdpy->screen, &fence, NULL); } diff --git a/src/gallium/state_trackers/nine/swapchain9.c b/src/gallium/state_trackers/nine/swapchain9.c index bc01c2dd4cf..08ee482f0d3 100644 --- a/src/gallium/state_trackers/nine/swapchain9.c +++ b/src/gallium/state_trackers/nine/swapchain9.c @@ -621,7 +621,7 @@ static void work_present(void *data) { struct end_present_struct *work = data; if (work->fence_to_wait) { - (void) work->screen->fence_finish(work->screen, work->fence_to_wait, PIPE_TIMEOUT_INFINITE); + (void) work->screen->fence_finish(work->screen, NULL, work->fence_to_wait, PIPE_TIMEOUT_INFINITE); work->screen->fence_reference(work->screen, &(work->fence_to_wait), NULL); } ID3DPresent_PresentBuffer(work->present, work->present_handle, work->hDestWindowOverride, NULL, NULL, NULL, 0); @@ -743,7 +743,7 @@ bypass_rendering: BOOL still_draw = FALSE; fence = swap_fences_see_front(This); if (fence) { - still_draw = !This->screen->fence_finish(This->screen, fence, 0); + still_draw = !This->screen->fence_finish(This->screen, NULL, fence, 0); This->screen->fence_reference(This->screen, &fence, NULL); } if (still_draw) @@ -754,7 +754,7 @@ bypass_rendering: This->tasks[0]=NULL; fence = swap_fences_pop_front(This); if (fence) { - (void) This->screen->fence_finish(This->screen, fence, PIPE_TIMEOUT_INFINITE); + (void) This->screen->fence_finish(This->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); This->screen->fence_reference(This->screen, &fence, NULL); } diff --git a/src/gallium/state_trackers/vdpau/presentation.c b/src/gallium/state_trackers/vdpau/presentation.c index e7f387e6173..2862eafa1da 100644 --- a/src/gallium/state_trackers/vdpau/presentation.c +++ b/src/gallium/state_trackers/vdpau/presentation.c @@ -327,7 +327,7 @@ vlVdpPresentationQueueBlockUntilSurfaceIdle(VdpPresentationQueue presentation_qu pipe_mutex_lock(pq->device->mutex); if (surf->fence) { screen = pq->device->vscreen->pscreen; - screen->fence_finish(screen, surf->fence, PIPE_TIMEOUT_INFINITE); + screen->fence_finish(screen, NULL, surf->fence, PIPE_TIMEOUT_INFINITE); screen->fence_reference(screen, &surf->fence, NULL); } pipe_mutex_unlock(pq->device->mutex); @@ -369,7 +369,7 @@ vlVdpPresentationQueueQuerySurfaceStatus(VdpPresentationQueue presentation_queue } else { pipe_mutex_lock(pq->device->mutex); screen = pq->device->vscreen->pscreen; - if (screen->fence_finish(screen, surf->fence, 0)) { + if (screen->fence_finish(screen, NULL, surf->fence, 0)) { screen->fence_reference(screen, &surf->fence, NULL); *status = VDP_PRESENTATION_QUEUE_STATUS_VISIBLE; pipe_mutex_unlock(pq->device->mutex); diff --git a/src/gallium/state_trackers/xa/xa_context.c b/src/gallium/state_trackers/xa/xa_context.c index 5553beb2014..715b48d7c84 100644 --- a/src/gallium/state_trackers/xa/xa_context.c +++ b/src/gallium/state_trackers/xa/xa_context.c @@ -383,7 +383,7 @@ xa_fence_wait(struct xa_fence *fence, uint64_t timeout) struct pipe_screen *screen = fence->xa->screen; boolean timed_out; - timed_out = !screen->fence_finish(screen, fence->pipe_fence, timeout); + timed_out = !screen->fence_finish(screen, NULL, fence->pipe_fence, timeout); if (timed_out) return -XA_ERR_BUSY; diff --git a/src/gallium/state_trackers/xvmc/surface.c b/src/gallium/state_trackers/xvmc/surface.c index 199712ba168..a4cd2aa2e12 100644 --- a/src/gallium/state_trackers/xvmc/surface.c +++ b/src/gallium/state_trackers/xvmc/surface.c @@ -488,7 +488,7 @@ Status XvMCGetSurfaceStatus(Display *dpy, XvMCSurface *surface, int *status) *status = 0; if (surface_priv->fence) - if (!pipe->screen->fence_finish(pipe->screen, surface_priv->fence, 0)) + if (!pipe->screen->fence_finish(pipe->screen, NULL, surface_priv->fence, 0)) *status |= XVMC_RENDERING; return Success; diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c index 82affd2de3e..5cab5a7f156 100644 --- a/src/mesa/state_tracker/st_cb_flush.c +++ b/src/mesa/state_tracker/st_cb_flush.c @@ -98,7 +98,7 @@ void st_finish( struct st_context *st ) st_flush(st, &fence, 0); if(fence) { - st->pipe->screen->fence_finish(st->pipe->screen, fence, + st->pipe->screen->fence_finish(st->pipe->screen, NULL, fence, PIPE_TIMEOUT_INFINITE); st->pipe->screen->fence_reference(st->pipe->screen, &fence, NULL); } diff --git a/src/mesa/state_tracker/st_cb_syncobj.c b/src/mesa/state_tracker/st_cb_syncobj.c index 69f2a289ada..1fa14039b59 100644 --- a/src/mesa/state_tracker/st_cb_syncobj.c +++ b/src/mesa/state_tracker/st_cb_syncobj.c @@ -87,7 +87,7 @@ static void st_check_sync(struct gl_context *ctx, struct gl_sync_object *obj) return; } - if (screen->fence_finish(screen, so->fence, 0)) { + if (screen->fence_finish(screen, NULL, so->fence, 0)) { screen->fence_reference(screen, &so->fence, NULL); so->b.StatusFlag = GL_TRUE; } @@ -110,7 +110,7 @@ static void st_client_wait_sync(struct gl_context *ctx, * already called when creating a fence. */ if (so->fence && - screen->fence_finish(screen, so->fence, timeout)) { + screen->fence_finish(screen, NULL, so->fence, timeout)) { screen->fence_reference(screen, &so->fence, NULL); so->b.StatusFlag = GL_TRUE; } -- 2.30.2