radeonsi: cleanly communicate whether si_shader_dump should check R600_DEBUG
authorMarek Olšák <marek.olsak@amd.com>
Tue, 3 Jan 2017 13:19:37 +0000 (14:19 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 9 Jan 2017 11:01:30 +0000 (12:01 +0100)
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Acked-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index cb14a35d7549c52594e4f13fa425bfd9a16aa5e8..fe29fb154d5301c8535198fd9f245aa44c4c1513 100644 (file)
@@ -170,7 +170,7 @@ static void *si_create_compute_state(
                                     &program->shader.config, 0);
                }
                si_shader_dump(sctx->screen, &program->shader, &sctx->b.debug,
-                              PIPE_SHADER_COMPUTE, stderr);
+                              PIPE_SHADER_COMPUTE, stderr, true);
                if (si_shader_binary_upload(sctx->screen, &program->shader) < 0) {
                        fprintf(stderr, "LLVM failed to upload shader\n");
                        FREE(program);
index ef92790ad55983bd8e7d4ec02a1d4e8ae65776c5..9f381fe12579f29ba07f9b13bb6f274bf0a31b5a 100644 (file)
@@ -45,7 +45,7 @@ static void si_dump_shader(struct si_screen *sscreen,
                fwrite(current->shader_log, current->shader_log_size, 1, f);
        else
                si_shader_dump(sscreen, state->current, NULL,
-                              state->cso->info.processor, f);
+                              state->cso->info.processor, f, false);
 }
 
 /**
index 8dec55c25e39f140de35c4024cfb6196619675da..5dfbd6603aad7f725e541bef97389e5e45eaff2f 100644 (file)
@@ -6169,7 +6169,8 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
                                 struct si_shader *shader,
                                 struct pipe_debug_callback *debug,
                                 unsigned processor,
-                                FILE *file)
+                                FILE *file,
+                                bool check_debug_option)
 {
        struct si_shader_config *conf = &shader->config;
        unsigned num_inputs = shader->selector ? shader->selector->info.num_inputs : 0;
@@ -6220,7 +6221,7 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
        if (lds_per_wave)
                max_simd_waves = MIN2(max_simd_waves, 16384 / lds_per_wave);
 
-       if (file != stderr ||
+       if (!check_debug_option ||
            r600_can_dump_shader(&sscreen->b, processor)) {
                if (processor == PIPE_SHADER_FRAGMENT) {
                        fprintf(file, "*** SHADER CONFIG ***\n"
@@ -6291,19 +6292,19 @@ static const char *si_get_shader_name(struct si_shader *shader,
 
 void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
                    struct pipe_debug_callback *debug, unsigned processor,
-                   FILE *file)
+                   FILE *file, bool check_debug_option)
 {
-       if (file != stderr ||
+       if (!check_debug_option ||
            r600_can_dump_shader(&sscreen->b, processor))
                si_dump_shader_key(processor, &shader->key, file);
 
-       if (file != stderr && shader->binary.llvm_ir_string) {
+       if (!check_debug_option && shader->binary.llvm_ir_string) {
                fprintf(file, "\n%s - main shader part - LLVM IR:\n\n",
                        si_get_shader_name(shader, processor));
                fprintf(file, "%s\n", shader->binary.llvm_ir_string);
        }
 
-       if (file != stderr ||
+       if (!check_debug_option ||
            (r600_can_dump_shader(&sscreen->b, processor) &&
             !(sscreen->b.debug_flags & DBG_NO_ASM))) {
                fprintf(file, "\n%s:\n", si_get_shader_name(shader, processor));
@@ -6320,7 +6321,8 @@ void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
                fprintf(file, "\n");
        }
 
-       si_shader_dump_stats(sscreen, shader, debug, processor, file);
+       si_shader_dump_stats(sscreen, shader, debug, processor, file,
+                            check_debug_option);
 }
 
 int si_compile_llvm(struct si_screen *sscreen,
@@ -6553,7 +6555,7 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
                if (r600_can_dump_shader(&sscreen->b, PIPE_SHADER_GEOMETRY))
                        fprintf(stderr, "GS Copy Shader:\n");
                si_shader_dump(sscreen, ctx.shader, debug,
-                              PIPE_SHADER_GEOMETRY, stderr);
+                              PIPE_SHADER_GEOMETRY, stderr, true);
                r = si_shader_binary_upload(sscreen, ctx.shader);
        }
 
@@ -8611,7 +8613,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
 
        si_fix_resource_usage(sscreen, shader);
        si_shader_dump(sscreen, shader, debug, sel->info.processor,
-                      stderr);
+                      stderr, true);
 
        /* Upload. */
        r = si_shader_binary_upload(sscreen, shader);
index 129e571aa732d30a3ac0cf7abf49cabdd2674128..1b5dec21e31a12c0a7ac31b61216099e639c9562 100644 (file)
@@ -546,7 +546,7 @@ unsigned si_shader_io_get_unique_index2(unsigned name, unsigned index);
 int si_shader_binary_upload(struct si_screen *sscreen, struct si_shader *shader);
 void si_shader_dump(struct si_screen *sscreen, struct si_shader *shader,
                    struct pipe_debug_callback *debug, unsigned processor,
-                   FILE *f);
+                   FILE *f, bool check_debug_option);
 void si_multiwave_lds_size_workaround(struct si_screen *sscreen,
                                      unsigned *lds_size);
 void si_shader_apply_scratch_relocs(struct si_context *sctx,
index a360672328190772c1275dc45b1539989fd27de5..99678377c8d4e00edd1f93370a65f7be0484b3dd 100644 (file)
@@ -1110,7 +1110,7 @@ static void si_build_shader_variant(void *job, int thread_index)
                FILE *f = open_memstream(&shader->shader_log,
                                         &shader->shader_log_size);
                if (f) {
-                       si_shader_dump(sscreen, shader, NULL, sel->type, f);
+                       si_shader_dump(sscreen, shader, NULL, sel->type, f, false);
                        fclose(f);
                }
        }