From e8b9a955c08404fa32bec8a9fa08446f4b3e87b7 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 19 Jul 2024 08:38:17 +0200 Subject: [PATCH] glamor: use glBlit where possible When we're simply doing a blit, using glBlitFramebuffer gives more information to the GL driver about what our intent is and can optionally enable optimizations (eg: do a copy instead of a draw). The main use case I have for this is 'present_copy_region' (which calls into glamor_copy_area and utltimately this function). For now glBlit usage is stricter than required (eg: single src/dst box), and could be extended later if it proves useful. Signed-off-by: Pierre-Eric Pelloux-Prayer --- glamor/glamor_copy.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/glamor/glamor_copy.c b/glamor/glamor_copy.c index 909565368..9500f7f00 100644 --- a/glamor/glamor_copy.c +++ b/glamor/glamor_copy.c @@ -384,6 +384,30 @@ glamor_copy_fbo_fbo_draw(DrawablePtr src, if (bitplane && !glamor_priv->can_copyplane) goto bail_ctx; + /* Try blit directly. */ + if (!bitplane && (!gc || gc->alu == GXcopy) && nbox == 1 && src_pixmap != dst_pixmap && + glamor_pixmap_hcnt(src_priv) == 1 && glamor_pixmap_hcnt(dst_priv) == 1) { + int dst_samples, src_samples; + + /* Assume DSA is available for simplicity. */ + glGetNamedFramebufferParameteriv(src_priv->fbo->fb, GL_SAMPLES, &src_samples); + glGetNamedFramebufferParameteriv(dst_priv->fbo->fb, GL_SAMPLES, &dst_samples); + + if (src_samples == dst_samples) { + glamor_get_drawable_deltas(src, src_pixmap, &src_off_x, &src_off_y); + glamor_get_drawable_deltas(dst, dst_pixmap, &dst_off_x, &dst_off_y); + + glBlitNamedFramebuffer( + src_priv->fbo->fb, dst_priv->fbo->fb, + box[0].x1 + dx + src_off_x, box[0].y1 + dy + src_off_y, + box[0].x2 + dx + src_off_x, box[0].y2 + dy + src_off_y, + box[0].x1 + dst_off_x, box[0].y1 + dst_off_y, + box[0].x2 + dst_off_x, box[0].y2 + dst_off_y, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + return TRUE; + } + } + if (bitplane) { prog = &glamor_priv->copy_plane_prog; copy_facet = &glamor_facet_copyplane;