turnip: add cache invalidate to fix input attachment cases
authorJonathan Marek <jonathan@marek.ca>
Tue, 17 Dec 2019 22:59:45 +0000 (17:59 -0500)
committerJonathan Marek <jonathan@marek.ca>
Thu, 19 Dec 2019 00:03:37 +0000 (19:03 -0500)
Fixes artifacts in the subpasses demo.

Workaround texture cache with input attachments from GMEM by adding a cache
invalidate between subpasses.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3143>

src/freedreno/vulkan/tu_cmd_buffer.c

index d654f0bff9ba2109d10903059bc02c26f614ab64..0080e10ee6641d4bf8a802b22c74e5e1ab8de058 100644 (file)
@@ -1461,7 +1461,7 @@ tu_cmd_prepare_tile_load_ib(struct tu_cmd_buffer *cmd,
                             const VkRenderPassBeginInfo *info)
 {
    const uint32_t tile_load_space =
-      6 + (23+19) * cmd->state.pass->attachment_count +
+      8 + (23+19) * cmd->state.pass->attachment_count +
       21 + (13 * cmd->state.subpass->color_count + 8) + 11;
 
    struct tu_cs sub_cs;
@@ -1483,6 +1483,13 @@ tu_cmd_prepare_tile_load_ib(struct tu_cmd_buffer *cmd,
    for (uint32_t i = 0; i < cmd->state.pass->attachment_count; ++i)
       tu6_emit_clear_attachment(cmd, &sub_cs, i, info);
 
+   /* invalidate because reading input attachments will cache GMEM and
+    * the cache isn''t updated when GMEM is written
+    * TODO: is there a no-cache bit for textures?
+    */
+   if (cmd->state.subpass->input_count)
+      tu6_emit_event_write(cmd, &sub_cs, CACHE_INVALIDATE, false);
+
    tu6_emit_zs(cmd, cmd->state.subpass, &sub_cs);
    tu6_emit_mrt(cmd, cmd->state.subpass, &sub_cs);
    tu6_emit_msaa(cmd, cmd->state.subpass, &sub_cs);
@@ -2386,6 +2393,13 @@ tu_CmdNextSubpass(VkCommandBuffer commandBuffer, VkSubpassContents contents)
       }
    }
 
+   /* invalidate because reading input attachments will cache GMEM and
+    * the cache isn''t updated when GMEM is written
+    * TODO: is there a no-cache bit for textures?
+    */
+   if (cmd->state.subpass->input_count)
+      tu6_emit_event_write(cmd, cs, CACHE_INVALIDATE, false);
+
    /* emit mrt/zs/msaa state for the subpass that is starting */
    tu6_emit_zs(cmd, cmd->state.subpass, cs);
    tu6_emit_mrt(cmd, cmd->state.subpass, cs);