Skip to content

Commit

Permalink
Qt: Work around Mesa issue 8035
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Jan 11, 2023
1 parent c8d7a7d commit a413dda
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/platform/qt/DisplayGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,20 @@ void PainterGL::filter(bool filter) {
}
}

#ifndef GL_DEBUG_OUTPUT_SYNCHRONOUS
#define GL_DEBUG_OUTPUT_SYNCHRONOUS 0x8242
#endif

void PainterGL::start() {
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 (m_supportsShaders && m_shader.passes) {
Expand Down
5 changes: 5 additions & 0 deletions src/platform/qt/OpenGLBug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ bool glContextHasBug(OpenGLBug bug) {
QOpenGLFunctions* fn = context->functions();
QString vendor(reinterpret_cast<const char*>(fn->glGetString(GL_VENDOR)));
QString renderer(reinterpret_cast<const char*>(fn->glGetString(GL_RENDERER)));
QString version(reinterpret_cast<const char*>(fn->glGetString(GL_VERSION)));

switch (bug) {
case OpenGLBug::CROSS_THREAD_FLUSH:
Expand All @@ -26,6 +27,10 @@ bool glContextHasBug(OpenGLBug bug) {
#else
return vendor == "Intel";
#endif

case OpenGLBug::GLTHREAD_BLOCKS_SWAP:
return version.contains(" Mesa ");

default:
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/qt/OpenGLBug.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
namespace QGBA {

enum class OpenGLBug {
// mgba.io/i/2761
CROSS_THREAD_FLUSH
CROSS_THREAD_FLUSH, // mgba.io/i/2761
GLTHREAD_BLOCKS_SWAP, // mgba.io/i/2767
};

bool glContextHasBug(OpenGLBug);
Expand Down

0 comments on commit a413dda

Please sign in to comment.