From: Thomas Hellstrom Date: Thu, 14 Sep 2017 11:09:05 +0000 (+0200) Subject: loader/dri3: Don't accidently free buffer holding new back content X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=15e208c4ccdd94582a459d0066b587f91caf270c;p=mesa.git loader/dri3: Don't accidently free buffer holding new back content Avoid freeing buffers holding new back content (with GLX_SWAP_COPY_OML and GLX_SWAP_EXCHANGE_OML) Prevously that would have resulted in back buffer content becoming incorrect after a swap, although I haven't managed to trigger such a situation yet. Signed-off-by: Thomas Hellstrom Reviewed-by: Sinclair Yeh --- diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c index dcc713d6d42..19ab5815100 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -391,13 +391,13 @@ dri3_handle_present_event(struct loader_dri3_drawable *draw, for (b = 0; b < sizeof(draw->buffers) / sizeof(draw->buffers[0]); b++) { struct loader_dri3_buffer *buf = draw->buffers[b]; - if (buf && buf->pixmap == ie->pixmap) { + if (buf && buf->pixmap == ie->pixmap) buf->busy = 0; - if (draw->num_back <= b && b < LOADER_DRI3_MAX_BACK) { - dri3_free_render_buffer(draw, buf); - draw->buffers[b] = NULL; - } - break; + + if (buf && draw->num_back <= b && b < LOADER_DRI3_MAX_BACK && + draw->cur_blit_source != b) { + dri3_free_render_buffer(draw, buf); + draw->buffers[b] = NULL; } } break; @@ -1469,10 +1469,12 @@ dri3_free_buffers(__DRIdrawable *driDrawable, case loader_dri3_buffer_back: first_id = LOADER_DRI3_BACK_ID(0); n_id = LOADER_DRI3_MAX_BACK; + draw->cur_blit_source = -1; break; case loader_dri3_buffer_front: first_id = LOADER_DRI3_FRONT_ID; - n_id = 1; + /* Don't free a fake front holding new backbuffer content. */ + n_id = (draw->cur_blit_source == LOADER_DRI3_FRONT_ID) ? 0 : 1; } for (buf_id = first_id; buf_id < first_id + n_id; buf_id++) {