From 4a59bc6df2baf3be1d8bc8dbcd04b7b02df13560 Mon Sep 17 00:00:00 2001 From: Jonathan Marek Date: Tue, 17 Dec 2019 17:59:45 -0500 Subject: [PATCH] turnip: add cache invalidate to fix input attachment cases 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 Reviewed-by: Eric Anholt Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index d654f0bff9b..0080e10ee66 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -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); -- 2.30.2