Mesa (master): turnip: disable LRZ writes when blend is enabled

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 2 04:00:57 UTC 2020


Module: Mesa
Branch: master
Commit: d1fa40bdcfca30f206938127810f55e2895bb064
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1fa40bdcfca30f206938127810f55e2895bb064

Author: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Date:   Fri Sep 11 15:16:39 2020 +0200

turnip: disable LRZ writes when blend is enabled

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5146>

---

 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 4f6d5732b9a..5d41732c47c 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 1dd9d5fa38d..9dce60f809a 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



More information about the mesa-commit mailing list