Revert "[platforms/x11/standalone] Remove SGI swap control and video sync"
This reverts commit 285adc1950
.
See: https://mail.kde.org/pipermail/kwin/2020-January/002999.html
This commit is contained in:
parent
bcf64af49b
commit
a15624dcc5
2 changed files with 37 additions and 5 deletions
|
@ -212,6 +212,7 @@ void GlxBackend::init()
|
||||||
m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
|
m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));
|
||||||
m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
|
m_haveMESASwapControl = hasExtension(QByteArrayLiteral("GLX_MESA_swap_control"));
|
||||||
m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
|
m_haveEXTSwapControl = hasExtension(QByteArrayLiteral("GLX_EXT_swap_control"));
|
||||||
|
m_haveSGISwapControl = hasExtension(QByteArrayLiteral("GLX_SGI_swap_control"));
|
||||||
// only enable Intel swap event if env variable is set, see BUG 342582
|
// only enable Intel swap event if env variable is set, see BUG 342582
|
||||||
m_haveINTELSwapEvent = hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event"))
|
m_haveINTELSwapEvent = hasExtension(QByteArrayLiteral("GLX_INTEL_swap_event"))
|
||||||
&& qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1");
|
&& qgetenv("KWIN_USE_INTEL_SWAP_EVENT") == QByteArrayLiteral("1");
|
||||||
|
@ -221,7 +222,7 @@ void GlxBackend::init()
|
||||||
glXSelectEvent(display(), glxWindow, GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK);
|
glXSelectEvent(display(), glxWindow, GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
haveSwapInterval = m_haveMESASwapControl || m_haveEXTSwapControl;
|
haveSwapInterval = m_haveMESASwapControl || m_haveEXTSwapControl || m_haveSGISwapControl;
|
||||||
|
|
||||||
setSupportsBufferAge(false);
|
setSupportsBufferAge(false);
|
||||||
|
|
||||||
|
@ -233,15 +234,23 @@ void GlxBackend::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
setSyncsToVBlank(false);
|
setSyncsToVBlank(false);
|
||||||
setBlocksForRetrace(true);
|
setBlocksForRetrace(false);
|
||||||
|
haveWaitSync = false;
|
||||||
const bool wantSync = options->glPreferBufferSwap() != Options::NoSwapEncourage;
|
const bool wantSync = options->glPreferBufferSwap() != Options::NoSwapEncourage;
|
||||||
if (wantSync && glXIsDirect(display(), ctx)) {
|
if (wantSync && glXIsDirect(display(), ctx)) {
|
||||||
if (haveSwapInterval) { // glXSwapInterval is preferred being more reliable
|
if (haveSwapInterval) { // glXSwapInterval is preferred being more reliable
|
||||||
setSwapInterval(1);
|
setSwapInterval(1);
|
||||||
setSyncsToVBlank(true);
|
setSyncsToVBlank(true);
|
||||||
} else {
|
} else if (hasExtension(QByteArrayLiteral("GLX_SGI_video_sync"))) {
|
||||||
qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! glSwapInterval is not supported";
|
unsigned int sync;
|
||||||
}
|
if (glXGetVideoSyncSGI(&sync) == 0 && glXWaitVideoSyncSGI(1, 0, &sync) == 0) {
|
||||||
|
setSyncsToVBlank(true);
|
||||||
|
setBlocksForRetrace(true);
|
||||||
|
haveWaitSync = true;
|
||||||
|
} else
|
||||||
|
qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! glXSwapInterval is not supported, glXWaitVideoSync is supported but broken";
|
||||||
|
} else
|
||||||
|
qCWarning(KWIN_X11STANDALONE) << "NO VSYNC! neither glSwapInterval nor glXWaitVideoSync are supported";
|
||||||
} else {
|
} else {
|
||||||
// disable v-sync (if possible)
|
// disable v-sync (if possible)
|
||||||
setSwapInterval(0);
|
setSwapInterval(0);
|
||||||
|
@ -678,6 +687,25 @@ void GlxBackend::setSwapInterval(int interval)
|
||||||
glXSwapIntervalEXT(display(), glxWindow, interval);
|
glXSwapIntervalEXT(display(), glxWindow, interval);
|
||||||
else if (m_haveMESASwapControl)
|
else if (m_haveMESASwapControl)
|
||||||
glXSwapIntervalMESA(interval);
|
glXSwapIntervalMESA(interval);
|
||||||
|
else if (m_haveSGISwapControl)
|
||||||
|
glXSwapIntervalSGI(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlxBackend::waitSync()
|
||||||
|
{
|
||||||
|
// NOTE that vsync has no effect with indirect rendering
|
||||||
|
if (haveWaitSync) {
|
||||||
|
uint sync;
|
||||||
|
#if 0
|
||||||
|
// TODO: why precisely is this important?
|
||||||
|
// the sync counter /can/ perform multiple steps during glXGetVideoSync & glXWaitVideoSync
|
||||||
|
// but this only leads to waiting for two frames??!?
|
||||||
|
glXGetVideoSync(&sync);
|
||||||
|
glXWaitVideoSync(2, (sync + 1) % 2, &sync);
|
||||||
|
#else
|
||||||
|
glXWaitVideoSyncSGI(1, 0, &sync);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlxBackend::present()
|
void GlxBackend::present()
|
||||||
|
@ -696,6 +724,7 @@ void GlxBackend::present()
|
||||||
if (haveSwapInterval) {
|
if (haveSwapInterval) {
|
||||||
glXSwapBuffers(display(), glxWindow);
|
glXSwapBuffers(display(), glxWindow);
|
||||||
} else {
|
} else {
|
||||||
|
waitSync();
|
||||||
glXSwapBuffers(display(), glxWindow);
|
glXSwapBuffers(display(), glxWindow);
|
||||||
}
|
}
|
||||||
if (supportsBufferAge()) {
|
if (supportsBufferAge()) {
|
||||||
|
|
|
@ -86,6 +86,7 @@ private:
|
||||||
bool initBuffer();
|
bool initBuffer();
|
||||||
bool checkVersion();
|
bool checkVersion();
|
||||||
void initExtensions();
|
void initExtensions();
|
||||||
|
void waitSync();
|
||||||
bool initRenderingContext();
|
bool initRenderingContext();
|
||||||
bool initFbConfig();
|
bool initFbConfig();
|
||||||
void initVisualDepthHashTable();
|
void initVisualDepthHashTable();
|
||||||
|
@ -112,8 +113,10 @@ private:
|
||||||
bool m_haveMESACopySubBuffer = false;
|
bool m_haveMESACopySubBuffer = false;
|
||||||
bool m_haveMESASwapControl = false;
|
bool m_haveMESASwapControl = false;
|
||||||
bool m_haveEXTSwapControl = false;
|
bool m_haveEXTSwapControl = false;
|
||||||
|
bool m_haveSGISwapControl = false;
|
||||||
bool m_haveINTELSwapEvent = false;
|
bool m_haveINTELSwapEvent = false;
|
||||||
bool haveSwapInterval = false;
|
bool haveSwapInterval = false;
|
||||||
|
bool haveWaitSync = false;
|
||||||
Display *m_x11Display;
|
Display *m_x11Display;
|
||||||
friend class GlxTexture;
|
friend class GlxTexture;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue