UI: Disable OSX V-Sync when program is open

OSX has an annoying feature called "BeamSync", which on later versions
of OSX is always on.  For whatever reason, Apple devs decided to force
this feature to always be on, so applications must always render with
v-sync regardless of what they set their swap interval to.

This issue would cause syncing to the vertical refresh for each
additional active display, and wouldn't allow rendering above the
current refresh rate.  This caused major rendering stalls and prevented
video frame timing from being accurate.

This fixes the issue by using an undocumented set of functions to
disable BeamSync.  Note that because this is an undocumented method of
working around the issue, its existence cannot be guaranteed.  If the
functions no longer exist for whatever reason, it will safely do
nothing.
This commit is contained in:
jp9000
2016-01-25 17:44:41 -08:00
parent c072ba55b2
commit 832043fc7f
7 changed files with 116 additions and 0 deletions
+43
View File
@@ -346,6 +346,8 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
HookWidget(ui->colorFormat, COMBO_CHANGED, ADV_CHANGED);
HookWidget(ui->colorSpace, COMBO_CHANGED, ADV_CHANGED);
HookWidget(ui->colorRange, COMBO_CHANGED, ADV_CHANGED);
HookWidget(ui->disableOSXVSync, CHECK_CHANGED, ADV_CHANGED);
HookWidget(ui->resetOSXVSync, CHECK_CHANGED, ADV_CHANGED);
HookWidget(ui->streamDelayEnable, CHECK_CHANGED, ADV_CHANGED);
HookWidget(ui->streamDelaySec, SCROLL_CHANGED, ADV_CHANGED);
HookWidget(ui->streamDelayPreserve, CHECK_CHANGED, ADV_CHANGED);
@@ -378,6 +380,13 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
ui->adapter = nullptr;
#endif
#ifndef __APPLE__
delete ui->disableOSXVSync;
delete ui->resetOSXVSync;
ui->disableOSXVSync = nullptr;
ui->resetOSXVSync = nullptr;
#endif
connect(ui->streamDelaySec, SIGNAL(valueChanged(int)),
this, SLOT(UpdateStreamDelayEstimate()));
connect(ui->outputMode, SIGNAL(currentIndexChanged(int)),
@@ -1676,6 +1685,16 @@ void OBSBasicSettings::LoadAdvancedSettings()
ui->advancedVideoContainer->setEnabled(false);
}
#ifdef __APPLE__
bool disableOSXVSync = config_get_bool(App()->GlobalConfig(),
"Video", "DisableOSXVSync");
bool resetOSXVSync = config_get_bool(App()->GlobalConfig(),
"Video", "ResetOSXVSyncOnExit");
ui->disableOSXVSync->setChecked(disableOSXVSync);
ui->resetOSXVSync->setChecked(resetOSXVSync);
ui->resetOSXVSync->setEnabled(disableOSXVSync);
#endif
loading = false;
}
@@ -2074,6 +2093,20 @@ void OBSBasicSettings::SaveAdvancedSettings()
config_set_string(App()->GlobalConfig(), "Video", "Renderer",
QT_TO_UTF8(ui->renderer->currentText()));
#endif
#ifdef __APPLE__
if (WidgetChanged(ui->disableOSXVSync)) {
bool disable = ui->disableOSXVSync->isChecked();
config_set_bool(App()->GlobalConfig(),
"Video", "DisableOSXVSync", disable);
EnableOSXVSync(!disable);
}
if (WidgetChanged(ui->resetOSXVSync))
config_set_bool(App()->GlobalConfig(),
"Video", "ResetOSXVSyncOnExit",
ui->resetOSXVSync->isChecked());
#endif
SaveSpinBox(ui->audioBufferingTime, "Audio", "BufferingTime");
SaveCombo(ui->colorFormat, "Video", "ColorFormat");
SaveCombo(ui->colorSpace, "Video", "ColorSpace");
@@ -2992,3 +3025,13 @@ void OBSBasicSettings::SimpleRecordingQualityLosslessWarning(int idx)
lastSimpleRecQualityIdx = idx;
}
void OBSBasicSettings::on_disableOSXVSync_clicked()
{
#ifdef __APPLE__
if (!loading) {
bool disable = ui->disableOSXVSync->isChecked();
ui->resetOSXVSync->setEnabled(disable);
}
#endif
}