radeonsi: move max_simd_waves computation into a separate function
authorMarek Olšák <marek.olsak@amd.com>
Wed, 10 Jan 2018 22:09:58 +0000 (23:09 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 31 Jan 2018 02:21:20 +0000 (03:21 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h

index 76215b318a042c1703f7af5b33646f05d5d211e4..7304d7e00db1c1b976f50c692412008091912ab4 100644 (file)
@@ -5362,16 +5362,11 @@ static void si_shader_dump_disassembly(const struct ac_shader_binary *binary,
        }
 }
 
-static void si_shader_dump_stats(struct si_screen *sscreen,
-                                const struct si_shader *shader,
-                                struct pipe_debug_callback *debug,
-                                unsigned processor,
-                                FILE *file,
-                                bool check_debug_option)
+static void si_calculate_max_simd_waves(struct si_shader *shader)
 {
-       const struct si_shader_config *conf = &shader->config;
-       unsigned num_inputs = shader->selector ? shader->selector->info.num_inputs : 0;
-       unsigned code_size = si_get_shader_binary_size(shader);
+       struct si_screen *sscreen = shader->selector->screen;
+       struct si_shader_config *conf = &shader->config;
+       unsigned num_inputs = shader->selector->info.num_inputs;
        unsigned lds_increment = sscreen->info.chip_class >= CIK ? 512 : 256;
        unsigned lds_per_wave = 0;
        unsigned max_simd_waves;
@@ -5388,7 +5383,7 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
        }
 
        /* Compute LDS usage for PS. */
-       switch (processor) {
+       switch (shader->selector->type) {
        case PIPE_SHADER_FRAGMENT:
                /* The minimum usage per wave is (num_inputs * 48). The maximum
                 * usage is (num_inputs * 48 * 16).
@@ -5429,6 +5424,19 @@ 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);
 
+       conf->max_simd_waves = max_simd_waves;
+}
+
+static void si_shader_dump_stats(struct si_screen *sscreen,
+                                const struct si_shader *shader,
+                                struct pipe_debug_callback *debug,
+                                unsigned processor,
+                                FILE *file,
+                                bool check_debug_option)
+{
+       const struct si_shader_config *conf = &shader->config;
+       unsigned code_size = si_get_shader_binary_size(shader);
+
        if (!check_debug_option ||
            si_can_dump_shader(sscreen, processor)) {
                if (processor == PIPE_SHADER_FRAGMENT) {
@@ -5453,7 +5461,7 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
                        conf->spilled_sgprs, conf->spilled_vgprs,
                        conf->private_mem_vgprs, code_size,
                        conf->lds_size, conf->scratch_bytes_per_wave,
-                       max_simd_waves);
+                       conf->max_simd_waves);
        }
 
        pipe_debug_message(debug, SHADER_INFO,
@@ -5462,7 +5470,7 @@ static void si_shader_dump_stats(struct si_screen *sscreen,
                           "Spilled VGPRs: %d PrivMem VGPRs: %d",
                           conf->num_sgprs, conf->num_vgprs, code_size,
                           conf->lds_size, conf->scratch_bytes_per_wave,
-                          max_simd_waves, conf->spilled_sgprs,
+                          conf->max_simd_waves, conf->spilled_sgprs,
                           conf->spilled_vgprs, conf->private_mem_vgprs);
 }
 
@@ -6971,6 +6979,7 @@ int si_compile_tgsi_shader(struct si_screen *sscreen,
                        shader->info.num_input_vgprs += 1;
        }
 
+       si_calculate_max_simd_waves(shader);
        return 0;
 }
 
@@ -8044,6 +8053,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
                        shader->config.num_vgprs = MAX2(shader->config.num_vgprs,
                                                        shader->epilog->config.num_vgprs);
                }
+               si_calculate_max_simd_waves(shader);
        }
 
        si_fix_resource_usage(sscreen, shader);
index c449aa9684496684d7ec2bd90a2851d7ee1c8dfd..6ed1646817f689b2bc8c8fe30a5b154ad9cbc99a 100644 (file)
@@ -557,6 +557,7 @@ struct si_shader_config {
        unsigned                        spilled_vgprs;
        unsigned                        private_mem_vgprs;
        unsigned                        lds_size;
+       unsigned                        max_simd_waves;
        unsigned                        spi_ps_input_ena;
        unsigned                        spi_ps_input_addr;
        unsigned                        float_mode;