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()
{
// 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()

View file

@ -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<const char*>(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...";
}
}