Qt: Work around Mesa issue 8035

This commit is contained in:
Vicki Pfau 2023-01-09 00:09:25 -08:00
parent 70e6470e8b
commit 9df06383b5
3 changed files with 19 additions and 2 deletions

View File

@ -670,8 +670,20 @@ void PainterGL::filter(bool filter) {
} }
} }
#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#endif
void PainterGL::start() { void PainterGL::start() {
makeCurrent(); makeCurrent();
#if defined(BUILD_GLES3) && !defined(Q_OS_MAC)
if (glContextHasBug(OpenGLBug::GLTHREAD_BLOCKS_SWAP)) {
// Suggested on Discord as a way to strongly hint that glthread should be disabled
// See https://gitlab.freedesktop.org/mesa/mesa/-/issues/8035
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>();
fn->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
}
#endif
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (m_supportsShaders && m_shader.passes) { if (m_supportsShaders && m_shader.passes) {

View File

@ -18,6 +18,7 @@ bool glContextHasBug(OpenGLBug bug) {
QOpenGLFunctions* fn = context->functions(); QOpenGLFunctions* fn = context->functions();
QString vendor(reinterpret_cast<const char*>(fn->glGetString(GL_VENDOR))); QString vendor(reinterpret_cast<const char*>(fn->glGetString(GL_VENDOR)));
QString renderer(reinterpret_cast<const char*>(fn->glGetString(GL_RENDERER))); QString renderer(reinterpret_cast<const char*>(fn->glGetString(GL_RENDERER)));
QString version(reinterpret_cast<const char*>(fn->glGetString(GL_VERSION)));
switch (bug) { switch (bug) {
case OpenGLBug::CROSS_THREAD_FLUSH: case OpenGLBug::CROSS_THREAD_FLUSH:
@ -26,6 +27,10 @@ bool glContextHasBug(OpenGLBug bug) {
#else #else
return vendor == "Intel"; return vendor == "Intel";
#endif #endif
case OpenGLBug::GLTHREAD_BLOCKS_SWAP:
return version.contains(" Mesa ");
default: default:
return false; return false;
} }

View File

@ -8,8 +8,8 @@
namespace QGBA { namespace QGBA {
enum class OpenGLBug { enum class OpenGLBug {
// mgba.io/i/2761 CROSS_THREAD_FLUSH, // mgba.io/i/2761
CROSS_THREAD_FLUSH GLTHREAD_BLOCKS_SWAP, // mgba.io/i/2767
}; };
bool glContextHasBug(OpenGLBug); bool glContextHasBug(OpenGLBug);