From: Shixiong Ou <[email protected]>

pre_blend_color_transform() traverses the colorop pipeline and unpacks
each pixel into s32 for every line, even when all colorops are bypassed
or the pipeline is empty.  Add a line-level check to skip the entire
function in that case, avoiding per-pixel overhead.

Signed-off-by: Shixiong Ou <[email protected]>
---
 drivers/gpu/drm/vkms/vkms_composer.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c 
b/drivers/gpu/drm/vkms/vkms_composer.c
index f3fb203946e8..1806c249da6f 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -190,13 +190,29 @@ static void apply_colorop(struct pixel_argb_s32 *pixel, 
struct drm_colorop *colo
        }
 }
 
+static bool pipeline_all_bypassed(struct drm_colorop *colorop)
+{
+       while (colorop) {
+               struct drm_colorop_state *colorop_state = colorop->state;
+
+               if (!colorop_state || !colorop_state->bypass)
+                       return false;
+               colorop = colorop->next;
+       }
+       return true;
+}
+
 static void pre_blend_color_transform(const struct vkms_plane_state 
*plane_state,
                                      struct line_buffer *output_buffer)
 {
+       struct drm_colorop *colorop = plane_state->base.base.color_pipeline;
        struct pixel_argb_s32 pixel;
 
+       if (!colorop || pipeline_all_bypassed(colorop))
+               return;
+
        for (size_t x = 0; x < output_buffer->n_pixels; x++) {
-               struct drm_colorop *colorop = 
plane_state->base.base.color_pipeline;
+               colorop = plane_state->base.base.color_pipeline;
 
                /*
                 * Some operations, such as applying a BT709 encoding matrix,
-- 
2.25.1


No virus found
                Checked by Hillstone Network AntiVirus

Reply via email to