EGL backend: Check if implementation supports swap interval of 1 before setting it

REVIEW: 110023
This commit is contained in:
Ralf Jung 2013-04-12 14:05:19 +02:00
parent c9f852a73f
commit 84c904d6f9

View file

@ -88,12 +88,21 @@ void EglOnXBackend::init()
if (surfaceHasSubPost) {
kDebug(1212) << "EGL implementation and surface support eglPostSubBufferNV, let's use it";
// set swap interval appropriately
const bool wantSync = options->glPreferBufferSwap() != Options::NoSwapEncourage;
const EGLBoolean res = eglSwapInterval(dpy, wantSync ? 1 : 0);
if (res && wantSync) {
kDebug(1212) << "Enabled v-sync";
setHasWaitSync(true);
if (options->glPreferBufferSwap() != Options::NoSwapEncourage) {
// check if swap interval 1 is supported
EGLint val;
eglGetConfigAttrib(dpy, config, EGL_MAX_SWAP_INTERVAL, &val);
if (val >= 1) {
if (eglSwapInterval(dpy, 1)) {
kDebug(1212) << "Enabled v-sync";
setHasWaitSync(true);
}
} else {
kWarning(1212) << "Cannot enable v-sync as max. swap interval is" << val;
}
} else {
// disable v-sync
eglSwapInterval(dpy, 0);
}
} else {
/* In the GLX backend, we fall back to using glCopyPixels if we have no extension providing support for partial screen updates.