Reintroduce a vsync option for people with really bad drivers

This commit is contained in:
James Rowe 2019-12-15 15:42:05 -07:00
parent 65613cce81
commit 36c5058d66
8 changed files with 54 additions and 3 deletions

View file

@ -123,6 +123,8 @@ void Config::ReadValues() {
Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true); Settings::values.use_frame_limit = sdl2_config->GetBoolean("Renderer", "use_frame_limit", true);
Settings::values.frame_limit = Settings::values.frame_limit =
static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100)); static_cast<u16>(sdl2_config->GetInteger("Renderer", "frame_limit", 100));
Settings::values.use_vsync_new =
static_cast<u16>(sdl2_config->GetInteger("Renderer", "use_vsync_new", 1));
Settings::values.render_3d = static_cast<Settings::StereoRenderOption>( Settings::values.render_3d = static_cast<Settings::StereoRenderOption>(
sdl2_config->GetInteger("Renderer", "render_3d", 0)); sdl2_config->GetInteger("Renderer", "render_3d", 0));

View file

@ -112,6 +112,11 @@ shaders_accurate_mul =
# 0: Interpreter (slow), 1 (default): JIT (fast) # 0: Interpreter (slow), 1 (default): JIT (fast)
use_shader_jit = 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 # Resolution scale factor
# 0: Auto (scales resolution to window size), 1: Native 3DS screen resolution, Otherwise a scale # 0: Auto (scales resolution to window size), 1: Native 3DS screen resolution, Otherwise a scale
# factor for the 3DS resolution # factor for the 3DS resolution

View file

@ -96,11 +96,22 @@ void EmuThread::run() {
OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context) OpenGLWindow::OpenGLWindow(QWindow* parent, QWidget* event_handler, QOpenGLContext* shared_context)
: QWindow(parent), event_handler(event_handler), : QWindow(parent), event_handler(event_handler),
context(new QOpenGLContext(shared_context->parent())) { 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->setShareContext(shared_context);
context->setScreen(this->screen()); context->setScreen(this->screen());
context->setFormat(shared_context->format()); context->setFormat(format);
context->create(); 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); setSurfaceType(QWindow::OpenGLSurface);
// TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground, // TODO: One of these flags might be interesting: WA_OpaquePaintEvent, WA_NoBackground,
@ -409,10 +420,16 @@ std::unique_ptr<Frontend::GraphicsContext> GRenderWindow::CreateSharedContext()
GLContext::GLContext(QOpenGLContext* shared_context) GLContext::GLContext(QOpenGLContext* shared_context)
: context(new QOpenGLContext(shared_context->parent())), : context(new QOpenGLContext(shared_context->parent())),
surface(new QOffscreenSurface(nullptr)) { surface(new QOffscreenSurface(nullptr)) {
// disable vsync for any shared contexts
auto format = shared_context->format();
format.setSwapInterval(0);
context->setShareContext(shared_context); context->setShareContext(shared_context);
context->setFormat(format);
context->create(); context->create();
surface->setParent(shared_context->parent()); surface->setParent(shared_context->parent());
surface->setFormat(shared_context->format()); surface->setFormat(format);
surface->create(); surface->create();
} }

View file

@ -428,6 +428,7 @@ void Config::ReadRendererValues() {
Settings::values.shaders_accurate_mul = Settings::values.shaders_accurate_mul =
ReadSetting(QStringLiteral("shaders_accurate_mul"), false).toBool(); ReadSetting(QStringLiteral("shaders_accurate_mul"), false).toBool();
Settings::values.use_shader_jit = ReadSetting(QStringLiteral("use_shader_jit"), true).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 = Settings::values.resolution_factor =
static_cast<u16>(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt()); static_cast<u16>(ReadSetting(QStringLiteral("resolution_factor"), 1).toInt());
Settings::values.use_frame_limit = Settings::values.use_frame_limit =
@ -855,6 +856,7 @@ void Config::SaveRendererValues() {
WriteSetting(QStringLiteral("shaders_accurate_mul"), Settings::values.shaders_accurate_mul, WriteSetting(QStringLiteral("shaders_accurate_mul"), Settings::values.shaders_accurate_mul,
false); false);
WriteSetting(QStringLiteral("use_shader_jit"), Settings::values.use_shader_jit, true); 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("resolution_factor"), Settings::values.resolution_factor, 1);
WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true); WriteSetting(QStringLiteral("use_frame_limit"), Settings::values.use_frame_limit, true);
WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100); WriteSetting(QStringLiteral("frame_limit"), Settings::values.frame_limit, 100);

View file

@ -18,6 +18,8 @@ ConfigureGraphics::ConfigureGraphics(QWidget* parent)
SetConfiguration(); SetConfiguration();
ui->hw_renderer_group->setEnabled(ui->toggle_hw_renderer->isChecked()); 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] { connect(ui->toggle_hw_renderer, &QCheckBox::toggled, this, [this] {
auto checked = ui->toggle_hw_renderer->isChecked(); auto checked = ui->toggle_hw_renderer->isChecked();
ui->hw_renderer_group->setEnabled(checked); 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_hw_shader->setChecked(Settings::values.use_hw_shader);
ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul); ui->toggle_accurate_mul->setChecked(Settings::values.shaders_accurate_mul);
ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit); ui->toggle_shader_jit->setChecked(Settings::values.use_shader_jit);
ui->toggle_vsync_new->setChecked(Settings::values.use_vsync_new);
} }
void ConfigureGraphics::ApplyConfiguration() { void ConfigureGraphics::ApplyConfiguration() {
@ -53,6 +56,7 @@ void ConfigureGraphics::ApplyConfiguration() {
Settings::values.use_hw_shader = ui->toggle_hw_shader->isChecked(); Settings::values.use_hw_shader = ui->toggle_hw_shader->isChecked();
Settings::values.shaders_accurate_mul = ui->toggle_accurate_mul->isChecked(); Settings::values.shaders_accurate_mul = ui->toggle_accurate_mul->isChecked();
Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked(); Settings::values.use_shader_jit = ui->toggle_shader_jit->isChecked();
Settings::values.use_vsync_new = ui->toggle_vsync_new->isChecked();
} }
void ConfigureGraphics::RetranslateUI() { void ConfigureGraphics::RetranslateUI() {

View file

@ -105,6 +105,25 @@
</layout> </layout>
</widget> </widget>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Advanced</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="toggle_vsync_new">
<property name="toolTip">
<string>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.</string>
</property>
<property name="text">
<string>Enable VSync</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<spacer name="verticalSpacer"> <spacer name="verticalSpacer">
<property name="orientation"> <property name="orientation">

View file

@ -2075,7 +2075,7 @@ int main(int argc, char* argv[]) {
QSurfaceFormat format; QSurfaceFormat format;
format.setVersion(3, 3); format.setVersion(3, 3);
format.setProfile(QSurfaceFormat::CoreProfile); format.setProfile(QSurfaceFormat::CoreProfile);
format.setSwapInterval(1); format.setSwapInterval(0);
// TODO: expose a setting for buffer value (ie default/single/double/triple) // TODO: expose a setting for buffer value (ie default/single/double/triple)
format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior); format.setSwapBehavior(QSurfaceFormat::DefaultSwapBehavior);
QSurfaceFormat::setDefaultFormat(format); QSurfaceFormat::setDefaultFormat(format);

View file

@ -173,6 +173,8 @@ struct Values {
bool custom_textures; bool custom_textures;
bool preload_textures; bool preload_textures;
bool use_vsync_new;
// Audio // Audio
bool enable_dsp_lle; bool enable_dsp_lle;
bool enable_dsp_lle_multithread; bool enable_dsp_lle_multithread;