The optimal modifier depends on the current CRTC as some modifiers might not allow direct scanout. When the window is moved to a different CRTC, available modifiers should be re-fetched and the buffers re-allocated.
Signed-off-by: Louis-Francis Ratté-Boulianne <[email protected]> --- src/loader/loader_dri3_helper.c | 35 +++++++++++++++++++---------------- src/loader/loader_dri3_helper.h | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/loader/loader_dri3_helper.c b/src/loader/loader_dri3_helper.c index f6bc1c52e8..6472f217d1 100644 --- a/src/loader/loader_dri3_helper.c +++ b/src/loader/loader_dri3_helper.c @@ -24,6 +24,7 @@ #include <fcntl.h> #include <stdlib.h> #include <unistd.h> +#include <string.h> #include <X11/xshmfence.h> #include <xcb/xcb.h> @@ -408,6 +409,14 @@ dri3_handle_present_event(struct loader_dri3_drawable *draw, } break; } + case XCB_PRESENT_EVENT_WINDOW_CRTC_NOTIFY: { + int b; + for (b = 0; b < sizeof(draw->buffers) / sizeof(draw->buffers[0]); b++) { + if (draw->buffers[b]) + draw->buffers[b]->crtc_changed = true; + } + break; + } } free(ge); } @@ -1047,7 +1056,6 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, uint64_t *modifiers[2] = {NULL, NULL}; uint32_t counts[2] = {0, 0}; uint32_t n = 0; - uint32_t *mod_parts; int i; mod_cookie = xcb_dri3_get_supported_modifiers(draw->conn, @@ -1067,11 +1075,9 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, goto no_image; } - mod_parts = xcb_dri3_get_supported_modifiers_drawable_modifiers(mod_reply); - for (i = 0; i < counts[n]; i++) { - modifiers[n][i] = (uint64_t) mod_parts[i * 2] << 32; - modifiers[n][i] |= (uint64_t) mod_parts[i * 2 + 1] & 0xffffff; - } + memcpy(modifiers[n], + xcb_dri3_get_supported_modifiers_drawable_modifiers(mod_reply), + counts[n] * sizeof(uint64_t)); n++; } @@ -1084,11 +1090,9 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, goto no_image; } - mod_parts = xcb_dri3_get_supported_modifiers_screen_modifiers(mod_reply); - for (i = 0; i < counts[n]; i++) { - modifiers[n][i] = (uint64_t) mod_parts[i * 2] << 32; - modifiers[n][i] |= (uint64_t) mod_parts[i * 2 + 1] & 0xffffff; - } + memcpy(modifiers[n], + xcb_dri3_get_supported_modifiers_screen_modifiers(mod_reply), + counts[n] * sizeof(uint64_t)); n++; } @@ -1192,8 +1196,7 @@ dri3_alloc_render_buffer(struct loader_dri3_drawable *draw, unsigned int format, buffer->strides[2], buffer->offsets[2], buffer->strides[3], buffer->offsets[3], depth, buffer->cpp * 8, - buffer->modifier >> 32, - buffer->modifier & 0xffffffff, + buffer->modifier, buffer_fds); } else @@ -1278,7 +1281,8 @@ dri3_update_drawable(__DRIdrawable *driDrawable, xcb_present_select_input_checked(draw->conn, draw->eid, draw->drawable, XCB_PRESENT_EVENT_MASK_CONFIGURE_NOTIFY | XCB_PRESENT_EVENT_MASK_COMPLETE_NOTIFY | - XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY); + XCB_PRESENT_EVENT_MASK_IDLE_NOTIFY | + XCB_PRESENT_EVENT_MASK_WINDOW_CRTC_NOTIFY); present_capabilities_cookie = xcb_present_query_capabilities(draw->conn, draw->drawable); @@ -1391,7 +1395,6 @@ loader_dri3_create_image_from_buffers(xcb_connection_t *c, int *fds; uint32_t *strides_in, *offsets_in; int strides[4], offsets[4]; - uint64_t modifier; unsigned error; int i; @@ -1549,7 +1552,7 @@ dri3_get_buffer(__DRIdrawable *driDrawable, * old one is the wrong size */ if (!buffer || buffer->width != draw->width || - buffer->height != draw->height) { + buffer->height != draw->height || buffer->crtc_changed) { struct loader_dri3_buffer *new_buffer; /* Allocate the new buffers diff --git a/src/loader/loader_dri3_helper.h b/src/loader/loader_dri3_helper.h index 03c874fe0d..7de42e0660 100644 --- a/src/loader/loader_dri3_helper.h +++ b/src/loader/loader_dri3_helper.h @@ -70,6 +70,7 @@ struct loader_dri3_buffer { uint32_t flags; uint32_t width, height; uint64_t last_swap; + bool crtc_changed; }; -- 2.13.0 _______________________________________________ [email protected]: X.Org development Archives: http://lists.x.org/archives/xorg-devel Info: https://lists.x.org/mailman/listinfo/xorg-devel
