panvk: Initialize clear values to zero when load_op != OP_CLEAR
authorBoris Brezillon <boris.brezillon@collabora.com>
Mon, 6 Sep 2021 14:18:45 +0000 (16:18 +0200)
committerBoris Brezillon <boris.brezillon@collabora.com>
Fri, 10 Sep 2021 09:41:59 +0000 (11:41 +0200)
This is easier to detect when something goes wrong with this default
initialization in place.

Signed-off-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12762>

src/panfrost/vulkan/panvk_cmd_buffer.c

index 4b0c990..ae13cd4 100644 (file)
@@ -326,10 +326,17 @@ panvk_cmd_prepare_clear_values(struct panvk_cmd_buffer *cmdbuf,
               attachment->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
              cmdbuf->state.clear[i].depth = in[i].depthStencil.depth;
              cmdbuf->state.clear[i].stencil = in[i].depthStencil.stencil;
+          } else {
+             cmdbuf->state.clear[i].depth = 0;
+             cmdbuf->state.clear[i].stencil = 0;
+          }
+       } else {
+          if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
+             union pipe_color_union *col = (union pipe_color_union *) &in[i].color;
+             pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
+          } else {
+             memset(cmdbuf->state.clear[i].color, 0, sizeof(cmdbuf->state.clear[0].color));
           }
-       } else if (attachment->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
-          union pipe_color_union *col = (union pipe_color_union *) &in[i].color;
-          pan_pack_color(cmdbuf->state.clear[i].color, col, fmt, false);
        }
    }
 }