From d1fa40bdcfca30f206938127810f55e2895bb064 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Samuel=20Iglesias=20Gons=C3=A1lvez?= Date: Fri, 11 Sep 2020 15:16:39 +0200 Subject: [PATCH] turnip: disable LRZ writes when blend is enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuel Iglesias Gonsálvez Part-of: --- src/freedreno/vulkan/tu_pipeline.c | 18 ++++++++++++++++++ src/freedreno/vulkan/tu_private.h | 1 + 2 files changed, 19 insertions(+) diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index 4f6d573..5d41732 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -2582,6 +2582,24 @@ tu_pipeline_builder_parse_multisample_and_color_blend( assert(cs.cur == cs.end); /* validate draw state size */ + if (blend_enable_mask) { + for (int i = 0; i < blend_info->attachmentCount; i++) { + VkPipelineColorBlendAttachmentState blendAttachment = blend_info->pAttachments[i]; + /* Disable LRZ writes when blend is enabled, since the + * resulting pixel value from the blend-draw + * depends on an earlier draw, which LRZ in the draw pass + * could early-reject if the previous blend-enabled draw wrote LRZ. + * + * From the PoV of LRZ, having masked color channels is + * the same as having blend enabled, in that the draw will + * care about the fragments from an earlier draw. + */ + if (blendAttachment.blendEnable || blendAttachment.colorWriteMask != 0xf) { + pipeline->lrz.blend_disable_write = true; + } + } + } + if (tu_pipeline_static_state(pipeline, &cs, VK_DYNAMIC_STATE_BLEND_CONSTANTS, 5)) { tu_cs_emit_pkt4(&cs, REG_A6XX_RB_BLEND_RED_F32, 4); tu_cs_emit_array(&cs, (const uint32_t *) blend_info->blendConstants, 4); diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h index 1dd9d5f..9dce60f8 100644 --- a/src/freedreno/vulkan/tu_private.h +++ b/src/freedreno/vulkan/tu_private.h @@ -845,6 +845,7 @@ struct tu_lrz_pipeline bool enable : 1; bool greater : 1; bool z_test_enable : 1; + bool blend_disable_write : 1; }; struct tu_cmd_state -- 2.7.4