Warning, /graphics/krita/3rdparty/ext_qt/0133-HACK-Force-glFinish-in-flushShared-for-ANGLE.patch is written in an unsupported language. File is not indexed.
0001 From 90eed4735d704a5236741ef48e8d17d11906d40c Mon Sep 17 00:00:00 2001 0002 From: Alvin Wong <alvinhochun@gmail.com> 0003 Date: Tue, 5 Apr 2022 18:49:33 +0800 0004 Subject: [PATCH] HACK: Force glFinish in flushShared for ANGLE 0005 0006 --- 0007 src/gui/opengl/qopenglfunctions.cpp | 31 +++++++++++++++++++++++++++++ 0008 1 file changed, 31 insertions(+) 0009 0010 diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp 0011 index 92770cb55f..848e706d65 100644 0012 --- a/src/gui/opengl/qopenglfunctions.cpp 0013 +++ b/src/gui/opengl/qopenglfunctions.cpp 0014 @@ -5072,6 +5072,37 @@ void QOpenGLExtensions::flushShared() 0015 { 0016 Q_D(QOpenGLExtensions); 0017 0018 + if (!d->flushVendorChecked) { 0019 + static bool forceNoGlFinish = qEnvironmentVariableIntValue("KRITA_QT_NO_GL_FINISH_IN_FLUSH_SHARED") == 1; 0020 + if (forceNoGlFinish) { 0021 + d->flushVendorChecked = true; 0022 + d->flushIsSufficientToSyncContexts = true; 0023 + } else { 0024 +#ifdef Q_OS_WIN 0025 + // HACK: Workaround QWidget composing too often and causing performance 0026 + // drop when using ANGLE by forcing a glFinish. This can be disabled 0027 + // by explicitly setting `KRITA_QT_NO_GL_FINISH_IN_FLUSH_SHARED=1`. 0028 + // 0029 + // FIXME: We ought to fix this issue with a more proper way... 0030 + // 0031 + // Note: GL_VENDOR on older ANGLE versions only contained "Google Inc.", 0032 + // but newer versions also included the native graphics vendor, e.g. 0033 + // "Google Inc. (Intel)". This changed the outcome of the check from 0034 + // above. In any case, we should explicitly check for ANGLE and its 0035 + // D3D backend. 0036 + const char *renderer = (const char *) glGetString(GL_RENDERER); 0037 + if (renderer && strstr(renderer, "ANGLE") && strstr(renderer, "Direct3D")) { 0038 + d->flushVendorChecked = true; 0039 + d->flushIsSufficientToSyncContexts = false; 0040 + static bool _callOnce = []() { 0041 + qDebug() << "QOpenGLExtensions::flushShared() forcing glFinish for ANGLE"; 0042 + return true; 0043 + }(); 0044 + Q_UNUSED(_callOnce) 0045 + } 0046 +#endif 0047 + } 0048 + } 0049 if (!d->flushVendorChecked) { 0050 d->flushVendorChecked = true; 0051 // It is not quite clear if glFlush() is sufficient to synchronize access to 0052 -- 0053 2.24.1.windows.2 0054