}
}
+void
+dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval)
+{
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
+ GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+
+ /* Allow driconf to override applications.*/
+ if (dri2_dpy->config)
+ dri2_dpy->config->configQueryi(dri2_dpy->dri_screen,
+ "vblank_mode", &vblank_mode);
+ switch (vblank_mode) {
+ case DRI_CONF_VBLANK_NEVER:
+ dri2_dpy->min_swap_interval = 0;
+ dri2_dpy->max_swap_interval = 0;
+ dri2_dpy->default_swap_interval = 0;
+ break;
+ case DRI_CONF_VBLANK_ALWAYS_SYNC:
+ dri2_dpy->min_swap_interval = 1;
+ dri2_dpy->max_swap_interval = max_swap_interval;
+ dri2_dpy->default_swap_interval = 1;
+ break;
+ case DRI_CONF_VBLANK_DEF_INTERVAL_0:
+ dri2_dpy->min_swap_interval = 0;
+ dri2_dpy->max_swap_interval = max_swap_interval;
+ dri2_dpy->default_swap_interval = 0;
+ break;
+ default:
+ case DRI_CONF_VBLANK_DEF_INTERVAL_1:
+ dri2_dpy->min_swap_interval = 0;
+ dri2_dpy->max_swap_interval = max_swap_interval;
+ dri2_dpy->default_swap_interval = 1;
+ break;
+ }
+}
+
/* All platforms but DRM call this function to create the screen and populate
* the driver_configs. DRM inherits that information from its display - GBM.
*/
void
dri2_setup_screen(_EGLDisplay *disp);
+void
+dri2_setup_swap_interval(_EGLDisplay *disp, int max_swap_interval);
+
EGLBoolean
dri2_load_driver_swrast(_EGLDisplay *disp);
static EGLBoolean
dri2_wl_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
{
- return dri2_wl_swap_buffers_with_damage (drv, disp, draw, NULL, 0);
+ return dri2_wl_swap_buffers_with_damage(drv, disp, draw, NULL, 0);
}
static struct wl_buffer *
};
static void
-dri2_wl_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
+dri2_wl_setup_swap_interval(_EGLDisplay *disp)
{
- GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
-
/* We can't use values greater than 1 on Wayland because we are using the
* frame callback to synchronise the frame and the only way we be sure to
* get a frame callback is to attach a new buffer. Therefore we can't just
* sit drawing nothing to wait until the next ānā frame callbacks */
- if (dri2_dpy->config)
- dri2_dpy->config->configQueryi(dri2_dpy->dri_screen,
- "vblank_mode", &vblank_mode);
- switch (vblank_mode) {
- case DRI_CONF_VBLANK_NEVER:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = 0;
- dri2_dpy->default_swap_interval = 0;
- break;
- case DRI_CONF_VBLANK_ALWAYS_SYNC:
- dri2_dpy->min_swap_interval = 1;
- dri2_dpy->max_swap_interval = 1;
- dri2_dpy->default_swap_interval = 1;
- break;
- case DRI_CONF_VBLANK_DEF_INTERVAL_0:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = 1;
- dri2_dpy->default_swap_interval = 0;
- break;
- default:
- case DRI_CONF_VBLANK_DEF_INTERVAL_1:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = 1;
- dri2_dpy->default_swap_interval = 1;
- break;
- }
+ dri2_setup_swap_interval(disp, 1);
}
static const struct dri2_egl_display_vtbl dri2_wl_display_vtbl = {
dri2_setup_screen(disp);
- dri2_wl_setup_swap_interval(dri2_dpy);
+ dri2_wl_setup_swap_interval(disp);
/* To use Prime, we must have _DRI_IMAGE v7 at least.
* createImageFromFds support indicates that Prime export/import
dri2_setup_screen(disp);
- dri2_wl_setup_swap_interval(dri2_dpy);
+ dri2_wl_setup_swap_interval(disp);
if (!dri2_wl_add_configs_for_visuals(drv, disp)) {
_eglError(EGL_NOT_INITIALIZED, "DRI2: failed to add configs");
}
static void
-dri2_x11_setup_swap_interval(struct dri2_egl_display *dri2_dpy)
+dri2_x11_setup_swap_interval(_EGLDisplay *disp)
{
- GLint vblank_mode = DRI_CONF_VBLANK_DEF_INTERVAL_1;
+ struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
int arbitrary_max_interval = 1000;
/* default behavior for no SwapBuffers support: no vblank syncing
return;
/* If we do have swapbuffers, then we can support pretty much any swap
- * interval, but we allow driconf to override applications.
+ * interval.
*/
- if (dri2_dpy->config)
- dri2_dpy->config->configQueryi(dri2_dpy->dri_screen,
- "vblank_mode", &vblank_mode);
- switch (vblank_mode) {
- case DRI_CONF_VBLANK_NEVER:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = 0;
- dri2_dpy->default_swap_interval = 0;
- break;
- case DRI_CONF_VBLANK_ALWAYS_SYNC:
- dri2_dpy->min_swap_interval = 1;
- dri2_dpy->max_swap_interval = arbitrary_max_interval;
- dri2_dpy->default_swap_interval = 1;
- break;
- case DRI_CONF_VBLANK_DEF_INTERVAL_0:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = arbitrary_max_interval;
- dri2_dpy->default_swap_interval = 0;
- break;
- default:
- case DRI_CONF_VBLANK_DEF_INTERVAL_1:
- dri2_dpy->min_swap_interval = 0;
- dri2_dpy->max_swap_interval = arbitrary_max_interval;
- dri2_dpy->default_swap_interval = 1;
- break;
- }
+ dri2_setup_swap_interval(disp, arbitrary_max_interval);
}
#ifdef HAVE_DRI3
dri2_setup_screen(disp);
- dri2_x11_setup_swap_interval(dri2_dpy);
+ dri2_x11_setup_swap_interval(disp);
if (!dri2_dpy->is_different_gpu)
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
dri2_setup_screen(disp);
- dri2_x11_setup_swap_interval(dri2_dpy);
+ dri2_x11_setup_swap_interval(disp);
disp->Extensions.KHR_image_pixmap = EGL_TRUE;
disp->Extensions.NOK_swap_region = EGL_TRUE;