r600g: use old shader disassembler by default 26/6426/1
authorVadim Girlin <vadimgirlin@gmail.com>
Fri, 3 May 2013 08:01:20 +0000 (12:01 +0400)
committerVadim Girlin <vadimgirlin@gmail.com>
Fri, 3 May 2013 12:53:41 +0000 (16:53 +0400)
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@gmail.com>
src/gallium/drivers/r600/r600_asm.c
src/gallium/drivers/r600/r600_pipe.c
src/gallium/drivers/r600/r600_pipe.h
src/gallium/drivers/r600/r600_shader.c

index 81b84ec..df0376a 100644 (file)
@@ -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;
index 4991fb2..daadaeb 100644 (file)
@@ -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 */
 };
index 61e2022..bb4e429 100644 (file)
@@ -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;
index fd3fe39..ab05b5a 100644 (file)
@@ -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;