[Mesa-dev] [PATCH 3/3] st/egl: Use DRI2SwapBuffers in the X11 backend
Fredrik Höglund
fredrik at kde.org
Thu Mar 8 13:22:36 PST 2012
---
src/gallium/state_trackers/egl/x11/native_dri2.c | 27 +++++++++++++++++++--
src/gallium/state_trackers/egl/x11/x11_screen.c | 11 +++++++++
src/gallium/state_trackers/egl/x11/x11_screen.h | 5 ++++
3 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/src/gallium/state_trackers/egl/x11/native_dri2.c b/src/gallium/state_trackers/egl/x11/native_dri2.c
index 740bd55..34e281a 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -313,8 +313,21 @@ dri2_surface_flush_frontbuffer(struct native_surface *nsurf)
}
static boolean
-dri2_surface_swap_buffers(struct native_surface *nsurf, int num_rects,
- const int *rects)
+dri2_surface_swap_buffers_msc(struct native_surface *nsurf)
+{
+ struct dri2_surface *dri2surf = dri2_surface(nsurf);
+ struct dri2_display *dri2dpy = dri2surf->dri2dpy;
+ int64_t count;
+
+ x11_drawable_swap_buffers(dri2dpy->xscr, dri2surf->drawable,
+ 0, 0, 1, &count);
+
+ return count != -1;
+}
+
+static boolean
+dri2_surface_swap_buffers(struct native_surface *nsurf, boolean preserve,
+ int num_rects, const int *rects)
{
struct dri2_surface *dri2surf = dri2_surface(nsurf);
struct dri2_display *dri2dpy = dri2surf->dri2dpy;
@@ -357,6 +370,8 @@ static boolean
dri2_surface_present(struct native_surface *nsurf,
const struct native_present_control *ctrl)
{
+ struct dri2_surface *dri2surf = dri2_surface(nsurf);
+ struct dri2_display *dri2dpy = dri2surf->dri2dpy;
boolean ret;
switch (ctrl->natt) {
@@ -364,7 +379,13 @@ dri2_surface_present(struct native_surface *nsurf,
ret = dri2_surface_flush_frontbuffer(nsurf);
break;
case NATIVE_ATTACHMENT_BACK_LEFT:
- ret = dri2_surface_swap_buffers(nsurf, ctrl->num_rects, ctrl->rects);
+ if (!ctrl->preserve && ctrl->num_rects == 0 &&
+ dri2surf->have_back && !dri2surf->have_fake &&
+ dri2dpy->dri_minor >= 2)
+ ret = dri2_surface_swap_buffers_msc(nsurf);
+ else
+ ret = dri2_surface_swap_buffers(nsurf, ctrl->preserve,
+ ctrl->num_rects, ctrl->rects);
break;
default:
ret = FALSE;
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index af5021d..1ec2b0a 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -338,6 +338,17 @@ x11_drawable_enable_dri2(struct x11_screen *xscr,
}
/**
+ * Swap the buffers of the DRI2 drawable.
+ */
+void
+x11_drawable_swap_buffers(struct x11_screen *xscr, Drawable drawable, int64_t target_msc,
+ int64_t divisor, int64_t remainder, int64_t *swap_count)
+{
+ DRI2SwapBuffers(xscr->dpy, drawable, (CARD64)target_msc, (CARD64)divisor,
+ (CARD64)remainder, (CARD64*)swap_count);
+}
+
+/**
* Copy between buffers of the DRI2 drawable.
*/
void
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h
index 197e16a..bde359d 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.h
@@ -108,6 +108,11 @@ x11_drawable_enable_dri2(struct x11_screen *xscr,
Drawable drawable, boolean on);
void
+x11_drawable_swap_buffers(struct x11_screen *xscr, Drawable drawable,
+ int64_t target_msc, int64_t divisor,
+ int64_t remainder, int64_t *swap_count);
+
+void
x11_drawable_copy_buffers_region(struct x11_screen *xscr, Drawable drawable,
int num_rects, const int *rects,
int src_buf, int dst_buf);
--
1.7.7.3
More information about the mesa-dev
mailing list