[Mesa-dev] [PATCH] r600g: use old shader disassembler by default

Marek Olšák maraeo at gmail.com
Fri May 3 03:40:16 PDT 2013


Reviewed-by: Marek Olšák <maraeo at gmail.com>

Marek

On Fri, May 3, 2013 at 10:04 AM, Vadim Girlin <vadimgirlin at gmail.com> wrote:
> New disassembler is not completely isolated yet from further processing
> in r600g/sb that is not required for printing the dump, so it has higher
> probability to fail in case of any unexpected features in the bytecode.
>
> This patch adds "sbdisasm" flag for R600_DEBUG that allows to use new
> disassembler in r600g/sb for shader dumps when shader optimization
> is not enabled.
>
> If shader optimization is enabled, new disassembler is used by default.
>
> Signed-off-by: Vadim Girlin <vadimgirlin at gmail.com>
> ---
>  src/gallium/drivers/r600/r600_asm.c    | 13 +++++++------
>  src/gallium/drivers/r600/r600_pipe.c   |  1 +
>  src/gallium/drivers/r600/r600_pipe.h   |  1 +
>  src/gallium/drivers/r600/r600_shader.c | 22 +++++++++-------------
>  4 files changed, 18 insertions(+), 19 deletions(-)
>
> diff --git a/src/gallium/drivers/r600/r600_asm.c b/src/gallium/drivers/r600/r600_asm.c
> index 81b84ec..df0376a 100644
> --- a/src/gallium/drivers/r600/r600_asm.c
> +++ b/src/gallium/drivers/r600/r600_asm.c
> @@ -2281,6 +2281,7 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
>         uint32_t *bytecode;
>         int i, j, r, fs_size;
>         struct r600_fetch_shader *shader;
> +       unsigned sb_disasm = rctx->screen->debug_flags & (DBG_SB_DISASM | DBG_SB);
>
>         assert(count < 32);
>
> @@ -2387,13 +2388,13 @@ void *r600_create_vertex_fetch_shader(struct pipe_context *ctx,
>                         fprintf(stderr, "\n");
>                 }
>
> -#if 0
> -               r600_bytecode_disasm(&bc);
> +               if (!sb_disasm) {
> +                       r600_bytecode_disasm(&bc);
>
> -               fprintf(stderr, "______________________________________________________________\n");
> -#else
> -               r600_sb_bytecode_process(rctx, &bc, NULL, 1 /*dump*/, 0 /*optimize*/);
> -#endif
> +                       fprintf(stderr, "______________________________________________________________\n");
> +               } else {
> +                       r600_sb_bytecode_process(rctx, &bc, NULL, 1 /*dump*/, 0 /*optimize*/);
> +               }
>         }
>
>         fs_size = bc.ndw*4;
> diff --git a/src/gallium/drivers/r600/r600_pipe.c b/src/gallium/drivers/r600/r600_pipe.c
> index 4991fb2..daadaeb 100644
> --- a/src/gallium/drivers/r600/r600_pipe.c
> +++ b/src/gallium/drivers/r600/r600_pipe.c
> @@ -73,6 +73,7 @@ static const struct debug_named_value debug_options[] = {
>         { "sbstat", DBG_SB_STAT, "Print optimization statistics for shaders" },
>         { "sbdump", DBG_SB_DUMP, "Print IR dumps after some optimization passes" },
>         { "sbnofallback", DBG_SB_NO_FALLBACK, "Abort on errors instead of fallback" },
> +       { "sbdisasm", DBG_SB_DISASM, "Use sb disassembler for shader dumps" },
>
>         DEBUG_NAMED_VALUE_END /* must be last */
>  };
> diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
> index 61e2022..bb4e429 100644
> --- a/src/gallium/drivers/r600/r600_pipe.h
> +++ b/src/gallium/drivers/r600/r600_pipe.h
> @@ -264,6 +264,7 @@ typedef boolean (*r600g_dma_blit_t)(struct pipe_context *ctx,
>  #define DBG_SB_STAT            (1 << 24)
>  #define DBG_SB_DUMP            (1 << 25)
>  #define DBG_SB_NO_FALLBACK     (1 << 26)
> +#define DBG_SB_DISASM  (1 << 27)
>
>  struct r600_tiling_info {
>         unsigned num_channels;
> diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c
> index 49218e5..9afd57f 100644
> --- a/src/gallium/drivers/r600/r600_shader.c
> +++ b/src/gallium/drivers/r600/r600_shader.c
> @@ -141,6 +141,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
>         uint32_t *ptr;
>         bool dump = r600_can_dump_shader(rctx->screen, tgsi_get_processor_type(sel->tokens));
>         unsigned use_sb = rctx->screen->debug_flags & DBG_SB;
> +       unsigned sb_disasm = use_sb || (rctx->screen->debug_flags & DBG_SB_DISASM);
>
>         shader->shader.bc.isa = rctx->isa;
>
> @@ -163,21 +164,18 @@ int r600_pipe_shader_create(struct pipe_context *ctx,
>                 return r;
>         }
>
> -#if 0
> -       if (dump) {
> +       if (dump && !sb_disasm) {
>                 fprintf(stderr, "--------------------------------------------------------------\n");
>                 r600_bytecode_disasm(&shader->shader.bc);
>                 fprintf(stderr, "______________________________________________________________\n");
> -       }
> -#else
> -       if (dump || use_sb) {
> -               r = r600_sb_bytecode_process(rctx, &shader->shader.bc, &shader->shader, dump, use_sb);
> +       } else if ((dump && sb_disasm) || use_sb) {
> +               r = r600_sb_bytecode_process(rctx, &shader->shader.bc, &shader->shader,
> +                                            dump, use_sb);
>                 if (r) {
>                         R600_ERR("r600_sb_bytecode_process failed !\n");
>                         return r;
>                 }
>         }
> -#endif
>
>         /* Store the shader in a buffer. */
>         if (shader->bo == NULL) {
> @@ -307,6 +305,8 @@ int r600_compute_shader_create(struct pipe_context * ctx,
>         boolean use_kill = false;
>         bool dump = (r600_ctx->screen->debug_flags & DBG_CS) != 0;
>         unsigned use_sb = r600_ctx->screen->debug_flags & DBG_SB_CS;
> +       unsigned sb_disasm = use_sb ||
> +                       (r600_ctx->screen->debug_flags & DBG_SB_DISASM);
>
>         shader_ctx.bc = bytecode;
>         r600_bytecode_init(shader_ctx.bc, r600_ctx->chip_class, r600_ctx->family,
> @@ -321,16 +321,12 @@ int r600_compute_shader_create(struct pipe_context * ctx,
>         }
>         r600_bytecode_build(shader_ctx.bc);
>
> -#if 0
> -       if (dump) {
> +       if (dump && !sb_disasm) {
>                 r600_bytecode_disasm(shader_ctx.bc);
> -       }
> -#else
> -       if (dump || use_sb) {
> +       } else if ((dump && sb_disasm) || use_sb) {
>                 if (r600_sb_bytecode_process(r600_ctx, shader_ctx.bc, NULL, dump, use_sb))
>                         R600_ERR("r600_sb_bytecode_process failed!\n");
>         }
> -#endif
>
>         free(bytes);
>         return 1;
> --
> 1.8.2.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list