radv: Fix output for sparse MRTs.
authorBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Wed, 13 Jun 2018 21:31:54 +0000 (23:31 +0200)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Thu, 14 Jun 2018 09:48:24 +0000 (11:48 +0200)
We need to init the cb_shader_format correctly with the changed
col_format, so this moves the col_format adjustment to before the
adjustment to before the cb_shader_mask gets generated.

Fixes: 06d3c650980 "radv: fix a GPU hang when MRTs are sparse"
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106903
CC: 18.1 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
src/amd/vulkan/radv_pipeline.c

index b8b425aca9f65415a271fd7e1c92c77e6b4960ae..6eeedc65a399bac8dcc58b4b94ed57592fee75d9 100644 (file)
@@ -524,20 +524,21 @@ radv_pipeline_compute_spi_color_formats(struct radv_pipeline *pipeline,
                col_format |= cf << (4 * i);
        }
 
-       blend->cb_shader_mask = ac_get_cb_shader_mask(col_format);
-
-       if (blend->mrt0_is_dual_src)
-               col_format |= (col_format & 0xf) << 4;
-       blend->spi_shader_col_format = col_format;
-
        /* If the i-th target format is set, all previous target formats must
         * be non-zero to avoid hangs.
         */
-       num_targets = (util_last_bit(blend->spi_shader_col_format) + 3) / 4;
+       num_targets = (util_last_bit(col_format) + 3) / 4;
        for (unsigned i = 0; i < num_targets; i++) {
-               if (!(blend->spi_shader_col_format & (0xf << (i * 4))))
-                       blend->spi_shader_col_format |= V_028714_SPI_SHADER_32_R << (i * 4);
+               if (!(col_format & (0xf << (i * 4)))) {
+                       col_format |= V_028714_SPI_SHADER_32_R << (i * 4);
+               }
        }
+
+       blend->cb_shader_mask = ac_get_cb_shader_mask(col_format);
+
+       if (blend->mrt0_is_dual_src)
+               col_format |= (col_format & 0xf) << 4;
+       blend->spi_shader_col_format = col_format;
 }
 
 static bool