diff --git a/src/citra/config.cpp b/src/citra/config.cpp index 297465f92..8fa802a6d 100644 --- a/src/citra/config.cpp +++ b/src/citra/config.cpp @@ -123,6 +123,8 @@ void Config::ReadValues() { Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); Settings::values.frame_limit = static_cast(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); + Settings::values.use_vsync_new = + static_cast(sdl2_config->GetInteger("Renderer", "use_vsync_new", 1)); Settings::values.render_3d = static_cast( sdl2_config->GetInteger("Renderer", "render_3d", 0)); diff --git a/src/citra/default_ini.h b/src/citra/default_ini.h index 2ca725438..d646823e2 100644 --- a/src/citra/default_ini.h +++ b/src/citra/default_ini.h @@ -112,6 +112,11 @@ shaders_accurate_mul = # 0: Interpreter (slow), 1 (default): JIT (fast) use_shader_jit = +# Forces VSync on the display thread. Usually doesn't impact performance, but on some drivers it can +# so only turn this off if you notice a speed difference. +# 0: Off, 1 (default): On +use_vsync_new = + # Resolution scale factor # 0: Auto (scales resolution to window size), 1: Native 3DS screen resolution, Otherwise a scale # factor for the 3DS resolution diff --git a/src/citra_qt/bootmanager.cpp b/src/citra_qt/bootmanager.cpp index 595e6d152..11d49dd50 100644 --- a/src/citra_qt/bootmanager.cpp +++ b/src/citra_qt/bootmanager.cpp @@ -96,11 +96,22 @@ void EmuThread::run() { OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context) : QWindow(parent), event_handler(event_handler), context(new QOpenGLContext(shared_context->parent())) { + + // disable vsync for any shared contexts + auto format = shared_context->format(); + format.setSwapInterval(Settings::values.use_vsync_new ? 1 : 0); + this->setFormat(format); + context->setShareContext(shared_context); context->setScreen(this->screen()); - context->setFormat(shared_context->format()); + context->setFormat(format); context->create(); + LOG_WARNING(Frontend, "OpenGLWindow context format Interval {}", + context->format().swapInterval()); + + LOG_WARNING(Frontend, "OpenGLWindow surface format interval {}", this->format().swapInterval()); + setSurfaceType(QWindow::OpenGLSurface); // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, @@ -409,10 +420,16 @@ std::unique_ptr GRenderWindow::CreateSharedContext() GLContext::GLContext(QOpenGLContext* shared_context) : context(new QOpenGLContext(shared_context->parent())), surface(new QOffscreenSurface(nullptr)) { + + // disable vsync for any shared contexts + auto format = shared_context->format(); + format.setSwapInterval(0); + context->setShareContext(shared_context); + context->setFormat(format); context->create(); surface->setParent(shared_context->parent()); - surface->setFormat(shared_context->format()); + surface->setFormat(format); surface->create(); } diff --git a/src/citra_qt/configuration/config.cpp b/src/citra_qt/configuration/config.cpp index 26034dbe6..d516f6744 100644 --- a/src/citra_qt/configuration/config.cpp +++ b/src/citra_qt/configuration/config.cpp @@ -428,6 +428,7 @@ void Config::ReadRendererValues() { Settings::values.shaders_accurate_mul = ReadSetting(QStringLiteral("shaders_accurate_mul"), false).toBool(); Settings::values.use_shader_jit = ReadSetting(QStringLiteral("use_shader_jit"), true).toBool(); + Settings::values.use_vsync_new = ReadSetting(QStringLiteral("use_vsync_new"), true).toBool(); Settings::values.resolution_factor = static_cast(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); Settings::values.use_frame_limit = @@ -855,6 +856,7 @@ void Config::SaveRendererValues() { WriteSetting(QStringLiteral("shaders_accurate_mul"), Settings::values.shaders_accurate_mul, false); WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit, true); + WriteSetting(QStringLiteral("use_vsync_new"), Settings::values.use_vsync_new, true); WriteSetting(QStringLiteral("resolution_factor"), Settings::values.resolution_factor, 1); WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); diff --git a/src/citra_qt/configuration/configure_graphics.cpp b/src/citra_qt/configuration/configure_graphics.cpp index d04c0d6fe..b9dd4b468 100644 --- a/src/citra_qt/configuration/configure_graphics.cpp +++ b/src/citra_qt/configuration/configure_graphics.cpp @@ -18,6 +18,8 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent) SetConfiguration(); ui->hw_renderer_group->setEnabled(ui->toggle_hw_renderer->isChecked()); + ui->toggle_vsync_new->setEnabled(!Core::System::GetInstance().IsPoweredOn()); + connect(ui->toggle_hw_renderer, &QCheckBox::toggled, this, [this] { auto checked = ui->toggle_hw_renderer->isChecked(); ui->hw_renderer_group->setEnabled(checked); @@ -46,6 +48,7 @@ void ConfigureGraphics::SetConfiguration() { ui->toggle_hw_shader->setChecked(Settings::values.use_hw_shader); ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul); ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); + ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new); } void ConfigureGraphics::ApplyConfiguration() { @@ -53,6 +56,7 @@ void ConfigureGraphics::ApplyConfiguration() { Settings::values.use_hw_shader = ui->toggle_hw_shader->isChecked(); Settings::values.shaders_accurate_mul = ui->toggle_accurate_mul->isChecked(); Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); + Settings::values.use_vsync_new = ui->toggle_vsync_new->isChecked(); } void ConfigureGraphics::RetranslateUI() { diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui index 88b9a0caa..43f538558 100644 --- a/src/citra_qt/configuration/configure_graphics.ui +++ b/src/citra_qt/configuration/configure_graphics.ui @@ -105,6 +105,25 @@ + + + + Advanced + + + + + + VSync prevents the screen from tearing, but some graphics cards have lower performance with VSync enabled. Keep it enabled if you don't notice a performance difference. + + + Enable VSync + + + + + + diff --git a/src/citra_qt/main.cpp b/src/citra_qt/main.cpp index 5fdc12765..bbe4a94f2 100644 --- a/src/citra_qt/main.cpp +++ b/src/citra_qt/main.cpp @@ -2075,7 +2075,7 @@ int main(int argc, char* argv[]) { QSurfaceFormat format; format.setVersion(3, 3); format.setProfile(QSurfaceFormat::CoreProfile); - format.setSwapInterval(1); + format.setSwapInterval(0); // TODO: expose a setting for buffer value (ie default/single/double/triple) format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); QSurfaceFormat::setDefaultFormat(format); diff --git a/src/core/settings.h b/src/core/settings.h index 0d391afba..d7d351a4c 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -173,6 +173,8 @@ struct Values { bool custom_textures; bool preload_textures; + bool use_vsync_new; + // Audio bool enable_dsp_lle; bool enable_dsp_lle_multithread;