From 0fd04379936c7251a8751944647c5a6fcacf9802 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 4 Sep 2024 11:26:56 -0500 Subject: [PATCH] nvk: Add all_linear to nvk_rendering_state Reviewed-by: Mary Guillemard Part-of: --- src/nouveau/vulkan/nvk_cmd_buffer.h | 2 ++ src/nouveau/vulkan/nvk_cmd_draw.c | 11 +++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.h b/src/nouveau/vulkan/nvk_cmd_buffer.h index dbdcef45311..7ea951f4db7 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.h +++ b/src/nouveau/vulkan/nvk_cmd_buffer.h @@ -159,6 +159,8 @@ struct nvk_rendering_state { struct nvk_attachment color_att[NVK_MAX_RTS]; struct nvk_attachment depth_att; struct nvk_attachment stencil_att; + + bool all_linear; }; struct nvk_graphics_state { diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 71af4a8eb1a..7dfe2627d08 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -782,6 +782,8 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, nvk_attachment_init(&render->stencil_att, pRenderingInfo->pStencilAttachment); + render->all_linear = nvk_rendering_all_linear(render); + nvk_cmd_buffer_dirty_render_pass(cmd); /* Always emit at least one color attachment, even if it's just a dummy. */ @@ -801,8 +803,6 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, .height = render->area.extent.height, }); - const bool all_linear = nvk_rendering_all_linear(render); - enum nil_sample_layout sample_layout = NIL_SAMPLE_LAYOUT_INVALID; for (uint32_t i = 0; i < color_att_count; i++) { if (render->color_att[i].iview) { @@ -816,7 +816,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, const uint8_t ip = iview->planes[0].image_plane; const struct nvk_image_plane *plane = &image->planes[ip]; - if (!all_linear && !plane->nil.levels[0].tiling.is_tiled) + if (!render->all_linear && !plane->nil.levels[0].tiling.is_tiled) plane = &image->linear_tiled_shadow; const struct nil_image *nil_image = &plane->nil; @@ -1059,7 +1059,7 @@ nvk_CmdBeginRendering(VkCommandBuffer commandBuffer, const VkAttachmentLoadOp load_op = pRenderingInfo->pColorAttachments[i].loadOp; - if (!all_linear && !plane->nil.levels[0].tiling.is_tiled && + if (!render->all_linear && !plane->nil.levels[0].tiling.is_tiled && load_op == VK_ATTACHMENT_LOAD_OP_LOAD) nvk_linear_render_copy(cmd, iview, render->area, true); } @@ -1125,7 +1125,6 @@ nvk_CmdEndRendering(VkCommandBuffer commandBuffer) struct nvk_rendering_state *render = &cmd->state.gfx.render; if (!(render->flags & VK_RENDERING_SUSPENDING_BIT)) { - const bool all_linear = nvk_rendering_all_linear(render); for (uint32_t i = 0; i < render->color_att_count; i++) { struct nvk_image_view *iview = render->color_att[i].iview; if (iview == NULL) @@ -1134,7 +1133,7 @@ nvk_CmdEndRendering(VkCommandBuffer commandBuffer) struct nvk_image *image = (struct nvk_image *)iview->vk.image; const uint8_t ip = iview->planes[0].image_plane; const struct nvk_image_plane *plane = &image->planes[ip]; - if (!all_linear && !plane->nil.levels[0].tiling.is_tiled && + if (!render->all_linear && !plane->nil.levels[0].tiling.is_tiled && render->color_att[i].store_op == VK_ATTACHMENT_STORE_OP_STORE) nvk_linear_render_copy(cmd, iview, render->area, false); }