<div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,</div><div><br></div><div>Please find my comments below:</div><div><br></div><div>Regards,</div><div>Andrii.</div><div><br></div><div><div class="gmail_quote"><div dir="ltr">On Tue, Sep 18, 2018 at 4:49 AM Marek Olšák <<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com" target="_blank">marek.olsak@amd.com</a>><br>
<br>
Marek<br>
<br>
On Wed, Sep 12, 2018 at 6:50 AM, Timothy Arceri <<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>> wrote:<br>
> This reverts commit bc65dcab3bc48673ff6180afb036561a4b8b1119.<br>
><br>
> This was manually reverted. Reverting stops the menu hanging in<br>
> some id tech games such as RAGE and Wolfenstein The New Order.<br>
><br>
> Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=107891" rel="noreferrer" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=107891</a><br>
> ---<br>
>  .../auxiliary/util/u_threaded_context.h       |  8 --<br>
>  src/gallium/drivers/radeonsi/si_fence.c       | 82 +++++++++----------<br>
>  src/gallium/drivers/radeonsi/si_gfx_cs.c      |  2 -<br>
>  3 files changed, 40 insertions(+), 52 deletions(-)<br>
><br>
> diff --git a/src/gallium/auxiliary/util/u_threaded_context.h b/src/gallium/auxiliary/util/u_threaded_context.h<br>
> index be6933d05a4..a32f893592a 100644<br>
> --- a/src/gallium/auxiliary/util/u_threaded_context.h<br>
> +++ b/src/gallium/auxiliary/util/u_threaded_context.h<br>
> @@ -408,14 +408,6 @@ threaded_transfer(struct pipe_transfer *transfer)<br>
>     return (struct threaded_transfer*)transfer;<br>
>  }<br>
><br>
> -static inline struct pipe_context *<br>
> -threaded_context_unwrap_unsync(struct pipe_context *pipe)<br>
> -{<br>
> -   if (!pipe || !pipe->priv)<br>
> -      return pipe;<br>
> -   return (struct pipe_context*)pipe->priv;<br>
> -}<br>
> -<br>
>  static inline void<br>
>  tc_unflushed_batch_token_reference(struct tc_unflushed_batch_token **dst,<br>
>                                     struct tc_unflushed_batch_token *src)<br>
> diff --git a/src/gallium/drivers/radeonsi/si_fence.c b/src/gallium/drivers/radeonsi/si_fence.c<br>
> index 186a785437d..abb7057f299 100644<br>
> --- a/src/gallium/drivers/radeonsi/si_fence.c<br>
> +++ b/src/gallium/drivers/radeonsi/si_fence.c<br>
> @@ -291,8 +291,12 @@ static boolean si_fence_finish(struct pipe_screen *screen,<br>
>  {<br>
>         struct radeon_winsys *rws = ((struct si_screen*)screen)->ws;<br>
>         struct si_multi_fence *rfence = (struct si_multi_fence *)fence;<br>
> +       struct si_context *sctx;<br>
>         int64_t abs_timeout = os_time_get_absolute_timeout(timeout);<br>
><br>
> +       ctx = threaded_context_unwrap_sync(ctx);<br>
> +       sctx = (struct si_context*)(ctx ? ctx : NULL);<br></blockquote><div> </div><div>Looks like it should be like:</div><div>sctx = (struct si_context*)ctx;</div><div>or maybe you meant:</div><div>sctx = (struct si_context*)(ctx ? ctx->****** : NULL);</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> +<br>
>         if (!util_queue_fence_is_signalled(&rfence->ready)) {<br>
>                 if (rfence->tc_token) {<br>
>                         /* Ensure that si_flush_from_st will be called for<br>
> @@ -345,49 +349,43 @@ static boolean si_fence_finish(struct pipe_screen *screen,<br>
>         }<br>
><br>
>         /* Flush the gfx IB if it hasn't been flushed yet. */<br>
> -       if (ctx && rfence->gfx_unflushed.ctx) {<br>
> -               struct si_context *sctx;<br>
> -<br>
> -               sctx = (struct si_context *)threaded_context_unwrap_unsync(ctx);<br>
> -               if (rfence->gfx_unflushed.ctx == sctx &&<br>
> -                   rfence->gfx_unflushed.ib_index == sctx->num_gfx_cs_flushes) {<br>
> -                       /* Section 4.1.2 (Signaling) of the OpenGL 4.6 (Core profile)<br>
> -                        * spec says:<br>
> -                        *<br>
> -                        *    "If the sync object being blocked upon will not be<br>
> -                        *     signaled in finite time (for example, by an associated<br>
> -                        *     fence command issued previously, but not yet flushed to<br>
> -                        *     the graphics pipeline), then ClientWaitSync may hang<br>
> -                        *     forever. To help prevent this behavior, if<br>
> -                        *     ClientWaitSync is called and all of the following are<br>
> -                        *     true:<br>
> -                        *<br>
> -                        *     * the SYNC_FLUSH_COMMANDS_BIT bit is set in flags,<br>
> -                        *     * sync is unsignaled when ClientWaitSync is called,<br>
> -                        *     * and the calls to ClientWaitSync and FenceSync were<br>
> -                        *       issued from the same context,<br>
> -                        *<br>
> -                        *     then the GL will behave as if the equivalent of Flush<br>
> -                        *     were inserted immediately after the creation of sync."<br>
> -                        *<br>
> -                        * This means we need to flush for such fences even when we're<br>
> -                        * not going to wait.<br>
> -                        */<br>
> -                       threaded_context_unwrap_sync(ctx);<br>
> -                       si_flush_gfx_cs(sctx,<br>
> -                                       (timeout ? 0 : PIPE_FLUSH_ASYNC) |<br>
> -                                        RADEON_FLUSH_START_NEXT_GFX_IB_NOW,<br>
> -                                       NULL);<br>
> -                       rfence->gfx_unflushed.ctx = NULL;<br>
> -<br>
> -                       if (!timeout)<br>
> -                               return false;<br>
> +       if (sctx && rfence->gfx_unflushed.ctx == sctx &&<br>
> +           rfence->gfx_unflushed.ib_index == sctx->num_gfx_cs_flushes) {<br>
> +               /* Section 4.1.2 (Signaling) of the OpenGL 4.6 (Core profile)<br>
> +                * spec says:<br>
> +                *<br>
> +                *    "If the sync object being blocked upon will not be<br>
> +                *     signaled in finite time (for example, by an associated<br>
> +                *     fence command issued previously, but not yet flushed to<br>
> +                *     the graphics pipeline), then ClientWaitSync may hang<br>
> +                *     forever. To help prevent this behavior, if<br>
> +                *     ClientWaitSync is called and all of the following are<br>
> +                *     true:<br>
> +                *<br>
> +                *     * the SYNC_FLUSH_COMMANDS_BIT bit is set in flags,<br>
> +                *     * sync is unsignaled when ClientWaitSync is called,<br>
> +                *     * and the calls to ClientWaitSync and FenceSync were<br>
> +                *       issued from the same context,<br>
> +                *<br>
> +                *     then the GL will behave as if the equivalent of Flush<br>
> +                *     were inserted immediately after the creation of sync."<br>
> +                *<br>
> +                * This means we need to flush for such fences even when we're<br>
> +                * not going to wait.<br>
> +                */<br>
> +               si_flush_gfx_cs(sctx,<br>
> +                               (timeout ? 0 : PIPE_FLUSH_ASYNC) |<br>
> +                                RADEON_FLUSH_START_NEXT_GFX_IB_NOW,<br>
> +                               NULL);<br>
> +               rfence->gfx_unflushed.ctx = NULL;<br>
><br>
> -                       /* Recompute the timeout after all that. */<br>
> -                       if (timeout && timeout != PIPE_TIMEOUT_INFINITE) {<br>
> -                               int64_t time = os_time_get_nano();<br>
> -                               timeout = abs_timeout > time ? abs_timeout - time : 0;<br>
> -                       }<br>
> +               if (!timeout)<br>
> +                       return false;<br>
> +<br>
> +               /* Recompute the timeout after all that. */<br>
> +               if (timeout && timeout != PIPE_TIMEOUT_INFINITE) {<br>
> +                       int64_t time = os_time_get_nano();<br>
> +                       timeout = abs_timeout > time ? abs_timeout - time : 0;<br>
>                 }<br>
>         }<br>
><br>
> diff --git a/src/gallium/drivers/radeonsi/si_gfx_cs.c b/src/gallium/drivers/radeonsi/si_gfx_cs.c<br>
> index 38b85ce6243..bdb576f7e5c 100644<br>
> --- a/src/gallium/drivers/radeonsi/si_gfx_cs.c<br>
> +++ b/src/gallium/drivers/radeonsi/si_gfx_cs.c<br>
> @@ -147,8 +147,6 @@ void si_flush_gfx_cs(struct si_context *ctx, unsigned flags,<br>
>         if (fence)<br>
>                 ws->fence_reference(fence, ctx->last_gfx_fence);<br>
><br>
> -       /* This must be after cs_flush returns, since the context's API<br>
> -        * thread can concurrently read this value in si_fence_finish. */<br>
>         ctx->num_gfx_cs_flushes++;<br>
><br>
>         /* Check VM faults if needed. */<br>
> --<br>
> 2.17.1<br>
><br>
> _______________________________________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div></div></div></div></div>