aboutsummaryrefslogtreecommitdiffstats
path: root/src/loader
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2017-09-14 12:39:18 +0200
committerThomas Hellstrom <[email protected]>2017-10-05 09:17:12 +0200
commit1b8e0bed6989386ce096fc0dce92cd0f3df8ea88 (patch)
tree3484ec3e709c7a60f3becf2927ff9920d77e6e10 /src/loader
parent622f5e1d9be1915d0982ece4aab99b77e30b1fd5 (diff)
loader/dri3: Avoid resizing existing buffers in dri3_find_back_alloc
Resize only in loader_dri3_get_buffers(), where the dri driver has a chance to immediately update the viewport. Signed-off-by: Thomas Hellstrom <[email protected]> Reviewed-by: Sinclair Yeh <[email protected]>
Diffstat (limited to 'src/loader')
-rw-r--r--src/loader/loader_dri3_helper.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c
index aea0f68ac63..dcc713d6d42 100644
--- a/src/loader/loader_dri3_helper.c
+++ b/src/loader/loader_dri3_helper.c
@@ -1639,6 +1639,7 @@ loader_dri3_close_screen(__DRIscreen *dri_screen)
* Find a potentially new back buffer, and if it's not been allocated yet and
* in addition needs initializing, then try to allocate and initialize it.
*/
+#include <stdio.h>
static struct loader_dri3_buffer *
dri3_find_back_alloc(struct loader_dri3_drawable *draw)
{
@@ -1646,16 +1647,36 @@ dri3_find_back_alloc(struct loader_dri3_drawable *draw)
int id;
id = dri3_find_back(draw);
- back = (id >= 0) ? draw->buffers[id] : NULL;
-
- if (back || (id >= 0 && draw->back_format != __DRI_IMAGE_FORMAT_NONE)) {
- if (dri3_update_drawable(draw->dri_drawable, draw)) {
- (void) dri3_get_buffer(draw->dri_drawable,
- draw->back_format,
- loader_dri3_buffer_back,
- draw);
- back = (id >= 0) ? draw->buffers[id] : NULL;
- }
+ if (id < 0)
+ return NULL;
+
+ back = draw->buffers[id];
+ /* Allocate a new back if we haven't got one */
+ if (!back && draw->back_format != __DRI_IMAGE_FORMAT_NONE &&
+ dri3_update_drawable(draw->dri_drawable, draw))
+ back = dri3_alloc_render_buffer(draw, draw->back_format,
+ draw->width, draw->height, draw->depth);
+
+ if (!back)
+ return NULL;
+
+ draw->buffers[id] = back;
+
+ /* If necessary, prefill the back with data according to swap_method mode. */
+ if (draw->cur_blit_source != -1 &&
+ draw->buffers[draw->cur_blit_source] &&
+ back != draw->buffers[draw->cur_blit_source]) {
+ struct loader_dri3_buffer *source = draw->buffers[draw->cur_blit_source];
+
+ dri3_fence_await(draw->conn, draw, source);
+ dri3_fence_await(draw->conn, draw, back);
+ (void) loader_dri3_blit_image(draw,
+ back->image,
+ source->image,
+ 0, 0, draw->width, draw->height,
+ 0, 0, 0);
+ back->last_swap = source->last_swap;
+ draw->cur_blit_source = -1;
}
return back;