CDROMAsyncReader: Support reading ahead more sectors

This commit is contained in:
Connor McLaughlin
2021-07-12 21:08:04 +10:00
parent 552b0098ef
commit a32ef4a963
10 changed files with 351 additions and 162 deletions

View File

@ -1,4 +1,5 @@
#include "consolesettingswidget.h"
#include "common/cd_image.h"
#include "core/system.h"
#include "qtutils.h"
#include "settingsdialog.h"
@ -28,6 +29,17 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
qApp->translate("MultitapMode", Settings::GetMultitapModeDisplayName(static_cast<MultitapMode>(i))));
}
static constexpr float TIME_PER_SECTOR_DOUBLE_SPEED = 1000.0f / 150.0f;
m_ui.cdromReadaheadSectors->addItem(tr("Disabled (Synchronous)"));
for (u32 i = 1; i <= 32; i++)
{
m_ui.cdromReadaheadSectors->addItem(tr("%1 sectors (%2 KB / %3 ms)")
.arg(i)
.arg(static_cast<float>(i) * TIME_PER_SECTOR_DOUBLE_SPEED, 0, 'f', 0)
.arg(static_cast<float>(i * CDImage::DATA_SECTOR_SIZE) / 1024.0f));
}
SettingWidgetBinder::BindWidgetToEnumSetting(m_host_interface, m_ui.region, "Console", "Region",
&Settings::ParseConsoleRegionName, &Settings::GetConsoleRegionName,
Settings::DEFAULT_CONSOLE_REGION);
@ -37,7 +49,8 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
Settings::DEFAULT_CPU_EXECUTION_MODE);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.enableCPUClockSpeedControl, "CPU",
"OverclockEnable", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromReadThread, "CDROM", "ReadThread", true);
SettingWidgetBinder::BindWidgetToIntSetting(m_host_interface, m_ui.cdromReadaheadSectors, "CDROM", "ReadaheadSectors",
Settings::DEFAULT_CDROM_READAHEAD_SECTORS);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromRegionCheck, "CDROM", "RegionCheck", false);
SettingWidgetBinder::BindWidgetToBoolSetting(m_host_interface, m_ui.cdromLoadImageToRAM, "CDROM", "LoadImageToRAM",
false);
@ -74,9 +87,10 @@ ConsoleSettingsWidget::ConsoleSettingsWidget(QtHostInterface* host_interface, QW
m_ui.cdromSeekSpeedup, tr("CD-ROM Seek Speedup"), tr("None (Normal Speed)"),
tr("Reduces the simulated time for the CD-ROM sled to move to different areas of the disc. Can improve loading "
"times, but crash games which do not expect the CD-ROM to operate faster."));
dialog->registerWidgetHelp(
m_ui.cdromReadThread, tr("Use Read Thread (Asynchronous)"), tr("Checked"),
tr("Reduces hitches in emulation by reading/decompressing CD data asynchronously on a worker thread."));
dialog->registerWidgetHelp(m_ui.cdromReadaheadSectors, tr("Asynchronous Readahead"), tr("8 Sectors"),
tr("Reduces hitches in emulation by reading/decompressing CD data asynchronously on a "
"worker thread. Higher sector numbers can reduce spikes when streaming FMVs or audio "
"on slower storage or when using compression formats such as CHD."));
dialog->registerWidgetHelp(m_ui.cdromRegionCheck, tr("Enable Region Check"), tr("Checked"),
tr("Simulates the region check present in original, unmodified consoles."));
dialog->registerWidgetHelp(

View File

@ -137,14 +137,17 @@
<string>CD-ROM Emulation</string>
</property>
<layout class="QFormLayout" name="formLayout_4">
<item row="0" column="0">
<item row="0" column="1">
<widget class="QComboBox" name="cdromReadaheadSectors"/>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Read Speedup:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QComboBox" name="cdromReadSpeedup">
<item>
<property name="text">
@ -198,46 +201,14 @@
</item>
</widget>
</item>
<item row="2" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="cdromReadThread">
<property name="text">
<string>Use Read Thread (Asynchronous)</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cdromRegionCheck">
<property name="text">
<string>Enable Region Check</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cdromLoadImageToRAM">
<property name="text">
<string>Preload Image To RAM</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="cdromLoadImagePatches">
<property name="text">
<string>Apply Image Patches</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Seek Speedup:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QComboBox" name="cdromSeekSpeedup">
<property name="currentIndex">
<number>1</number>
@ -299,6 +270,38 @@
</item>
</widget>
</item>
<item row="3" column="0" colspan="2">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<widget class="QCheckBox" name="cdromRegionCheck">
<property name="text">
<string>Enable Region Check</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="cdromLoadImageToRAM">
<property name="text">
<string>Preload Image To RAM</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="cdromLoadImagePatches">
<property name="text">
<string>Apply Image Patches</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Async Readahead:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>