[Mesa-dev] [PATCH 2/3] st/egl: Implement eglSwapInterval in the X11 backend
Fredrik Höglund
fredrik at kde.org
Thu Mar 8 13:22:35 PST 2012
---
src/gallium/state_trackers/egl/x11/native_dri2.c | 20 +++++++++++++++++---
src/gallium/state_trackers/egl/x11/x11_screen.c | 8 ++++++++
src/gallium/state_trackers/egl/x11/x11_screen.h | 4 ++++
3 files changed, 29 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 5d7d379..740bd55 100644
--- a/src/gallium/state_trackers/egl/x11/native_dri2.c
+++ b/src/gallium/state_trackers/egl/x11/native_dri2.c
@@ -359,9 +359,6 @@ dri2_surface_present(struct native_surface *nsurf,
{
boolean ret;
- if (ctrl->swap_interval)
- return FALSE;
-
switch (ctrl->natt) {
case NATIVE_ATTACHMENT_FRONT_LEFT:
ret = dri2_surface_flush_frontbuffer(nsurf);
@@ -378,6 +375,18 @@ dri2_surface_present(struct native_surface *nsurf,
}
static boolean
+dri2_surface_swap_interval(struct native_surface *nsurf, int interval)
+{
+ struct dri2_surface *dri2surf = dri2_surface(nsurf);
+ struct dri2_display *dri2dpy = dri2surf->dri2dpy;
+
+ if (dri2dpy->dri_minor >= 2)
+ x11_drawable_swap_interval(dri2dpy->xscr, dri2surf->drawable, interval);
+
+ return TRUE;
+}
+
+static boolean
dri2_surface_validate(struct native_surface *nsurf, uint attachment_mask,
unsigned int *seq_num, struct pipe_resource **textures,
int *width, int *height)
@@ -470,6 +479,7 @@ dri2_display_create_surface(struct native_display *ndpy,
dri2surf->base.present = dri2_surface_present;
dri2surf->base.validate = dri2_surface_validate;
dri2surf->base.wait = dri2_surface_wait;
+ dri2surf->base.swap_interval = dri2_surface_swap_interval;
if (drawable) {
x11_drawable_enable_dri2(dri2dpy->xscr, drawable, TRUE);
@@ -724,6 +734,7 @@ static int
dri2_display_get_param(struct native_display *ndpy,
enum native_param_type param)
{
+ struct dri2_display *dri2dpy = dri2_display(ndpy);
int val;
switch (param) {
@@ -739,6 +750,9 @@ dri2_display_get_param(struct native_display *ndpy,
val = TRUE;
break;
case NATIVE_PARAM_MAX_SWAP_INTERVAL:
+ /* XXX Arbitrary value */
+ val = dri2dpy->dri_minor >= 2 ? 1000 : 0;
+ break;
default:
val = 0;
break;
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.c b/src/gallium/state_trackers/egl/x11/x11_screen.c
index 1e20f94..af5021d 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.c
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.c
@@ -381,6 +381,14 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
return (struct x11_drawable_buffer *) dri2bufs;
}
+void
+x11_drawable_swap_interval(struct x11_screen *xscr, Drawable drawable,
+ int interval)
+{
+ /* XXX Check vblank_mode? */
+ DRI2SwapInterval(xscr->dpy, drawable, interval);
+}
+
/**
* Create a mode list of the given size.
*/
diff --git a/src/gallium/state_trackers/egl/x11/x11_screen.h b/src/gallium/state_trackers/egl/x11/x11_screen.h
index ad7aa97..197e16a 100644
--- a/src/gallium/state_trackers/egl/x11/x11_screen.h
+++ b/src/gallium/state_trackers/egl/x11/x11_screen.h
@@ -129,6 +129,10 @@ x11_drawable_get_buffers(struct x11_screen *xscr, Drawable drawable,
int *width, int *height, unsigned int *attachments,
boolean with_format, int num_ins, int *num_outs);
+void
+x11_drawable_swap_interval(struct x11_screen *xscr, Drawable drawable,
+ int interval);
+
#endif /* GLX_DIRECT_RENDERING */
#endif /* _X11_SCREEN_H_ */
--
1.7.7.3
More information about the mesa-dev
mailing list