Purpose:
Turn off vsync.
Envs:
Qt 5.4.1 + eglfs(QPA) + linux kernel 3.10.53
First Try:
When running a Qt related app, I can get the tip like this:
QEglFSImx6Hooks will set environment variable FB_MULTI_BUFFER=2 to enable double buffering and vsync.
If this is not desired, you can override this via: export QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1
Forwording, I check Qt 5.4.1 src code in qeglfshooks_imx6.cpp, and find the related context to trun off vsync by setting env variable
QT_EGLFS_IMX6_NO_FB_MULTI_BUFFER=1.
Result:
Negative, failed to turn off vsync.
Second Try:
According to Qt 5.4.1 src code in Qeglplatformcontext.cpp, we can trun off vsync by set env variable QT_QPA_EGLFS_SWAPINTERVAL=0.
const bool ok = eglMakeCurrent(m_eglDisplay, eglSurface, eglSurface, m_eglContext);
if (ok) {
if (!m_swapIntervalEnvChecked) {
m_swapIntervalEnvChecked = true;
if (qEnvironmentVariableIsSet("QT_QPA_EGLFS_SWAPINTERVAL")) {
QByteArray swapIntervalString = qgetenv("QT_QPA_EGLFS_SWAPINTERVAL");
bool intervalOk;
const int swapInterval = swapIntervalString.toInt(&intervalOk);
if (intervalOk)
m_swapIntervalFromEnv = swapInterval;
}
}
const int requestedSwapInterval = m_swapIntervalFromEnv >= 0
? m_swapIntervalFromEnv
: surface->format().swapInterval();
if (requestedSwapInterval >= 0 && m_swapInterval != requestedSwapInterval) {
m_swapInterval = requestedSwapInterval;
eglSwapInterval(eglDisplay(), m_swapInterval);
}
} else {
qWarning("QEGLPlatformContext::makeCurrent: eglError: %x, this: %p \n", eglGetError(), this);
}
Result:
Negative, faild to turn off vsync.
Note:
1. whether turn off vsync or not will determine block or not the op, swapping buffers. And we can check the result by calculating the consuming time on swapping buffers.
2. In windows 7 / Ubuntu 14.04(x11), we can turn off vsync by QSurfaceFormat::setSwapInterval(0), in addition, Qt guider says this api may differ from platforms. In this case, we try to get a clue by studying Qt 5.4.1 src code, and we just have the mentioned attempts.
I just want to turn off vsync in order to prevent fps being limited to 60Hz ( default display refresh rate).
In contrast, Re: i.MX6: VIV's EGL lib on framebuffer has no SYNC with V-sync