From dd78a6969c79733546b581bfdfb0150e1ede6095 Mon Sep 17 00:00:00 2001 From: Luc Ma Date: Sun, 29 Sep 2024 17:51:56 +0800 Subject: [PATCH] glamor: Force to flush when copying an exporting pixmap Consider the following scenario involving egl-create-pbuffer-surface in Piglit: egl-create-pbuffer-surface(Mesa) Xorg eglCreatePbufferSurface(); ProcCreatePixmap() xcb_dri3_buffers_from_pixmap(); proc_dri3_buffers_from_pixmap() glamor_egl_fds_from_pixmap() glamor_make_pixmap_exportable() glamor_copy_fbo_fbo_draw() ( no flush ) eglBindTexImage(); draw(); glReadPixels(); BlockHandler() (flush) (flush) In this case, there is no guarantee which command stream will go into GPU first. There is a small chance that pixmap BO importer's render buffer could be overwritten by glamor. v2: perform the flush at the highest level possible (Michel) Signed-off-by: Luc Ma --- glamor/glamor_egl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c index 5e0cbb035..3486213bb 100644 --- a/glamor/glamor_egl.c +++ b/glamor/glamor_egl.c @@ -359,6 +359,11 @@ glamor_make_pixmap_exportable(PixmapPtr pixmap, Bool modifiers_ok) 0, 0, width, height, 0, 0); FreeScratchGC(scratch_gc); + /* In case that the pixmap backing BO importer's command stream accidentally + * gets flushed first. + */ + glFlush(); + /* Now, swap the tex/gbm/EGLImage/etc. of the exported pixmap into * the original pixmap struct. */