Small improvements to the VSync setup and logging.

This commit is contained in:
Leon Styhre 2021-01-07 00:17:59 +01:00
parent e2b3ca55be
commit 001a46341e
2 changed files with 19 additions and 22 deletions

View file

@ -377,21 +377,20 @@ namespace Renderer
void setSwapInterval() void setSwapInterval()
{ {
// vsync.
if (Settings::getInstance()->getBool("VSync")) { if (Settings::getInstance()->getBool("VSync")) {
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), // Adaptive VSync seems to be nonfunctional or having issues on some hardware
// 1 for updates synchronized with the vertical retrace, // and drivers, so only attempt to apply regular VSync.
// or -1 for late swap tearing. if (SDL_GL_SetSwapInterval(1) == 0) {
// SDL_GL_SetSwapInterval returns 0 on success, -1 on error. LOG(LogInfo) << "Enabling VSync...";
// if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing }
// if that doesn't work, report an error. else {
if (SDL_GL_SetSwapInterval(1) != 0 && SDL_GL_SetSwapInterval(-1) != 0) { LOG(LogWarning) << "Could not enable VSync: " << SDL_GetError();
LOG(LogWarning) << "Tried to enable vsync, but it failed. (" <<
SDL_GetError() << ")";
} }
} }
else else {
SDL_GL_SetSwapInterval(0); SDL_GL_SetSwapInterval(0);
LOG(LogInfo) << "Disabling VSync...";
}
} }
void swapBuffers() void swapBuffers()

View file

@ -83,7 +83,7 @@ namespace Renderer
LOG(LogInfo) << "GL renderer: " << renderer; LOG(LogInfo) << "GL renderer: " << renderer;
LOG(LogInfo) << "GL version: " << version; LOG(LogInfo) << "GL version: " << version;
LOG(LogInfo) << "EmulationStation renderer: OpenGL ES 1.0"; 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) ? std::string glExts = glGetString(GL_EXTENSIONS) ?
reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : ""; reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)) : "";
LOG(LogInfo) << "GL_OES_texture_npot: " << LOG(LogInfo) << "GL_OES_texture_npot: " <<
@ -240,21 +240,19 @@ namespace Renderer
void setSwapInterval() void setSwapInterval()
{ {
// vsync.
if (Settings::getInstance()->getBool("VSync")) { if (Settings::getInstance()->getBool("VSync")) {
// SDL_GL_SetSwapInterval(0) for immediate updates (no vsync, default), // Adaptive VSync seems to be nonfunctional or having issues on some hardware
// 1 for updates synchronized with the vertical retrace, // and drivers, so only attempt to apply regular VSync.
// or -1 for late swap tearing. if (SDL_GL_SetSwapInterval(1) == 0) {
// SDL_GL_SetSwapInterval returns 0 on success, -1 on error. LOG(LogInfo) << "Enabling VSync...";
// if vsync is requested, try normal vsync; if that doesn't work, try late swap tearing }
// if that doesn't work, report an error. else {
if (SDL_GL_SetSwapInterval(1) != 0 && SDL_GL_SetSwapInterval(-1) != 0) { LOG(LogWarning) << "Could not enable VSync: " << SDL_GetError();
LOG(LogWarning) << "Tried to enable vsync, but it failed. (" <<
SDL_GetError() << ")";
} }
} }
else { else {
SDL_GL_SetSwapInterval(0); SDL_GL_SetSwapInterval(0);
LOG(LogInfo) << "Disabling VSync...";
} }
} }