[PATCH 1/2] drm/vkms: skip a blend that cannot change the frame

From: Oarora Etimis

Date: Thu Nov 26 2026 - 10:47:37 EST


A single full-screen plane no longer goes through fill_background() and the
line blend: read it straight into the output line.

Signed-off-by: Oarora Etimis <oaroraetimis@xxxxxxxxx>
---
drivers/gpu/drm/vkms/vkms_composer.c | 44 ++++++++++++++++++++++++++++++++----
1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vkms/vkms_composer.c b/drivers/gpu/drm/vkms/vkms_composer.c
index 7a6a7875520c..4e2dd568bc3e 100644
--- a/drivers/gpu/drm/vkms/vkms_composer.c
+++ b/drivers/gpu/drm/vkms/vkms_composer.c
@@ -452,13 +452,15 @@ static void clamp_line_coordinates(enum pixel_read_direction direction,
* @crtc_x_limit: width of the output buffer
* @stage_buffer: temporary buffer to convert the pixel line from the source buffer
* @output_buffer: buffer to blend the read line into.
+ * @blend_direct: false to read the line straight into @output_buffer
*/
static void blend_line(struct vkms_plane_state *current_plane, int y,
int crtc_x_limit, struct line_buffer *stage_buffer,
- struct line_buffer *output_buffer)
+ struct line_buffer *output_buffer, bool blend_direct)
{
int src_x_start, src_y_start, dst_x_start, pixel_count;
struct drm_rect dst_line, tmp_src, src_line;
+ struct line_buffer *read_buffer = blend_direct ? stage_buffer : output_buffer;

/* Avoid rendering useless lines */
if (y < current_plane->frame_info.dst.y1 ||
@@ -542,12 +544,43 @@ static void blend_line(struct vkms_plane_state *current_plane, int y,
* buffer [1].
*/
current_plane->pixel_read_line(current_plane, src_x_start, src_y_start, direction,
- pixel_count, &stage_buffer->pixels[dst_x_start]);
+ pixel_count, &read_buffer->pixels[dst_x_start]);
+
+ if (!blend_direct)
+ return;
+
pre_blend_color_transform(current_plane, stage_buffer);
pre_mul_alpha_blend(stage_buffer, output_buffer,
dst_x_start, pixel_count);
}

+static bool compose_direct(const struct vkms_crtc_state *crtc_state)
+{
+ const struct vkms_plane_state *plane;
+ const struct drm_rect *dst;
+
+ if (crtc_state->num_active_planes != 1)
+ return false;
+
+ plane = crtc_state->active_planes[0];
+ if (!plane)
+ return false;
+
+ dst = &plane->frame_info.dst;
+ if (dst->x1 != 0 || dst->y1 != 0 ||
+ dst->x2 != crtc_state->base.mode.hdisplay ||
+ dst->y2 != crtc_state->base.mode.vdisplay)
+ return false;
+
+ if (plane->frame_info.fb->format->has_alpha)
+ return false;
+
+ if (plane->base.base.color_pipeline)
+ return false;
+
+ return true;
+}
+
/**
* blend - blend the pixels from all planes and compute crc
* @wb: The writeback frame buffer metadata
@@ -579,6 +612,7 @@ static void blend(struct vkms_writeback_job *wb,

int crtc_y_limit = crtc_state->base.mode.vdisplay;
int crtc_x_limit = crtc_state->base.mode.hdisplay;
+ bool direct = compose_direct(crtc_state);

/*
* The planes are composed line-by-line to avoid heavy memory usage. It is a necessary
@@ -588,11 +622,13 @@ static void blend(struct vkms_writeback_job *wb,
* algorithm for a specific format, into the staging buffer.
*/
for (int y = 0; y < crtc_y_limit; y++) {
- fill_background(&background_color, output_buffer);
+ if (!direct)
+ fill_background(&background_color, output_buffer);

/* The active planes are composed associatively in z-order. */
for (size_t i = 0; i < n_active_planes; i++) {
- blend_line(plane[i], y, crtc_x_limit, stage_buffer, output_buffer);
+ blend_line(plane[i], y, crtc_x_limit, stage_buffer,
+ output_buffer, !direct);
}

apply_lut(crtc_state, output_buffer);

--
2.56.1