mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-12-16 04:09:39 +00:00
Core/DiscIO: Add a setting to load the running game into memory via CachedBlobReader.
This commit is contained in:
parent
d7c3513eae
commit
e5ad814142
@ -240,7 +240,7 @@ std::unique_ptr<BootParameters> BootParameters::GenerateFromFile(std::vector<std
|
|||||||
".elf"}};
|
".elf"}};
|
||||||
if (disc_image_extensions.contains(extension))
|
if (disc_image_extensions.contains(extension))
|
||||||
{
|
{
|
||||||
std::unique_ptr<DiscIO::VolumeDisc> disc = DiscIO::CreateDisc(path);
|
std::unique_ptr<DiscIO::VolumeDisc> disc = DiscIO::CreateDiscForCore(path);
|
||||||
if (disc)
|
if (disc)
|
||||||
{
|
{
|
||||||
return std::make_unique<BootParameters>(Disc{std::move(path), std::move(disc), paths},
|
return std::make_unique<BootParameters>(Disc{std::move(path), std::move(disc), paths},
|
||||||
@ -469,7 +469,7 @@ static void SetDefaultDisc(DVD::DVDInterface& dvd_interface)
|
|||||||
{
|
{
|
||||||
const std::string default_iso = Config::Get(Config::MAIN_DEFAULT_ISO);
|
const std::string default_iso = Config::Get(Config::MAIN_DEFAULT_ISO);
|
||||||
if (!default_iso.empty())
|
if (!default_iso.empty())
|
||||||
SetDisc(dvd_interface, DiscIO::CreateDisc(default_iso));
|
SetDisc(dvd_interface, DiscIO::CreateDiscForCore(default_iso));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CopyDefaultExceptionHandlers(Core::System& system)
|
static void CopyDefaultExceptionHandlers(Core::System& system)
|
||||||
@ -629,7 +629,7 @@ bool CBoot::BootUp(Core::System& system, const Core::CPUThreadGuard& guard,
|
|||||||
if (ipl.disc)
|
if (ipl.disc)
|
||||||
{
|
{
|
||||||
NOTICE_LOG_FMT(BOOT, "Inserting disc: {}", ipl.disc->path);
|
NOTICE_LOG_FMT(BOOT, "Inserting disc: {}", ipl.disc->path);
|
||||||
SetDisc(system.GetDVDInterface(), DiscIO::CreateDisc(ipl.disc->path),
|
SetDisc(system.GetDVDInterface(), DiscIO::CreateDiscForCore(ipl.disc->path),
|
||||||
ipl.disc->auto_disc_change_paths);
|
ipl.disc->auto_disc_change_paths);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -58,6 +58,7 @@ constexpr bool DEFAULT_CPU_THREAD = true;
|
|||||||
constexpr bool DEFAULT_CPU_THREAD = false;
|
constexpr bool DEFAULT_CPU_THREAD = false;
|
||||||
#endif
|
#endif
|
||||||
const Info<bool> MAIN_CPU_THREAD{{System::Main, "Core", "CPUThread"}, DEFAULT_CPU_THREAD};
|
const Info<bool> MAIN_CPU_THREAD{{System::Main, "Core", "CPUThread"}, DEFAULT_CPU_THREAD};
|
||||||
|
const Info<bool> MAIN_LOAD_GAME_INTO_MEMORY{{System::Main, "Core", "LoadGameIntoMemory"}, false};
|
||||||
const Info<bool> MAIN_SYNC_ON_SKIP_IDLE{{System::Main, "Core", "SyncOnSkipIdle"}, true};
|
const Info<bool> MAIN_SYNC_ON_SKIP_IDLE{{System::Main, "Core", "SyncOnSkipIdle"}, true};
|
||||||
const Info<std::string> MAIN_DEFAULT_ISO{{System::Main, "Core", "DefaultISO"}, ""};
|
const Info<std::string> MAIN_DEFAULT_ISO{{System::Main, "Core", "DefaultISO"}, ""};
|
||||||
const Info<bool> MAIN_ENABLE_CHEATS{{System::Main, "Core", "EnableCheats"}, false};
|
const Info<bool> MAIN_ENABLE_CHEATS{{System::Main, "Core", "EnableCheats"}, false};
|
||||||
|
|||||||
@ -68,6 +68,7 @@ extern const Info<bool> MAIN_CORRECT_TIME_DRIFT;
|
|||||||
extern const Info<bool> MAIN_RUSH_FRAME_PRESENTATION;
|
extern const Info<bool> MAIN_RUSH_FRAME_PRESENTATION;
|
||||||
extern const Info<bool> MAIN_SMOOTH_EARLY_PRESENTATION;
|
extern const Info<bool> MAIN_SMOOTH_EARLY_PRESENTATION;
|
||||||
extern const Info<bool> MAIN_CPU_THREAD;
|
extern const Info<bool> MAIN_CPU_THREAD;
|
||||||
|
extern const Info<bool> MAIN_LOAD_GAME_INTO_MEMORY;
|
||||||
extern const Info<bool> MAIN_SYNC_ON_SKIP_IDLE;
|
extern const Info<bool> MAIN_SYNC_ON_SKIP_IDLE;
|
||||||
extern const Info<std::string> MAIN_DEFAULT_ISO;
|
extern const Info<std::string> MAIN_DEFAULT_ISO;
|
||||||
extern const Info<bool> MAIN_ENABLE_CHEATS;
|
extern const Info<bool> MAIN_ENABLE_CHEATS;
|
||||||
|
|||||||
@ -428,7 +428,8 @@ void DVDInterface::EjectDiscCallback(Core::System& system, u64 userdata, s64 cyc
|
|||||||
void DVDInterface::InsertDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate)
|
void DVDInterface::InsertDiscCallback(Core::System& system, u64 userdata, s64 cyclesLate)
|
||||||
{
|
{
|
||||||
auto& di = system.GetDVDInterface();
|
auto& di = system.GetDVDInterface();
|
||||||
std::unique_ptr<DiscIO::VolumeDisc> new_disc = DiscIO::CreateDisc(di.m_disc_path_to_insert);
|
std::unique_ptr<DiscIO::VolumeDisc> new_disc =
|
||||||
|
DiscIO::CreateDiscForCore(di.m_disc_path_to_insert);
|
||||||
|
|
||||||
if (new_disc)
|
if (new_disc)
|
||||||
di.SetDisc(std::move(new_disc), {});
|
di.SetDisc(std::move(new_disc), {});
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "DiscIO/Volume.h"
|
#include "DiscIO/Volume.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
@ -16,8 +16,11 @@
|
|||||||
#include "Common/Crypto/SHA1.h"
|
#include "Common/Crypto/SHA1.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/IOS/ES/Formats.h"
|
#include "Core/IOS/ES/Formats.h"
|
||||||
|
|
||||||
#include "DiscIO/Blob.h"
|
#include "DiscIO/Blob.h"
|
||||||
|
#include "DiscIO/CachedBlob.h"
|
||||||
#include "DiscIO/DiscUtils.h"
|
#include "DiscIO/DiscUtils.h"
|
||||||
#include "DiscIO/Enums.h"
|
#include "DiscIO/Enums.h"
|
||||||
#include "DiscIO/VolumeDisc.h"
|
#include "DiscIO/VolumeDisc.h"
|
||||||
@ -84,16 +87,21 @@ std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<char16_t>
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<VolumeDisc> TryCreateDisc(std::unique_ptr<BlobReader>& reader)
|
template <typename T = std::identity>
|
||||||
|
static std::unique_ptr<VolumeDisc> TryCreateDisc(std::unique_ptr<BlobReader> reader,
|
||||||
|
const T& reader_adapter_factory = {})
|
||||||
{
|
{
|
||||||
if (!reader)
|
if (!reader)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
|
// `reader_adapter_factory` is used *after* successful magic word read.
|
||||||
|
// This prevents `CachedBlobReader` from showing warnings when failing to scrub a .dol file.
|
||||||
|
|
||||||
if (reader->ReadSwapped<u32>(0x18) == WII_DISC_MAGIC)
|
if (reader->ReadSwapped<u32>(0x18) == WII_DISC_MAGIC)
|
||||||
return std::make_unique<VolumeWii>(std::move(reader));
|
return std::make_unique<VolumeWii>(reader_adapter_factory(std::move(reader)));
|
||||||
|
|
||||||
if (reader->ReadSwapped<u32>(0x1C) == GAMECUBE_DISC_MAGIC)
|
if (reader->ReadSwapped<u32>(0x1C) == GAMECUBE_DISC_MAGIC)
|
||||||
return std::make_unique<VolumeGC>(std::move(reader));
|
return std::make_unique<VolumeGC>(reader_adapter_factory(std::move(reader)));
|
||||||
|
|
||||||
// No known magic words found
|
// No known magic words found
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -101,7 +109,7 @@ static std::unique_ptr<VolumeDisc> TryCreateDisc(std::unique_ptr<BlobReader>& re
|
|||||||
|
|
||||||
std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader> reader)
|
std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader> reader)
|
||||||
{
|
{
|
||||||
return TryCreateDisc(reader);
|
return TryCreateDisc(std::move(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path)
|
std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path)
|
||||||
@ -109,7 +117,15 @@ std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path)
|
|||||||
return CreateDisc(CreateBlobReader(path));
|
return CreateDisc(CreateBlobReader(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::unique_ptr<VolumeWAD> TryCreateWAD(std::unique_ptr<BlobReader>& reader)
|
std::unique_ptr<VolumeDisc> CreateDiscForCore(const std::string& path)
|
||||||
|
{
|
||||||
|
if (Config::Get(Config::MAIN_LOAD_GAME_INTO_MEMORY))
|
||||||
|
return TryCreateDisc(CreateBlobReader(path), CreateScrubbingCachedBlobReader);
|
||||||
|
|
||||||
|
return CreateDisc(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::unique_ptr<VolumeWAD> TryCreateWAD(std::unique_ptr<BlobReader> reader)
|
||||||
{
|
{
|
||||||
if (!reader)
|
if (!reader)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -126,7 +142,7 @@ static std::unique_ptr<VolumeWAD> TryCreateWAD(std::unique_ptr<BlobReader>& read
|
|||||||
|
|
||||||
std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader> reader)
|
std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader> reader)
|
||||||
{
|
{
|
||||||
return TryCreateWAD(reader);
|
return TryCreateWAD(std::move(reader));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
|
std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
|
||||||
@ -136,11 +152,11 @@ std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
|
|||||||
|
|
||||||
std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader)
|
std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader)
|
||||||
{
|
{
|
||||||
std::unique_ptr<VolumeDisc> disc = TryCreateDisc(reader);
|
std::unique_ptr<VolumeDisc> disc = TryCreateDisc(std::move(reader));
|
||||||
if (disc)
|
if (disc)
|
||||||
return disc;
|
return disc;
|
||||||
|
|
||||||
std::unique_ptr<VolumeWAD> wad = TryCreateWAD(reader);
|
std::unique_ptr<VolumeWAD> wad = TryCreateWAD(std::move(reader));
|
||||||
if (wad)
|
if (wad)
|
||||||
return wad;
|
return wad;
|
||||||
|
|
||||||
|
|||||||
@ -176,6 +176,9 @@ protected:
|
|||||||
|
|
||||||
std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader> reader);
|
std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader> reader);
|
||||||
std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path);
|
std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path);
|
||||||
|
// This version enables caching when the "Load Games into Memory" setting is enabled.
|
||||||
|
std::unique_ptr<VolumeDisc> CreateDiscForCore(const std::string& path);
|
||||||
|
|
||||||
std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader> reader);
|
std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader> reader);
|
||||||
std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path);
|
std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path);
|
||||||
std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader);
|
std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader);
|
||||||
|
|||||||
@ -90,6 +90,7 @@ void GeneralPane::OnEmulationStateChanged(Core::State state)
|
|||||||
|
|
||||||
m_checkbox_dualcore->setEnabled(!running);
|
m_checkbox_dualcore->setEnabled(!running);
|
||||||
m_checkbox_cheats->setEnabled(!running);
|
m_checkbox_cheats->setEnabled(!running);
|
||||||
|
m_checkbox_load_games_into_memory->setEnabled(!running);
|
||||||
m_checkbox_override_region_settings->setEnabled(!running);
|
m_checkbox_override_region_settings->setEnabled(!running);
|
||||||
#ifdef USE_DISCORD_PRESENCE
|
#ifdef USE_DISCORD_PRESENCE
|
||||||
m_checkbox_discord_presence->setEnabled(!running);
|
m_checkbox_discord_presence->setEnabled(!running);
|
||||||
@ -147,6 +148,15 @@ void GeneralPane::CreateBasic()
|
|||||||
m_checkbox_cheats = new ConfigBool(tr("Enable Cheats"), Config::MAIN_ENABLE_CHEATS);
|
m_checkbox_cheats = new ConfigBool(tr("Enable Cheats"), Config::MAIN_ENABLE_CHEATS);
|
||||||
basic_group_layout->addWidget(m_checkbox_cheats);
|
basic_group_layout->addWidget(m_checkbox_cheats);
|
||||||
|
|
||||||
|
m_checkbox_load_games_into_memory =
|
||||||
|
new ConfigBool(tr("Load Whole Game Into Memory"), Config::MAIN_LOAD_GAME_INTO_MEMORY);
|
||||||
|
basic_group_layout->addWidget(m_checkbox_load_games_into_memory);
|
||||||
|
m_checkbox_load_games_into_memory->SetDescription(
|
||||||
|
tr("Loads the running game into memory in the background."
|
||||||
|
"<br><br>This may improve performance with slow or high-latency storage."
|
||||||
|
"<br>System memory requirements will be much higher with this setting enabled."
|
||||||
|
"<br><br><dolphin_emphasis>If unsure, leave this unchecked.</dolphin_emphasis>"));
|
||||||
|
|
||||||
m_checkbox_override_region_settings =
|
m_checkbox_override_region_settings =
|
||||||
new ConfigBool(tr("Allow Mismatched Region Settings"), Config::MAIN_OVERRIDE_REGION_SETTINGS);
|
new ConfigBool(tr("Allow Mismatched Region Settings"), Config::MAIN_OVERRIDE_REGION_SETTINGS);
|
||||||
basic_group_layout->addWidget(m_checkbox_override_region_settings);
|
basic_group_layout->addWidget(m_checkbox_override_region_settings);
|
||||||
|
|||||||
@ -48,6 +48,7 @@ private:
|
|||||||
ToolTipComboBox* m_combobox_fallback_region;
|
ToolTipComboBox* m_combobox_fallback_region;
|
||||||
ConfigBool* m_checkbox_dualcore;
|
ConfigBool* m_checkbox_dualcore;
|
||||||
ConfigBool* m_checkbox_cheats;
|
ConfigBool* m_checkbox_cheats;
|
||||||
|
ConfigBool* m_checkbox_load_games_into_memory;
|
||||||
ConfigBool* m_checkbox_override_region_settings;
|
ConfigBool* m_checkbox_override_region_settings;
|
||||||
ConfigBool* m_checkbox_auto_disc_change;
|
ConfigBool* m_checkbox_auto_disc_change;
|
||||||
#ifdef USE_DISCORD_PRESENCE
|
#ifdef USE_DISCORD_PRESENCE
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user