From 001a46341e11284c238db8eb5fab45695455c1cc Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Thu, 7 Jan 2021 00:17:59 +0100 Subject: [PATCH] Small improvements to the VSync setup and logging. --- es-core/src/renderers/Renderer_GL21.cpp | 21 ++++++++++----------- es-core/src/renderers/Renderer_GLES10.cpp | 20 +++++++++----------- 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/es-core/src/renderers/Renderer_GL21.cpp b/es-core/src/renderers/Renderer_GL21.cpp index 06fd5e9d4..ade739504 100644 --- a/es-core/src/renderers/Renderer_GL21.cpp +++ b/es-core/src/renderers/Renderer_GL21.cpp @@ -377,21 +377,20 @@ namespace Renderer void setSwapInterval() { - // vsync. if (Settings::getInstance()->getBool("VSync")) { - // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), - // 1 for updates synchronized with the vertical retrace, - // or -1 for late swap tearing. - // SDL_GL_SetSwapInterval returns 0 on success, -1 on error. - // if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing - // if that doesn't work, report an error. - if (SDL_GL_SetSwapInterval(1) != 0 && SDL_GL_SetSwapInterval(-1) != 0) { - LOG(LogWarning) << "Tried to enable vsync, but it failed. (" << - SDL_GetError() << ")"; + // Adaptive VSync seems to be nonfunctional or having issues on some hardware + // and drivers, so only attempt to apply regular VSync. + if (SDL_GL_SetSwapInterval(1) == 0) { + LOG(LogInfo) << "Enabling VSync..."; + } + else { + LOG(LogWarning) << "Could not enable VSync: " << SDL_GetError(); } } - else + else { SDL_GL_SetSwapInterval(0); + LOG(LogInfo) << "Disabling VSync..."; + } } void swapBuffers() diff --git a/es-core/src/renderers/Renderer_GLES10.cpp b/es-core/src/renderers/Renderer_GLES10.cpp index cb79a9d2e..e9e3a03f1 100644 --- a/es-core/src/renderers/Renderer_GLES10.cpp +++ b/es-core/src/renderers/Renderer_GLES10.cpp @@ -83,7 +83,7 @@ namespace Renderer LOG(LogInfo) << "GL renderer: " << renderer; LOG(LogInfo) << "GL version: " << version; LOG(LogInfo) << "EmulationStation renderer: OpenGL ES 1.0"; - LOG(LogInfo) << "Checking available OpenGL extensions..."; + LOG(LogInfo) << "Checking available OpenGL ES extensions..."; std::string glExts = glGetString(GL_EXTENSIONS) ? reinterpret_cast(glGetString(GL_EXTENSIONS)) : ""; LOG(LogInfo) << "GL_OES_texture_npot: " << @@ -240,21 +240,19 @@ namespace Renderer void setSwapInterval() { - // vsync. if (Settings::getInstance()->getBool("VSync")) { - // SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), - // 1 for updates synchronized with the vertical retrace, - // or -1 for late swap tearing. - // SDL_GL_SetSwapInterval returns 0 on success, -1 on error. - // if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing - // if that doesn't work, report an error. - if (SDL_GL_SetSwapInterval(1) != 0 && SDL_GL_SetSwapInterval(-1) != 0) { - LOG(LogWarning) << "Tried to enable vsync, but it failed. (" << - SDL_GetError() << ")"; + // Adaptive VSync seems to be nonfunctional or having issues on some hardware + // and drivers, so only attempt to apply regular VSync. + if (SDL_GL_SetSwapInterval(1) == 0) { + LOG(LogInfo) << "Enabling VSync..."; + } + else { + LOG(LogWarning) << "Could not enable VSync: " << SDL_GetError(); } } else { SDL_GL_SetSwapInterval(0); + LOG(LogInfo) << "Disabling VSync..."; } }