From: Christian König Date: Fri, 24 Feb 2012 15:47:52 +0000 (+0100) Subject: vl: hide X latency by using asynchronous requests X-Git-Tag: 062012170305~1279 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91ac681113b05f8fe4dff51c3b80f967ac05c867;p=profile%2Fivi%2Fmesa.git vl: hide X latency by using asynchronous requests Signed-off-by: Christian König --- diff --git a/src/gallium/winsys/g3dvl/dri/dri_winsys.c b/src/gallium/winsys/g3dvl/dri/dri_winsys.c index 3a64751..096f068 100644 --- a/src/gallium/winsys/g3dvl/dri/dri_winsys.c +++ b/src/gallium/winsys/g3dvl/dri/dri_winsys.c @@ -50,8 +50,15 @@ struct vl_dri_screen struct vl_screen base; xcb_connection_t *conn; xcb_drawable_t drawable; + + bool flushed; + xcb_dri2_swap_buffers_cookie_t swap_cookie; + xcb_dri2_wait_sbc_cookie_t wait_cookie; + xcb_dri2_get_buffers_cookie_t buffers_cookie; }; +static const unsigned int attachments[1] = { XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT }; + static void vl_dri2_flush_frontbuffer(struct pipe_screen *screen, struct pipe_resource *resource, @@ -59,14 +66,19 @@ vl_dri2_flush_frontbuffer(struct pipe_screen *screen, void *context_private) { struct vl_dri_screen *scrn = (struct vl_dri_screen*)context_private; - xcb_dri2_swap_buffers_cookie_t swap_cookie; assert(screen); assert(resource); assert(context_private); - swap_cookie = xcb_dri2_swap_buffers_unchecked(scrn->conn, scrn->drawable, 0, 0, 0, 0, 0, 0); - free(xcb_dri2_swap_buffers_reply(scrn->conn, swap_cookie, NULL)); + if (scrn->flushed) + free(xcb_dri2_swap_buffers_reply(scrn->conn, scrn->swap_cookie, NULL)); + else + scrn->flushed = true; + + scrn->swap_cookie = xcb_dri2_swap_buffers_unchecked(scrn->conn, scrn->drawable, 0, 0, 0, 0, 0, 0); + scrn->wait_cookie = xcb_dri2_wait_sbc_unchecked(scrn->conn, scrn->drawable, 0, 0); + scrn->buffers_cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, scrn->drawable, 1, 1, attachments); } static void @@ -83,30 +95,38 @@ vl_dri2_destroy_drawable(struct vl_dri_screen *scrn) struct pipe_resource* vl_screen_texture_from_drawable(struct vl_screen *vscreen, Drawable drawable) { - static const unsigned int attachments[1] = { XCB_DRI2_ATTACHMENT_BUFFER_BACK_LEFT }; struct vl_dri_screen *scrn = (struct vl_dri_screen*)vscreen; struct winsys_handle dri2_front_handle; struct pipe_resource template, *tex; - xcb_dri2_get_buffers_cookie_t cookie; xcb_dri2_get_buffers_reply_t *reply; xcb_dri2_dri2_buffer_t *buffers; assert(scrn); + if (scrn->flushed) { + free(xcb_dri2_swap_buffers_reply(scrn->conn, scrn->swap_cookie, NULL)); + free(xcb_dri2_wait_sbc_reply(scrn->conn, scrn->wait_cookie, NULL)); + } + if (scrn->drawable != drawable) { vl_dri2_destroy_drawable(scrn); xcb_dri2_create_drawable(scrn->conn, drawable); scrn->drawable = drawable; - } else { - xcb_dri2_wait_sbc_cookie_t wait_cookie; - wait_cookie = xcb_dri2_wait_sbc_unchecked(scrn->conn, scrn->drawable, 0, 0); - free(xcb_dri2_wait_sbc_reply(scrn->conn, wait_cookie, NULL)); + + if (scrn->flushed) { + free(xcb_dri2_get_buffers_reply(scrn->conn, scrn->buffers_cookie, NULL)); + scrn->flushed = false; + } } - cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, drawable, 1, 1, attachments); - reply = xcb_dri2_get_buffers_reply(scrn->conn, cookie, NULL); + if (!scrn->flushed) + scrn->buffers_cookie = xcb_dri2_get_buffers_unchecked(scrn->conn, drawable, 1, 1, attachments); + else + scrn->flushed = false; + + reply = xcb_dri2_get_buffers_reply(scrn->conn, scrn->buffers_cookie, NULL); if (!reply) return NULL; @@ -238,6 +258,12 @@ void vl_screen_destroy(struct vl_screen *vscreen) assert(vscreen); + if (scrn->flushed) { + free(xcb_dri2_swap_buffers_reply(scrn->conn, scrn->swap_cookie, NULL)); + free(xcb_dri2_wait_sbc_reply(scrn->conn, scrn->wait_cookie, NULL)); + free(xcb_dri2_get_buffers_reply(scrn->conn, scrn->buffers_cookie, NULL)); + } + vl_dri2_destroy_drawable(scrn); scrn->base.pscreen->destroy(scrn->base.pscreen); FREE(scrn);