[Mesa-dev] [PATCH] radeonsi: use the correct LLVMTargetMachineRef in si_build_shader_variant

Marek Olšák maraeo at gmail.com
Tue Jun 13 23:09:18 UTC 2017


On Mon, Jun 12, 2017 at 11:26 PM, Nicolai Hähnle <nhaehnle at gmail.com> wrote:
> From: Nicolai Hähnle <nicolai.haehnle at amd.com>
>
> si_build_shader_variant can actually be called directly from one of
> normal-priority compiler threads. In that case, the thread_index is
> only valid for the normal tm array.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=101384 (maybe)
> Fixes: 86cc8097266c ("radeonsi: use a compiler queue with a low priority for optimized shaders")
> --
> I'm not sure whether this actually fixes the linked bug, waiting for
> the reporter to provide an update. That said, it seems pretty clear
> that there is a bug here as described, and this patch should fix it.
>
> ---
>  src/gallium/drivers/radeonsi/si_state_shaders.c | 62 ++++++++++++++++---------
>  1 file changed, 39 insertions(+), 23 deletions(-)
>
> diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c
> index 677a6de..7758545 100644
> --- a/src/gallium/drivers/radeonsi/si_state_shaders.c
> +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c
> @@ -1438,58 +1438,79 @@ static inline void si_shader_selector_key(struct pipe_context *ctx,
>                 break;
>         }
>         default:
>                 assert(0);
>         }
>
>         if (unlikely(sctx->screen->b.debug_flags & DBG_NO_OPT_VARIANT))
>                 memset(&key->opt, 0, sizeof(key->opt));
>  }
>
> -static void si_build_shader_variant(void *job, int thread_index)
> +static LLVMTargetMachineRef get_tm(struct si_shader_selector *sel,
> +                                  int thread_index)
>  {
> -       struct si_shader *shader = (struct si_shader *)job;
> -       struct si_shader_selector *sel = shader->selector;
>         struct si_screen *sscreen = sel->screen;
> -       LLVMTargetMachineRef tm;
> -       struct pipe_debug_callback *debug = &shader->compiler_ctx_state.debug;
> -       int r;
>
>         if (thread_index >= 0) {
> -               assert(thread_index < ARRAY_SIZE(sscreen->tm_low_priority));
> -               tm = sscreen->tm_low_priority[thread_index];
> -               if (!debug->async)
> -                       debug = NULL;
> -       } else {
> -               tm = shader->compiler_ctx_state.tm;
> +               assert(thread_index < ARRAY_SIZE(sscreen->tm));
> +               return sscreen->tm[thread_index];
>         }
>
> +       return sel->compiler_ctx_state.tm;

The non-async main shader selector initialization should use
sel->compiler_ctx_state.tm, but the non-async shader variant
compilation should use shader->compiler_ctx_state.tm.

Marek


More information about the mesa-dev mailing list