egl/drm: flush before calling get_back_bo
Similar to what was done for Wayland in 58f90fd03f
:
the glthread unmarhsal thread needs to be idle to avoid
concurrent calls to get_back_bo.
Also the existing code flushed after setting dri2_surf->back
to NULL so a new back buffer was always allocated by the
glthread flush:
|---------------> dri2_drm_swap_buffers
| get_back_bo (back=0x55eb93c6c488) > # First get_back_bo call
| get_back_bo (back=0x55eb93c6c488 age: 0)<
| # dri2_surf->back = NULL
|-----> FLUSH
| get_back_bo (back=nil) > # Another get_back_bo call
| get_back_bo (back=0x55eb93c6c4c8 age: 3)<
|-----< FLUSH
|---------------< dri2_drm_swap_buffers
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/10437
Cc: mesa-stable
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27143>
This commit is contained in:

committed by
Marge Bot

parent
d9f15f8d9b
commit
6f47e87a60
@@ -329,6 +329,13 @@ dri2_drm_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
||||
if (dri2_surf->color_buffers[i].age > 0)
|
||||
dri2_surf->color_buffers[i].age++;
|
||||
|
||||
/* Flushing must be done before get_back_bo to make sure glthread's
|
||||
* unmarshalling thread is idle otherwise it might concurrently
|
||||
* call get_back_bo (eg: through dri2_drm_image_get_buffers).
|
||||
*/
|
||||
dri2_flush_drawable_for_swapbuffers(disp, draw);
|
||||
dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
|
||||
|
||||
/* Make sure we have a back buffer in case we're swapping without
|
||||
* ever rendering. */
|
||||
if (get_back_bo(dri2_surf) < 0)
|
||||
@@ -338,9 +345,6 @@ dri2_drm_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
||||
dri2_surf->current->age = 1;
|
||||
dri2_surf->back = NULL;
|
||||
|
||||
dri2_flush_drawable_for_swapbuffers(disp, draw);
|
||||
dri2_dpy->flush->invalidate(dri2_surf->dri_drawable);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user