Qt: Start OpenGL bug list with glFlush cross-thread on Windows (fixes #2761)

This commit is contained in:
Vicki Pfau 2022-12-21 22:13:23 -08:00
parent 455e34edcf
commit 86bcbf1716
4 changed files with 60 additions and 1 deletions

View File

@ -123,6 +123,7 @@ set(SOURCE_FILES
MessagePainter.cpp
MultiplayerController.cpp
ObjView.cpp
OpenGLBug.cpp
OverrideView.cpp
PaletteView.cpp
PlacementControl.cpp

View File

@ -44,6 +44,8 @@ using QOpenGLFunctions_Baseline = QOpenGLFunctions_3_2_Core;
#define OVERHEAD_NSEC 300000
#endif
#include "OpenGLBug.h"
using namespace QGBA;
QHash<QSurfaceFormat, bool> DisplayGL::s_supports;
@ -959,7 +961,12 @@ QOpenGLContext* PainterGL::shareContext() {
void PainterGL::updateFramebufferHandle() {
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>();
fn->glFlush();
// TODO: Figure out why glFlush doesn't work here on Intel/Windows
if (glContextHasBug(OpenGLBug::CROSS_THREAD_FLUSH)) {
fn->glFinish();
} else {
fn->glFlush();
}
CoreController::Interrupter interrupter(m_context);
if (!m_context->hardwareAccelerated()) {

View File

@ -0,0 +1,34 @@
/* Copyright (c) 2013-2022 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "OpenGLBug.h"
#include <QOpenGLContext>
#include <QOpenGLFunctions>
namespace QGBA {
bool glContextHasBug(OpenGLBug bug) {
QOpenGLContext* context = QOpenGLContext::currentContext();
if (!context) {
abort();
}
QOpenGLFunctions* fn = context->functions();
QString vendor(reinterpret_cast<const char*>(fn->glGetString(GL_VENDOR)));
QString renderer(reinterpret_cast<const char*>(fn->glGetString(GL_RENDERER)));
switch (bug) {
case OpenGLBug::CROSS_THREAD_FLUSH:
#ifndef Q_OS_WIN
return false;
#else
return vendor == "Intel";
#endif
default:
return false;
}
}
}

View File

@ -0,0 +1,17 @@
/* Copyright (c) 2013-2022 Jeffrey Pfau
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#pragma once
namespace QGBA {
enum class OpenGLBug {
// mgba.io/i/2761
CROSS_THREAD_FLUSH
};
bool glContextHasBug(OpenGLBug);
}