diff options
author | Thomas Hellstrom <[email protected]> | 2017-09-14 13:09:05 +0200 |
---|---|---|
committer | Thomas Hellstrom <[email protected]> | 2017-10-05 09:17:12 +0200 |
commit | 15e208c4ccdd94582a459d0066b587f91caf270c (patch) | |
tree | 629ce695a135f0965b44dc1013b3580017ba7128 /src/loader/loader_dri3_helper.c | |
parent | 1b8e0bed6989386ce096fc0dce92cd0f3df8ea88 (diff) |
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 <[email protected]>
Reviewed-by: Sinclair Yeh <[email protected]>
Diffstat (limited to 'src/loader/loader_dri3_helper.c')
-rw-r--r-- | src/loader/loader_dri3_helper.c | 16 |
1 files changed, 9 insertions, 7 deletions
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++) { |