From 945cfe234b649aec08efcebadae905de5dfcda90 Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 9 Nov 2020 22:12:41 -0500 Subject: [PATCH 1/2] bootmanager: Log and show GL_RENDERER string when GPU is insufficient Changes the first message to not include the OpenGL version, as the error is caused by OpenGL failing to load. Adds a new check for OpenGL version 4.3. This will display a message with a similar error as well as the GL_RENDERER string. Adds a CRITICAL log message when triggered. This prevents a crash with yuzu trying to use older OpenGL versions. Modifies the unsupported extension message to output the GL_RENDERER string in the message, as well as logging the string. --- src/yuzu/bootmanager.cpp | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 408eac2b7..4481c749b 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -603,19 +604,34 @@ bool GRenderWindow::LoadOpenGL() { auto context = CreateSharedContext(); auto scope = context->Acquire(); if (!gladLoadGL()) { + QMessageBox::critical( + this, tr("Error while initializing OpenGL!"), + tr("Your GPU may not support OpenGL, or you do not have the latest graphics driver.")); + return false; + } + + QString renderer = QString::fromUtf8(reinterpret_cast(glGetString(GL_RENDERER))); + + if (!GLAD_GL_VERSION_4_3) { + LOG_CRITICAL(Frontend, "GPU does not support OpenGL 4.3: {:s}", renderer.toStdString()); QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"), tr("Your GPU may not support OpenGL 4.3, or you do not have the " - "latest graphics driver.")); + "latest graphics driver.

GL Renderer:
%1") + .arg(renderer)); return false; } QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions(); if (!unsupported_gl_extensions.empty()) { + LOG_CRITICAL(Frontend, "GPU does not support all needed extensions: {:s}", + renderer.toStdString()); QMessageBox::critical( this, tr("Error while initializing OpenGL!"), tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you " - "have the latest graphics driver.

Unsupported extensions:
") + - unsupported_gl_extensions.join(QStringLiteral("
"))); + "have the latest graphics driver.

GL Renderer:
%1

Unsupported " + "extensions:
%2") + .arg(renderer) + .arg(unsupported_gl_extensions.join(QStringLiteral("
")))); return false; } return true; From c433c0a746ad3826b4cbcf9f62b587e08dec03ad Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Mon, 9 Nov 2020 22:55:05 -0500 Subject: [PATCH 2/2] bootmanager: Address review comments Changes QMessageBox usages to warnings, as the problems they bring to light are being safely handled by the application and do not warrant something of the "critical" level. Changes LOG_CRITICAL to LOG_ERROR for the same reason. Preferring ERROR to WARNING as yuzu is denying loading of any guest applications after checking for these conditions. Moved logging the GL_RENDERER string into GetUnsupportedGLExtensions() to make more clear that unsupported extensions were already being logged. Makes placement of the logs easier to understand later, as well. --- src/yuzu/bootmanager.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/yuzu/bootmanager.cpp b/src/yuzu/bootmanager.cpp index 4481c749b..e38bc7a9a 100644 --- a/src/yuzu/bootmanager.cpp +++ b/src/yuzu/bootmanager.cpp @@ -604,28 +604,27 @@ bool GRenderWindow::LoadOpenGL() { auto context = CreateSharedContext(); auto scope = context->Acquire(); if (!gladLoadGL()) { - QMessageBox::critical( + QMessageBox::warning( this, tr("Error while initializing OpenGL!"), tr("Your GPU may not support OpenGL, or you do not have the latest graphics driver.")); return false; } - QString renderer = QString::fromUtf8(reinterpret_cast(glGetString(GL_RENDERER))); + const QString renderer = + QString::fromUtf8(reinterpret_cast(glGetString(GL_RENDERER))); if (!GLAD_GL_VERSION_4_3) { - LOG_CRITICAL(Frontend, "GPU does not support OpenGL 4.3: {:s}", renderer.toStdString()); - QMessageBox::critical(this, tr("Error while initializing OpenGL 4.3!"), - tr("Your GPU may not support OpenGL 4.3, or you do not have the " - "latest graphics driver.

GL Renderer:
%1") - .arg(renderer)); + LOG_ERROR(Frontend, "GPU does not support OpenGL 4.3: {}", renderer.toStdString()); + QMessageBox::warning(this, tr("Error while initializing OpenGL 4.3!"), + tr("Your GPU may not support OpenGL 4.3, or you do not have the " + "latest graphics driver.

GL Renderer:
%1") + .arg(renderer)); return false; } QStringList unsupported_gl_extensions = GetUnsupportedGLExtensions(); if (!unsupported_gl_extensions.empty()) { - LOG_CRITICAL(Frontend, "GPU does not support all needed extensions: {:s}", - renderer.toStdString()); - QMessageBox::critical( + QMessageBox::warning( this, tr("Error while initializing OpenGL!"), tr("Your GPU may not support one or more required OpenGL extensions. Please ensure you " "have the latest graphics driver.

GL Renderer:
%1

Unsupported " @@ -661,8 +660,13 @@ QStringList GRenderWindow::GetUnsupportedGLExtensions() const { if (!GLAD_GL_ARB_depth_buffer_float) unsupported_ext.append(QStringLiteral("ARB_depth_buffer_float")); - for (const QString& ext : unsupported_ext) - LOG_CRITICAL(Frontend, "Unsupported GL extension: {}", ext.toStdString()); + if (!unsupported_ext.empty()) { + LOG_ERROR(Frontend, "GPU does not support all required extensions: {}", + glGetString(GL_RENDERER)); + } + for (const QString& ext : unsupported_ext) { + LOG_ERROR(Frontend, "Unsupported GL extension: {}", ext.toStdString()); + } return unsupported_ext; }