Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes #2794)

This commit is contained in:
Vicki Pfau 2023-01-26 05:57:08 -08:00
parent c4157e59fc
commit 8e671b0830
2 changed files with 7 additions and 5 deletions

View File

@ -5,6 +5,8 @@ Features:
Emulation fixes: Emulation fixes:
- GBA Memory: Make VRAM access stalls only apply to BG RAM - GBA Memory: Make VRAM access stalls only apply to BG RAM
- GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722) - GBA Video: Disable BG target 1 blending when OBJ blending (fixes mgba.io/i/2722)
Other fixes:
- Qt: Fix crash when attempting to use OpenGL 2.1 to 3.1 (fixes mgba.io/i/2794)
Misc: Misc:
- GB Serialize: Add missing savestate support for MBC6 and NT (newer) - GB Serialize: Add missing savestate support for MBC6 and NT (newer)
- GBA: Improve detection of valid ELF ROMs - GBA: Improve detection of valid ELF ROMs

View File

@ -513,10 +513,10 @@ void PainterGL::create() {
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
if (m_supportsShaders) { if (m_supportsShaders) {
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>();
gl2Backend = static_cast<mGLES2Context*>(malloc(sizeof(mGLES2Context))); gl2Backend = static_cast<mGLES2Context*>(malloc(sizeof(mGLES2Context)));
mGLES2ContextCreate(gl2Backend); mGLES2ContextCreate(gl2Backend);
m_backend = &gl2Backend->d; m_backend = &gl2Backend->d;
QOpenGLFunctions* fn = m_gl->functions();
fn->glGenTextures(m_bridgeTexes.size(), m_bridgeTexes.data()); fn->glGenTextures(m_bridgeTexes.size(), m_bridgeTexes.data());
for (auto tex : m_bridgeTexes) { for (auto tex : m_bridgeTexes) {
m_freeTex.enqueue(tex); m_freeTex.enqueue(tex);
@ -543,7 +543,7 @@ void PainterGL::create() {
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
mGLES2Context* gl2Backend = reinterpret_cast<mGLES2Context*>(painter->m_backend); mGLES2Context* gl2Backend = reinterpret_cast<mGLES2Context*>(painter->m_backend);
if (painter->m_widget && painter->supportsShaders()) { if (painter->m_widget && painter->supportsShaders()) {
QOpenGLFunctions_Baseline* fn = painter->m_gl->versionFunctions<QOpenGLFunctions_Baseline>(); QOpenGLFunctions* fn = painter->m_gl->functions();
fn->glFinish(); fn->glFinish();
painter->m_widget->setTex(painter->m_finalTex[painter->m_finalTexIdx]); painter->m_widget->setTex(painter->m_finalTex[painter->m_finalTexIdx]);
painter->m_finalTexIdx ^= 1; painter->m_finalTexIdx ^= 1;
@ -589,7 +589,7 @@ void PainterGL::destroy() {
} }
makeCurrent(); makeCurrent();
#if defined(BUILD_GLES2) || defined(BUILD_GLES3) #if defined(BUILD_GLES2) || defined(BUILD_GLES3)
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>(); QOpenGLFunctions* fn = m_gl->functions();
if (m_shader.passes) { if (m_shader.passes) {
mGLES2ShaderFree(&m_shader); mGLES2ShaderFree(&m_shader);
} }
@ -680,7 +680,7 @@ void PainterGL::start() {
if (glContextHasBug(OpenGLBug::GLTHREAD_BLOCKS_SWAP)) { if (glContextHasBug(OpenGLBug::GLTHREAD_BLOCKS_SWAP)) {
// Suggested on Discord as a way to strongly hint that glthread should be disabled // Suggested on Discord as a way to strongly hint that glthread should be disabled
// See https://gitlab.freedesktop.org/mesa/mesa/-/issues/8035 // See https://gitlab.freedesktop.org/mesa/mesa/-/issues/8035
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>(); QOpenGLFunctions* fn = m_gl->functions();
fn->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); fn->glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
} }
#endif #endif
@ -972,7 +972,7 @@ QOpenGLContext* PainterGL::shareContext() {
} }
void PainterGL::updateFramebufferHandle() { void PainterGL::updateFramebufferHandle() {
QOpenGLFunctions_Baseline* fn = m_gl->versionFunctions<QOpenGLFunctions_Baseline>(); QOpenGLFunctions* fn = m_gl->functions();
// TODO: Figure out why glFlush doesn't work here on Intel/Windows // TODO: Figure out why glFlush doesn't work here on Intel/Windows
if (glContextHasBug(OpenGLBug::CROSS_THREAD_FLUSH)) { if (glContextHasBug(OpenGLBug::CROSS_THREAD_FLUSH)) {
fn->glFinish(); fn->glFinish();