mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
radeonsi: avoid syncing the driver thread in si_fence_finish
It is really only required when we need to flush for deferred fences. Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
3db1ce01b1
commit
bc65dcab3b
3 changed files with 49 additions and 37 deletions
|
|
@ -407,6 +407,14 @@ threaded_transfer(struct pipe_transfer *transfer)
|
||||||
return (struct threaded_transfer*)transfer;
|
return (struct threaded_transfer*)transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline struct pipe_context *
|
||||||
|
threaded_context_unwrap_unsync(struct pipe_context *pipe)
|
||||||
|
{
|
||||||
|
if (!pipe || !pipe->priv)
|
||||||
|
return pipe;
|
||||||
|
return (struct pipe_context*)pipe->priv;
|
||||||
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
tc_unflushed_batch_token_reference(struct tc_unflushed_batch_token **dst,
|
tc_unflushed_batch_token_reference(struct tc_unflushed_batch_token **dst,
|
||||||
struct tc_unflushed_batch_token *src)
|
struct tc_unflushed_batch_token *src)
|
||||||
|
|
|
||||||
|
|
@ -188,12 +188,8 @@ static boolean si_fence_finish(struct pipe_screen *screen,
|
||||||
{
|
{
|
||||||
struct radeon_winsys *rws = ((struct r600_common_screen*)screen)->ws;
|
struct radeon_winsys *rws = ((struct r600_common_screen*)screen)->ws;
|
||||||
struct si_multi_fence *rfence = (struct si_multi_fence *)fence;
|
struct si_multi_fence *rfence = (struct si_multi_fence *)fence;
|
||||||
struct r600_common_context *rctx;
|
|
||||||
int64_t abs_timeout = os_time_get_absolute_timeout(timeout);
|
int64_t abs_timeout = os_time_get_absolute_timeout(timeout);
|
||||||
|
|
||||||
ctx = threaded_context_unwrap_sync(ctx);
|
|
||||||
rctx = ctx ? (struct r600_common_context*)ctx : NULL;
|
|
||||||
|
|
||||||
if (!util_queue_fence_is_signalled(&rfence->ready)) {
|
if (!util_queue_fence_is_signalled(&rfence->ready)) {
|
||||||
if (!timeout)
|
if (!timeout)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -245,9 +241,12 @@ static boolean si_fence_finish(struct pipe_screen *screen,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Flush the gfx IB if it hasn't been flushed yet. */
|
/* Flush the gfx IB if it hasn't been flushed yet. */
|
||||||
if (rctx &&
|
if (ctx && rfence->gfx_unflushed.ctx) {
|
||||||
rfence->gfx_unflushed.ctx == rctx &&
|
struct si_context *sctx;
|
||||||
rfence->gfx_unflushed.ib_index == rctx->num_gfx_cs_flushes) {
|
|
||||||
|
sctx = (struct si_context *)threaded_context_unwrap_unsync(ctx);
|
||||||
|
if (rfence->gfx_unflushed.ctx == &sctx->b &&
|
||||||
|
rfence->gfx_unflushed.ib_index == sctx->b.num_gfx_cs_flushes) {
|
||||||
/* Section 4.1.2 (Signaling) of the OpenGL 4.6 (Core profile)
|
/* Section 4.1.2 (Signaling) of the OpenGL 4.6 (Core profile)
|
||||||
* spec says:
|
* spec says:
|
||||||
*
|
*
|
||||||
|
|
@ -270,7 +269,8 @@ static boolean si_fence_finish(struct pipe_screen *screen,
|
||||||
* This means we need to flush for such fences even when we're
|
* This means we need to flush for such fences even when we're
|
||||||
* not going to wait.
|
* not going to wait.
|
||||||
*/
|
*/
|
||||||
rctx->gfx.flush(rctx, timeout ? 0 : RADEON_FLUSH_ASYNC, NULL);
|
threaded_context_unwrap_sync(ctx);
|
||||||
|
sctx->b.gfx.flush(&sctx->b, timeout ? 0 : RADEON_FLUSH_ASYNC, NULL);
|
||||||
rfence->gfx_unflushed.ctx = NULL;
|
rfence->gfx_unflushed.ctx = NULL;
|
||||||
|
|
||||||
if (!timeout)
|
if (!timeout)
|
||||||
|
|
@ -282,6 +282,7 @@ static boolean si_fence_finish(struct pipe_screen *screen,
|
||||||
timeout = abs_timeout > time ? abs_timeout - time : 0;
|
timeout = abs_timeout > time ? abs_timeout - time : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rws->fence_wait(rws, rfence->gfx, timeout))
|
if (rws->fence_wait(rws, rfence->gfx, timeout))
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,9 @@ void si_context_gfx_flush(void *context, unsigned flags,
|
||||||
ws->cs_flush(cs, flags, &ctx->b.last_gfx_fence);
|
ws->cs_flush(cs, flags, &ctx->b.last_gfx_fence);
|
||||||
if (fence)
|
if (fence)
|
||||||
ws->fence_reference(fence, ctx->b.last_gfx_fence);
|
ws->fence_reference(fence, ctx->b.last_gfx_fence);
|
||||||
|
|
||||||
|
/* This must be after cs_flush returns, since the context's API
|
||||||
|
* thread can concurrently read this value in si_fence_finish. */
|
||||||
ctx->b.num_gfx_cs_flushes++;
|
ctx->b.num_gfx_cs_flushes++;
|
||||||
|
|
||||||
/* Check VM faults if needed. */
|
/* Check VM faults if needed. */
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue