Module: Mesa
Branch: main
Commit: 11382a6711f5a7bc7e405377c7703ccb92461523
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=11382a6711f5a7bc7e405377c7703ccb92461523

Author: Samuel Pitoiset <[email protected]>
Date:   Wed Jan 18 08:25:54 2023 +0100

radv: add a new helper for normalizing blend factors

It will be also used when compiling PS epilogs on-demand.

Signed-off-by: Samuel Pitoiset <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20281>

---

 src/amd/vulkan/radv_pipeline.c | 10 ++--------
 src/amd/vulkan/radv_private.h  |  9 +++++++++
 2 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index 111405719c4..2f6fc7c6831 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -484,14 +484,8 @@ radv_pipeline_init_blend_state(struct 
radv_graphics_pipeline *pipeline,
             continue;
          }
 
-         if (eqRGB == VK_BLEND_OP_MIN || eqRGB == VK_BLEND_OP_MAX) {
-            srcRGB = VK_BLEND_FACTOR_ONE;
-            dstRGB = VK_BLEND_FACTOR_ONE;
-         }
-         if (eqA == VK_BLEND_OP_MIN || eqA == VK_BLEND_OP_MAX) {
-            srcA = VK_BLEND_FACTOR_ONE;
-            dstA = VK_BLEND_FACTOR_ONE;
-         }
+         radv_normalize_blend_factor(eqRGB, &srcRGB, &dstRGB);
+         radv_normalize_blend_factor(eqA, &srcA, &dstA);
 
          /* Blending optimizations for RB+.
           * These transformations don't change the behavior.
diff --git a/src/amd/vulkan/radv_private.h b/src/amd/vulkan/radv_private.h
index 64e54165c7b..55b2c3b54ba 100644
--- a/src/amd/vulkan/radv_private.h
+++ b/src/amd/vulkan/radv_private.h
@@ -3350,6 +3350,15 @@ radv_is_dual_src(VkBlendFactor factor)
    }
 }
 
+static inline void
+radv_normalize_blend_factor(VkBlendOp op, VkBlendFactor *src_factor, 
VkBlendFactor *dst_factor)
+{
+   if (op == VK_BLEND_OP_MIN || op == VK_BLEND_OP_MAX) {
+      *src_factor = VK_BLEND_FACTOR_ONE;
+      *dst_factor = VK_BLEND_FACTOR_ONE;
+   }
+}
+
 void si_blend_remove_dst(VkBlendOp *func, VkBlendFactor *src_factor, 
VkBlendFactor *dst_factor,
                          VkBlendFactor expected_dst, VkBlendFactor 
replacement_src);
 

Reply via email to