radv: Add utility function to calculate max waves.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Sat, 1 Jun 2019 16:46:21 +0000 (18:46 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Mon, 12 Aug 2019 21:00:24 +0000 (23:00 +0200)
Not AC because a lot of it is data extraction out of radv structs.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_shader.c
src/amd/vulkan/radv_shader.h

index c74bfa2e2818f457b1c4604d14e17e05d33822a9..0f0703d66d158a59f04883ad02e7f4684eafcc95 100644 (file)
@@ -1279,23 +1279,21 @@ radv_get_shader_name(struct radv_shader_variant_info *info,
        };
 }
 
-static void
-generate_shader_stats(struct radv_device *device,
-                     struct radv_shader_variant *variant,
-                     gl_shader_stage stage,
-                     struct _mesa_string_buffer *buf)
+
+unsigned
+radv_get_max_waves(struct radv_device *device,
+                   struct radv_shader_variant *variant,
+                   gl_shader_stage stage)
 {
        enum chip_class chip_class = device->physical_device->rad_info.chip_class;
        unsigned lds_increment = chip_class >= GFX7 ? 512 : 256;
        uint8_t wave_size = variant->info.info.wave_size;
-       struct ac_shader_config *conf;
+       struct ac_shader_config *conf = &variant->config;
        unsigned max_simd_waves;
        unsigned lds_per_wave = 0;
 
        max_simd_waves = ac_get_max_simd_waves(device->physical_device->rad_info.family);
 
-       conf = &variant->config;
-
        if (stage == MESA_SHADER_FRAGMENT) {
                lds_per_wave = conf->lds_size * lds_increment +
                               align(variant->info.fs.num_interp * 48,
@@ -1323,6 +1321,18 @@ generate_shader_stats(struct radv_device *device,
        if (lds_per_wave)
                max_simd_waves = MIN2(max_simd_waves, 16384 / lds_per_wave);
 
+       return max_simd_waves;
+}
+
+static void
+generate_shader_stats(struct radv_device *device,
+                     struct radv_shader_variant *variant,
+                     gl_shader_stage stage,
+                     struct _mesa_string_buffer *buf)
+{
+       struct ac_shader_config *conf = &variant->config;
+       unsigned max_simd_waves = radv_get_max_waves(device, variant, stage);
+
        if (stage == MESA_SHADER_FRAGMENT) {
                _mesa_string_buffer_printf(buf, "*** SHADER CONFIG ***\n"
                                           "SPI_PS_INPUT_ADDR = 0x%04x\n"
index 9adf2a6a279622164257c6a1669ba1132d6a0871..f93b1ec0fe2263c6aa155a95bd44bed41220cb1d 100644 (file)
@@ -413,6 +413,12 @@ void
 radv_shader_variant_destroy(struct radv_device *device,
                            struct radv_shader_variant *variant);
 
+
+unsigned
+radv_get_max_waves(struct radv_device *device,
+                   struct radv_shader_variant *variant,
+                   gl_shader_stage stage);
+
 const char *
 radv_get_shader_name(struct radv_shader_variant_info *info,
                     gl_shader_stage stage);