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 <luc@sietium.com>
This commit is contained in:
Luc Ma 2024-09-29 17:51:56 +08:00 committed by Luc Ma
parent bdacb100bf
commit dd78a6969c

View file

@ -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.
*/