radv: always initialize the clear color values to 0
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 19 Jun 2018 13:56:19 +0000 (15:56 +0200)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 20 Jun 2018 11:21:42 +0000 (13:21 +0200)
Having random data in there is probably not the best.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/amd/vulkan/radv_cmd_buffer.c
src/amd/vulkan/radv_meta_clear.c
src/amd/vulkan/radv_private.h

index e13f7a94e1d33dd7bc26ec331079058533747172..fb775c1cc481936db70e0dc801cc8e2e20022c42 100644 (file)
@@ -1354,10 +1354,9 @@ radv_update_bound_fast_clear_color(struct radv_cmd_buffer *cmd_buffer,
 /**
  * Set the clear color values to the image's metadata.
  */
-void
+static void
 radv_set_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
                              struct radv_image *image,
-                             int cb_idx,
                              uint32_t color_values[2])
 {
        struct radeon_cmdbuf *cs = cmd_buffer->cs;
@@ -1375,6 +1374,20 @@ radv_set_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
        radeon_emit(cs, va >> 32);
        radeon_emit(cs, color_values[0]);
        radeon_emit(cs, color_values[1]);
+}
+
+/**
+ * Update the clear color values for this image.
+ */
+void
+radv_update_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
+                                struct radv_image *image,
+                                int cb_idx,
+                                uint32_t color_values[2])
+{
+       assert(radv_image_has_cmask(image) || radv_image_has_dcc(image));
+
+       radv_set_color_clear_metadata(cmd_buffer, image, color_values);
 
        radv_update_bound_fast_clear_color(cmd_buffer, image, cb_idx,
                                           color_values);
@@ -4061,6 +4074,11 @@ static void radv_init_color_image_metadata(struct radv_cmd_buffer *cmd_buffer,
 
                radv_set_dcc_need_cmask_elim_pred(cmd_buffer, image, false);
        }
+
+       if (radv_image_has_cmask(image) || radv_image_has_dcc(image)) {
+               uint32_t color_values[2] = {};
+               radv_set_color_clear_metadata(cmd_buffer, image, color_values);
+       }
 }
 
 /**
index e9af0532859fd0d6ebf42335f13e3084ad51e829..01d75c23d6ac71d6268078b401bba4f3eee041e8 100644 (file)
@@ -1104,8 +1104,8 @@ emit_fast_color_clear(struct radv_cmd_buffer *cmd_buffer,
                cmd_buffer->state.flush_bits |= flush_bits;
        }
 
-       radv_set_color_clear_metadata(cmd_buffer, iview->image, subpass_att,
-                                     clear_color);
+       radv_update_color_clear_metadata(cmd_buffer, iview->image, subpass_att,
+                                        clear_color);
 
        return true;
 fail:
index 27440da595e2482d07b9ab39d2d456b3d8f8847b..e6aaf16447902ec2133ab9dde8e9b3e4f55436fa 100644 (file)
@@ -1117,10 +1117,10 @@ void radv_set_ds_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
                                VkClearDepthStencilValue ds_clear_value,
                                VkImageAspectFlags aspects);
 
-void radv_set_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
-                                  struct radv_image *image,
-                                  int cb_idx,
-                                  uint32_t color_values[2]);
+void radv_update_color_clear_metadata(struct radv_cmd_buffer *cmd_buffer,
+                                     struct radv_image *image,
+                                     int cb_idx,
+                                     uint32_t color_values[2]);
 
 void radv_set_dcc_need_cmask_elim_pred(struct radv_cmd_buffer *cmd_buffer,
                                       struct radv_image *image,