summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorChristian König <[email protected]>2012-02-24 16:47:52 +0100
committerChristian König <[email protected]>2012-03-01 15:06:51 +0100
commit91ac681113b05f8fe4dff51c3b80f967ac05c867 (patch)
tree47b9d26b49457c8459d51a20a9d11d9223bad6ba /src/gallium/winsys
parent66480c0f565eb5dc7ae4a5dc792341f6886f481a (diff)
vl: hide X latency by using asynchronous requests
Signed-off-by: Christian König <[email protected]>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/g3dvl/dri/dri_winsys.c48
1 files changed, 37 insertions, 11 deletions
diff --git a/src/gallium/winsys/g3dvl/dri/dri_winsys.c b/src/gallium/winsys/g3dvl/dri/dri_winsys.c
index 3a647510c7d..096f068dbb4 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);