code golfing

This commit is contained in:
kalaposfos13 2026-03-02 19:51:32 +01:00
parent 6c81ae571f
commit 111f893f97
64 changed files with 242 additions and 252 deletions

View File

@ -141,7 +141,7 @@ public:
const auto& log_dir = GetUserPath(PathType::LogDir);
std::filesystem::create_directory(log_dir);
Filter filter;
filter.ParseFilterString(EmulatorSettings::GetInstance()->GetLogFilter());
filter.ParseFilterString(EmulatorSettings.GetLogFilter());
const auto& log_file_path = log_file.empty() ? LOG_FILE : log_file;
instance = std::unique_ptr<Impl, decltype(&Deleter)>(
new Impl(log_dir / log_file_path, filter), Deleter);
@ -186,7 +186,7 @@ public:
void PushEntry(Class log_class, Level log_level, const char* filename, unsigned int line_num,
const char* function, const char* format, const fmt::format_args& args) {
if (!filter.CheckMessage(log_class, log_level) ||
!EmulatorSettings::GetInstance()->IsLogEnabled()) {
!EmulatorSettings.IsLogEnabled()) {
return;
}
@ -214,7 +214,7 @@ public:
using std::chrono::microseconds;
using std::chrono::steady_clock;
if (EmulatorSettings::GetInstance()->IsIdenticalLogGrouped()) {
if (EmulatorSettings.IsIdenticalLogGrouped()) {
std::unique_lock entry_loc(_mutex);
if (_last_entry.message == message) {
@ -227,7 +227,7 @@ public:
}
if (_last_entry.counter >= 1) {
if (EmulatorSettings::GetInstance()->GetLogType() == "async") {
if (EmulatorSettings.GetLogType() == "async") {
message_queue.EmplaceWait(_last_entry);
} else {
ForEachBackend([this](auto& backend) { backend.Write(this->_last_entry); });
@ -259,7 +259,7 @@ public:
.counter = 1,
};
if (EmulatorSettings::GetInstance()->GetLogType() == "async") {
if (EmulatorSettings.GetLogType() == "async") {
message_queue.EmplaceWait(entry);
} else {
ForEachBackend([&entry](auto& backend) { backend.Write(entry); });
@ -297,14 +297,14 @@ private:
}
void StopBackendThread() {
if (EmulatorSettings::GetInstance()->IsIdenticalLogGrouped()) {
if (EmulatorSettings.IsIdenticalLogGrouped()) {
// log last message
if (_last_entry.counter >= 2) {
_last_entry.message += " x" + std::to_string(_last_entry.counter);
}
if (_last_entry.counter >= 1) {
if (EmulatorSettings::GetInstance()->GetLogType() == "async") {
if (EmulatorSettings.GetLogType() == "async") {
message_queue.EmplaceWait(_last_entry);
} else {
ForEachBackend([this](auto& backend) { backend.Write(this->_last_entry); });

View File

@ -187,7 +187,7 @@ struct AddressSpace::Impl {
user_size = supported_user_max - USER_MIN - 1;
// Increase BackingSize to account for config options.
BackingSize += EmulatorSettings::GetInstance()->GetExtraDmemInMBytes() * 1_MB;
BackingSize += EmulatorSettings.GetExtraDmemInMBytes() * 1_MB;
// Allocate backing file that represents the total physical memory.
backing_handle = CreateFileMapping2(INVALID_HANDLE_VALUE, nullptr, FILE_MAP_ALL_ACCESS,
@ -606,7 +606,7 @@ enum PosixPageProtection {
struct AddressSpace::Impl {
Impl() {
BackingSize += EmulatorSettings::GetInstance()->GetExtraDmemInMBytes() * 1_MB;
BackingSize += EmulatorSettings.GetExtraDmemInMBytes() * 1_MB;
// Allocate virtual address placeholder for our address space.
system_managed_size = SystemManagedSize;
system_reserved_size = SystemReservedSize;

View File

@ -110,11 +110,11 @@ void L::DrawMenuBar() {
EndDisabled();
if (Button("Save")) {
EmulatorSettings::GetInstance()->SetFsrEnabled(fsr.enable);
EmulatorSettings::GetInstance()->SetRcasEnabled(fsr.use_rcas);
EmulatorSettings::GetInstance()->SetRcasAttenuation(
EmulatorSettings.SetFsrEnabled(fsr.enable);
EmulatorSettings.SetRcasEnabled(fsr.use_rcas);
EmulatorSettings.SetRcasAttenuation(
static_cast<int>(fsr.rcas_attenuation * 1000));
EmulatorSettings::GetInstance()->Save();
EmulatorSettings.Save();
CloseCurrentPopup();
}
@ -311,7 +311,7 @@ static void LoadSettings(const char* line) {
void L::SetupSettings() {
frame_graph.is_open = true;
show_simple_fps = EmulatorSettings::GetInstance()->IsShowFpsCounter();
show_simple_fps = EmulatorSettings.IsShowFpsCounter();
using SettingLoader = void (*)(const char*);
@ -472,7 +472,7 @@ void L::Draw() {
if (ImGui::Begin("Volume Window", &show_volume,
ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoDecoration |
ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDocking)) {
Text("Volume: %d", EmulatorSettings::GetInstance()->GetVolumeSlider());
Text("Volume: %d", EmulatorSettings.GetVolumeSlider());
}
End();
}

View File

@ -29,7 +29,7 @@ void FrameGraph::DrawFrameGraph() {
return;
}
float target_dt = 1.0f / (float)EmulatorSettings::GetInstance()->GetVblankFrequency();
float target_dt = 1.0f / (float)EmulatorSettings.GetVblankFrequency();
float cur_pos_x = pos.x + full_width;
pos.y += FRAME_GRAPH_PADDING_Y;
const float final_pos_y = pos.y + FRAME_GRAPH_HEIGHT;

View File

@ -23,7 +23,7 @@ public:
bool open = false;
static bool IsSystemModule(const std::filesystem::path& path) {
const auto sys_modules_path = EmulatorSettings::GetInstance()->GetSysModulesDir();
const auto sys_modules_path = EmulatorSettings.GetSysModulesDir();
const auto abs_path = std::filesystem::absolute(path).lexically_normal();
const auto abs_sys_path = std::filesystem::absolute(sys_modules_path).lexically_normal();

View File

@ -244,7 +244,7 @@ void ShaderList::Draw() {
return;
}
if (!EmulatorSettings::GetInstance()->IsShaderCollect()) {
if (!EmulatorSettings.IsShaderCollect()) {
DrawCenteredText("Enable 'shader_dump' in config to see shaders");
End();
return;

View File

@ -16,8 +16,8 @@
using json = nlohmann::json;
// ── Singleton storage ─────────────────────────────────────────────────
std::shared_ptr<EmulatorSettings> EmulatorSettings::s_instance = nullptr;
std::mutex EmulatorSettings::s_mutex;
std::shared_ptr<EmulatorSettingsImpl> EmulatorSettingsImpl::s_instance = nullptr;
std::mutex EmulatorSettingsImpl::s_mutex;
// ── nlohmann helpers for std::filesystem::path ───────────────────────
namespace nlohmann {
@ -34,7 +34,7 @@ struct adl_serializer<std::filesystem::path> {
// ── Helpers ───────────────────────────────────────────────────────────
void EmulatorSettings::PrintChangedSummary(const std::vector<std::string>& changed) {
void EmulatorSettingsImpl::PrintChangedSummary(const std::vector<std::string>& changed) {
if (changed.empty()) {
LOG_DEBUG(EmuSettings, "No game-specific overrides applied");
return;
@ -45,20 +45,20 @@ void EmulatorSettings::PrintChangedSummary(const std::vector<std::string>& chang
}
// ── Singleton ────────────────────────────────────────────────────────
EmulatorSettings::EmulatorSettings() = default;
EmulatorSettingsImpl::EmulatorSettingsImpl() = default;
EmulatorSettings::~EmulatorSettings() {
EmulatorSettingsImpl::~EmulatorSettingsImpl() {
Save();
}
std::shared_ptr<EmulatorSettings> EmulatorSettings::GetInstance() {
std::shared_ptr<EmulatorSettingsImpl> EmulatorSettingsImpl::GetInstance() {
std::lock_guard lock(s_mutex);
if (!s_instance)
s_instance = std::make_shared<EmulatorSettings>();
s_instance = std::make_shared<EmulatorSettingsImpl>();
return s_instance;
}
void EmulatorSettings::SetInstance(std::shared_ptr<EmulatorSettings> instance) {
void EmulatorSettingsImpl::SetInstance(std::shared_ptr<EmulatorSettingsImpl> instance) {
std::lock_guard lock(s_mutex);
s_instance = std::move(instance);
}
@ -66,7 +66,7 @@ void EmulatorSettings::SetInstance(std::shared_ptr<EmulatorSettings> instance) {
// --------------------
// General helpers
// --------------------
bool EmulatorSettings::AddGameInstallDir(const std::filesystem::path& dir, bool enabled) {
bool EmulatorSettingsImpl::AddGameInstallDir(const std::filesystem::path& dir, bool enabled) {
for (const auto& d : m_general.install_dirs.value)
if (d.path == dir)
return false;
@ -74,7 +74,7 @@ bool EmulatorSettings::AddGameInstallDir(const std::filesystem::path& dir, bool
return true;
}
std::vector<std::filesystem::path> EmulatorSettings::GetGameInstallDirs() const {
std::vector<std::filesystem::path> EmulatorSettingsImpl::GetGameInstallDirs() const {
std::vector<std::filesystem::path> out;
for (const auto& d : m_general.install_dirs.value)
if (d.enabled)
@ -82,15 +82,15 @@ std::vector<std::filesystem::path> EmulatorSettings::GetGameInstallDirs() const
return out;
}
const std::vector<GameInstallDir>& EmulatorSettings::GetAllGameInstallDirs() const {
const std::vector<GameInstallDir>& EmulatorSettingsImpl::GetAllGameInstallDirs() const {
return m_general.install_dirs.value;
}
void EmulatorSettings::SetAllGameInstallDirs(const std::vector<GameInstallDir>& dirs) {
void EmulatorSettingsImpl::SetAllGameInstallDirs(const std::vector<GameInstallDir>& dirs) {
m_general.install_dirs.value = dirs;
}
void EmulatorSettings::RemoveGameInstallDir(const std::filesystem::path& dir) {
void EmulatorSettingsImpl::RemoveGameInstallDir(const std::filesystem::path& dir) {
auto iterator =
std::find_if(m_general.install_dirs.value.begin(), m_general.install_dirs.value.end(),
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
@ -99,7 +99,7 @@ void EmulatorSettings::RemoveGameInstallDir(const std::filesystem::path& dir) {
}
}
void EmulatorSettings::SetGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) {
void EmulatorSettingsImpl::SetGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled) {
auto iterator =
std::find_if(m_general.install_dirs.value.begin(), m_general.install_dirs.value.end(),
[&dir](const GameInstallDir& install_dir) { return install_dir.path == dir; });
@ -108,14 +108,14 @@ void EmulatorSettings::SetGameInstallDirEnabled(const std::filesystem::path& dir
}
}
void EmulatorSettings::SetGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
void EmulatorSettingsImpl::SetGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
m_general.install_dirs.value.clear();
for (const auto& dir : dirs_config) {
m_general.install_dirs.value.push_back({dir, true});
}
}
const std::vector<bool> EmulatorSettings::GetGameInstallDirsEnabled() {
const std::vector<bool> EmulatorSettingsImpl::GetGameInstallDirsEnabled() {
std::vector<bool> enabled_dirs;
for (const auto& dir : m_general.install_dirs.value) {
enabled_dirs.push_back(dir.enabled);
@ -123,41 +123,41 @@ const std::vector<bool> EmulatorSettings::GetGameInstallDirsEnabled() {
return enabled_dirs;
}
std::filesystem::path EmulatorSettings::GetHomeDir() {
std::filesystem::path EmulatorSettingsImpl::GetHomeDir() {
if (m_general.home_dir.value.empty()) {
return Common::FS::GetUserPath(Common::FS::PathType::HomeDir);
}
return m_general.home_dir.value;
}
void EmulatorSettings::SetHomeDir(const std::filesystem::path& dir) {
void EmulatorSettingsImpl::SetHomeDir(const std::filesystem::path& dir) {
m_general.home_dir.value = dir;
}
std::filesystem::path EmulatorSettings::GetSysModulesDir() {
std::filesystem::path EmulatorSettingsImpl::GetSysModulesDir() {
if (m_general.sys_modules_dir.value.empty()) {
return Common::FS::GetUserPath(Common::FS::PathType::SysModuleDir);
}
return m_general.sys_modules_dir.value;
}
void EmulatorSettings::SetSysModulesDir(const std::filesystem::path& dir) {
void EmulatorSettingsImpl::SetSysModulesDir(const std::filesystem::path& dir) {
m_general.sys_modules_dir.value = dir;
}
std::filesystem::path EmulatorSettings::GetFontsDir() {
std::filesystem::path EmulatorSettingsImpl::GetFontsDir() {
if (m_general.font_dir.value.empty()) {
return Common::FS::GetUserPath(Common::FS::PathType::FontsDir);
}
return m_general.font_dir.value;
}
void EmulatorSettings::SetFontsDir(const std::filesystem::path& dir) {
void EmulatorSettingsImpl::SetFontsDir(const std::filesystem::path& dir) {
m_general.font_dir.value = dir;
}
// ── Game-specific override management ────────────────────────────────
void EmulatorSettings::ClearGameSpecificOverrides() {
void EmulatorSettingsImpl::ClearGameSpecificOverrides() {
ClearGroupOverrides(m_general);
ClearGroupOverrides(m_debug);
ClearGroupOverrides(m_input);
@ -167,7 +167,7 @@ void EmulatorSettings::ClearGameSpecificOverrides() {
LOG_DEBUG(EmuSettings, "All game-specific overrides cleared");
}
void EmulatorSettings::ResetGameSpecificValue(const std::string& key) {
void EmulatorSettingsImpl::ResetGameSpecificValue(const std::string& key) {
// Walk every overrideable group until we find the matching key.
auto tryGroup = [&key](auto& group) {
for (auto& item : group.GetOverrideableFields()) {
@ -193,7 +193,7 @@ void EmulatorSettings::ResetGameSpecificValue(const std::string& key) {
LOG_WARNING(EmuSettings, "ResetGameSpecificValue: key '{}' not found", key);
}
bool EmulatorSettings::Save(const std::string& serial) {
bool EmulatorSettingsImpl::Save(const std::string& serial) {
try {
if (!serial.empty()) {
const auto cfgDir = Common::FS::GetUserPath(Common::FS::PathType::CustomConfigs);
@ -264,7 +264,7 @@ bool EmulatorSettings::Save(const std::string& serial) {
// ── Load ──────────────────────────────────────────────────────────────
bool EmulatorSettings::Load(const std::string& serial) {
bool EmulatorSettingsImpl::Load(const std::string& serial) {
try {
if (serial.empty()) {
// ── Global config ──────────────────────────────────────────
@ -382,7 +382,7 @@ bool EmulatorSettings::Load(const std::string& serial) {
}
}
void EmulatorSettings::SetDefaultValues() {
void EmulatorSettingsImpl::SetDefaultValues() {
m_general = GeneralSettings{};
m_debug = DebugSettings{};
m_input = InputSettings{};
@ -391,7 +391,7 @@ void EmulatorSettings::SetDefaultValues() {
m_vulkan = VulkanSettings{};
}
std::vector<std::string> EmulatorSettings::GetAllOverrideableKeys() const {
std::vector<std::string> EmulatorSettingsImpl::GetAllOverrideableKeys() const {
std::vector<std::string> keys;
auto addGroup = [&keys](const auto& fields) {
for (const auto& item : fields)

View File

@ -15,6 +15,8 @@
#include "common/types.h"
#include "core/user_manager.h"
#define EmulatorSettings (*EmulatorSettingsImpl::GetInstance())
enum HideCursorState : int {
Never,
Idle,
@ -393,13 +395,13 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Users, default_user_id, user)
// -------------------------------
// Main manager
// -------------------------------
class EmulatorSettings {
class EmulatorSettingsImpl {
public:
EmulatorSettings();
~EmulatorSettings();
EmulatorSettingsImpl();
~EmulatorSettingsImpl();
static std::shared_ptr<EmulatorSettings> GetInstance();
static void SetInstance(std::shared_ptr<EmulatorSettings> instance);
static std::shared_ptr<EmulatorSettingsImpl> GetInstance();
static void SetInstance(std::shared_ptr<EmulatorSettingsImpl> instance);
bool Save(const std::string& serial = "");
bool Load(const std::string& serial = "");
@ -454,7 +456,7 @@ private:
UserManager m_userManager;
ConfigMode m_configMode{ConfigMode::Default};
static std::shared_ptr<EmulatorSettings> s_instance;
static std::shared_ptr<EmulatorSettingsImpl> s_instance;
static std::mutex s_mutex;
/// Apply overrideable fields from groupJson into group.game_specific_value.

View File

@ -153,7 +153,7 @@ void IPC::InputLoop() {
} else if (cmd == "ADJUST_VOLUME") {
int value = static_cast<int>(next_u64());
bool is_game_specific = next_u64() != 0;
EmulatorSettings::GetInstance()->SetVolumeSlider(value);
EmulatorSettings.SetVolumeSlider(value);
Libraries::AudioOut::AdjustVol();
} else if (cmd == "SET_FSR") {
bool use_fsr = next_u64() != 0;

View File

@ -57,7 +57,7 @@ int PS4_SYSV_ABI sceAppContentAddcontMount(u32 service_label,
OrbisAppContentMountPoint* mount_point) {
LOG_INFO(Lib_AppContent, "called");
const auto& addon_path = EmulatorSettings::GetInstance()->GetAddonInstallDir() / title_id;
const auto& addon_path = EmulatorSettings.GetAddonInstallDir() / title_id;
auto* mnt = Common::Singleton<Core::FileSys::MntPoints>::Instance();
// Determine which loaded additional content this entitlement label is for.
@ -282,7 +282,7 @@ int PS4_SYSV_ABI sceAppContentInitialize(const OrbisAppContentInitParam* initPar
LOG_ERROR(Lib_AppContent, "(DUMMY) called");
auto* param_sfo = Common::Singleton<PSF>::Instance();
const auto addons_dir = EmulatorSettings::GetInstance()->GetAddonInstallDir();
const auto addons_dir = EmulatorSettings.GetAddonInstallDir();
if (const auto value = param_sfo->GetString("TITLE_ID"); value.has_value()) {
title_id = *value;
} else {

View File

@ -21,7 +21,7 @@ public:
fmt.channels = static_cast<Uint8>(port.channels_num);
fmt.freq = static_cast<int>(port.freq);
std::string micDevStr = EmulatorSettings::GetInstance()->GetMicDevice();
std::string micDevStr = EmulatorSettings.GetMicDevice();
uint32_t devId = 0;
if (micDevStr == "None") {
nullDevice = true;

View File

@ -111,7 +111,7 @@ public:
}
const float slider_gain =
EmulatorSettings::GetInstance()->GetVolumeSlider() * 0.01f; // Faster than /100.0f
EmulatorSettings.GetVolumeSlider() * 0.01f; // Faster than /100.0f
const float total_gain = max_channel_gain * slider_gain;
const float current = current_gain.load(std::memory_order_acquire);
@ -157,7 +157,7 @@ private:
}
// Initialize current gain
current_gain.store(EmulatorSettings::GetInstance()->GetVolumeSlider() * 0.01f,
current_gain.store(EmulatorSettings.GetVolumeSlider() * 0.01f,
std::memory_order_relaxed);
if (!SelectConverter()) {
@ -203,7 +203,7 @@ private:
last_volume_check_time = current_time;
const float config_volume = EmulatorSettings::GetInstance()->GetVolumeSlider() * 0.01f;
const float config_volume = EmulatorSettings.GetVolumeSlider() * 0.01f;
const float stored_gain = current_gain.load(std::memory_order_acquire);
// Only update if the difference is significant
@ -370,11 +370,11 @@ private:
switch (type) {
case OrbisAudioOutPort::Main:
case OrbisAudioOutPort::Bgm:
return EmulatorSettings::GetInstance()->GetMainOutputDevice();
return EmulatorSettings.GetMainOutputDevice();
case OrbisAudioOutPort::PadSpk:
return EmulatorSettings::GetInstance()->GetPadSpkOutputDevice();
return EmulatorSettings.GetPadSpkOutputDevice();
default:
return EmulatorSettings::GetInstance()->GetMainOutputDevice();
return EmulatorSettings.GetMainOutputDevice();
}
}

View File

@ -2874,7 +2874,7 @@ void RegisterLib(Core::Loader::SymbolsResolver* sym) {
sdk_version = 0;
}
if (EmulatorSettings::GetInstance()->IsCopyGpuBuffers()) {
if (EmulatorSettings.IsCopyGpuBuffers()) {
liverpool->ReserveCopyBufferSpace();
}

View File

@ -17,19 +17,19 @@ s32 PS4_SYSV_ABI sceKernelIsInSandbox() {
}
s32 PS4_SYSV_ABI sceKernelIsNeoMode() {
return EmulatorSettings::GetInstance()->IsNeo() &&
return EmulatorSettings.IsNeo() &&
Common::ElfInfo::Instance().GetPSFAttributes().support_neo_mode;
}
s32 PS4_SYSV_ABI sceKernelHasNeoMode() {
return EmulatorSettings::GetInstance()->IsNeo();
return EmulatorSettings.IsNeo();
}
s32 PS4_SYSV_ABI sceKernelGetMainSocId() {
// These hardcoded values are based on hardware observations.
// Different models of PS4/PS4 Pro likely return slightly different values.
LOG_DEBUG(Lib_Kernel, "called");
if (EmulatorSettings::GetInstance()->IsNeo()) {
if (EmulatorSettings.IsNeo()) {
return 0x740f30;
}
return 0x710f10;

View File

@ -1447,7 +1447,7 @@ int PS4_SYSV_ABI sceNetResolverStartNtoa(OrbisNetId resolverid, const char* host
return ORBIS_NET_ERROR_EBADF;
}
if (!EmulatorSettings::GetInstance()->IsConnectedToNetwork()) {
if (!EmulatorSettings.IsConnectedToNetwork()) {
*sceNetErrnoLoc() = ORBIS_NET_RESOLVER_ENODNS;
file->resolver->resolution_error = ORBIS_NET_ERROR_RESOLVER_ENODNS;
return ORBIS_NET_ERROR_RESOLVER_ENODNS;

View File

@ -46,7 +46,7 @@ s32 NetCtlInternal::RegisterNpToolkitCallback(OrbisNetCtlCallbackForNpToolkit fu
void NetCtlInternal::CheckCallback() {
std::scoped_lock lock{m_mutex};
const auto event = EmulatorSettings::GetInstance()->IsConnectedToNetwork()
const auto event = EmulatorSettings.IsConnectedToNetwork()
? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED
: ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED;
for (const auto [func, arg] : callbacks) {
@ -58,7 +58,7 @@ void NetCtlInternal::CheckCallback() {
void NetCtlInternal::CheckNpToolkitCallback() {
std::scoped_lock lock{m_mutex};
const auto event = EmulatorSettings::GetInstance()->IsConnectedToNetwork()
const auto event = EmulatorSettings.IsConnectedToNetwork()
? ORBIS_NET_CTL_EVENT_TYPE_IPOBTAINED
: ORBIS_NET_CTL_EVENT_TYPE_DISCONNECTED;
for (const auto [func, arg] : nptool_callbacks) {

View File

@ -27,7 +27,7 @@ int Resolver::ResolveAsync(const char* hostname, OrbisNetInAddr* addr, int timeo
}
void Resolver::Resolve() {
if (!EmulatorSettings::GetInstance()->IsConnectedToNetwork()) {
if (!EmulatorSettings.IsConnectedToNetwork()) {
resolution_error = ORBIS_NET_ERROR_RESOLVER_ENODNS;
return;
}

View File

@ -162,7 +162,7 @@ int PS4_SYSV_ABI sceNetCtlGetIfStat() {
int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
LOG_DEBUG(Lib_NetCtl, "code = {}", code);
if (!EmulatorSettings::GetInstance()->IsConnectedToNetwork()) {
if (!EmulatorSettings.IsConnectedToNetwork()) {
return ORBIS_NET_CTL_ERROR_NOT_CONNECTED;
}
@ -180,7 +180,7 @@ int PS4_SYSV_ABI sceNetCtlGetInfo(int code, OrbisNetCtlInfo* info) {
info->mtu = 1500; // default value
break;
case ORBIS_NET_CTL_INFO_LINK:
info->link = EmulatorSettings::GetInstance()->IsConnectedToNetwork()
info->link = EmulatorSettings.IsConnectedToNetwork()
? ORBIS_NET_CTL_LINK_CONNECTED
: ORBIS_NET_CTL_LINK_DISCONNECTED;
break;
@ -319,7 +319,7 @@ int PS4_SYSV_ABI sceNetCtlGetScanInfoForSsidScanIpcInt() {
}
int PS4_SYSV_ABI sceNetCtlGetState(int* state) {
const auto connected = EmulatorSettings::GetInstance()->IsConnectedToNetwork();
const auto connected = EmulatorSettings.IsConnectedToNetwork();
LOG_DEBUG(Lib_NetCtl, "connected = {}", connected);
const auto current_state =
connected ? ORBIS_NET_CTL_STATE_IPOBTAINED : ORBIS_NET_CTL_STATE_DISCONNECTED;

View File

@ -363,7 +363,7 @@ s32 PS4_SYSV_ABI sceNpAuthDeleteRequest(s32 req_id) {
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
g_signed_in = EmulatorSettings::GetInstance()->IsPSNSignedIn();
g_signed_in = EmulatorSettings.IsPSNSignedIn();
LIB_FUNCTION("6bwFkosYRQg", "libSceNpAuth", 1, "libSceNpAuth", sceNpAuthCreateRequest);
LIB_FUNCTION("N+mr7GjTvr8", "libSceNpAuth", 1, "libSceNpAuth", sceNpAuthCreateAsyncRequest);

View File

@ -632,7 +632,7 @@ s32 PS4_SYSV_ABI sceNpGetNpId(Libraries::UserService::OrbisUserServiceUserId use
}
memset(np_id, 0, sizeof(OrbisNpId));
strncpy(np_id->handle.data,
EmulatorSettings::GetInstance()->GetUserManager().GetDefaultUser().user_name.c_str(),
UserManagement.GetDefaultUser().user_name.c_str(),
sizeof(np_id->handle.data));
return ORBIS_OK;
}
@ -648,7 +648,7 @@ s32 PS4_SYSV_ABI sceNpGetOnlineId(Libraries::UserService::OrbisUserServiceUserId
}
memset(online_id, 0, sizeof(OrbisNpOnlineId));
strncpy(online_id->data,
EmulatorSettings::GetInstance()->GetUserManager().GetDefaultUser().user_name.c_str(),
UserManagement.GetDefaultUser().user_name.c_str(),
sizeof(online_id->data));
return ORBIS_OK;
}
@ -788,7 +788,7 @@ void DeregisterNpCallback(std::string key) {
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
g_signed_in = EmulatorSettings::GetInstance()->IsPSNSignedIn();
g_signed_in = EmulatorSettings.IsPSNSignedIn();
LIB_FUNCTION("GpLQDNKICac", "libSceNpManager", 1, "libSceNpManager", sceNpCreateRequest);
LIB_FUNCTION("eiqMCt9UshI", "libSceNpManager", 1, "libSceNpManager", sceNpCreateAsyncRequest);

View File

@ -376,8 +376,8 @@ int PS4_SYSV_ABI sceNpMatching2ContextStart(OrbisNpMatching2ContextId ctxId, u64
}
std::scoped_lock lk{g_events_mutex};
if (EmulatorSettings::GetInstance()->IsConnectedToNetwork() &&
EmulatorSettings::GetInstance()->IsPSNSignedIn()) {
if (EmulatorSettings.IsConnectedToNetwork() &&
EmulatorSettings.IsPSNSignedIn()) {
g_ctx_events.emplace_back(ctxId, ORBIS_NP_MATCHING2_CONTEXT_EVENT_STARTED,
ORBIS_NP_MATCHING2_EVENT_CAUSE_CONTEXT_ACTION, 0);
} else {

View File

@ -207,7 +207,7 @@ s32 PS4_SYSV_ABI sceNpWebApi2SendMultipartRequest() {
}
s32 PS4_SYSV_ABI sceNpWebApi2SendRequest() {
if (!EmulatorSettings::GetInstance()->IsPSNSignedIn()) {
if (!EmulatorSettings.IsPSNSignedIn()) {
LOG_INFO(Lib_NpWebApi2, "called, returning PSN signed out.");
return ORBIS_NP_WEBAPI2_ERROR_NOT_SIGNED_IN;
}

View File

@ -606,7 +606,7 @@ s32 sendRequest(s64 requestId, s32 partIndex, const void* pData, u64 dataSize, s
unlockContext(context);
// Stubbing sceNpManagerIntGetSigninState call with a config check.
if (!EmulatorSettings::GetInstance()->IsPSNSignedIn()) {
if (!EmulatorSettings.IsPSNSignedIn()) {
releaseRequest(request);
releaseUserContext(user_context);
releaseContext(context);
@ -1025,7 +1025,7 @@ s32 createServicePushEventFilterInternal(
auto& handle = context->handles[handleId];
handle->userCount++;
if (pNpServiceName != nullptr && !EmulatorSettings::GetInstance()->IsPSNSignedIn()) {
if (pNpServiceName != nullptr && !EmulatorSettings.IsPSNSignedIn()) {
// Seems sceNpManagerIntGetUserList fails?
LOG_DEBUG(Lib_NpWebApi, "Cannot create service push event while PSN is disabled");
handle->userCount--;
@ -1202,7 +1202,7 @@ s32 createExtendedPushEventFilterInternal(
auto& handle = context->handles[handleId];
handle->userCount++;
if (pNpServiceName != nullptr && !EmulatorSettings::GetInstance()->IsPSNSignedIn()) {
if (pNpServiceName != nullptr && !EmulatorSettings.IsPSNSignedIn()) {
// Seems sceNpManagerIntGetUserList fails?
LOG_DEBUG(Lib_NpWebApi, "Cannot create extended push event while PSN is disabled");
handle->userCount--;

View File

@ -31,9 +31,9 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin
const std::string_view& rarity)
: trophy_name(trophyName), trophy_type(rarity) {
side = EmulatorSettings::GetInstance()->GetTrophyNotificationSide();
side = EmulatorSettings.GetTrophyNotificationSide();
trophy_timer = EmulatorSettings::GetInstance()->GetTrophyNotificationDuration();
trophy_timer = EmulatorSettings.GetTrophyNotificationDuration();
if (std::filesystem::exists(trophyIconPath)) {
trophy_icon = RefCountedTexture::DecodePngFile(trophyIconPath);
@ -94,7 +94,7 @@ TrophyUI::TrophyUI(const std::filesystem::path& trophyIconPath, const std::strin
}
MIX_SetMasterGain(
mixer, static_cast<float>(EmulatorSettings::GetInstance()->GetVolumeSlider() / 100.f));
mixer, static_cast<float>(EmulatorSettings.GetVolumeSlider() / 100.f));
auto musicPathMp3 = CustomTrophy_Dir / "trophy.mp3";
auto musicPathWav = CustomTrophy_Dir / "trophy.wav";
@ -280,7 +280,7 @@ void AddTrophyToQueue(const std::filesystem::path& trophyIconPath, const std::st
const std::string_view& rarity) {
std::lock_guard<std::mutex> lock(queueMtx);
if (EmulatorSettings::GetInstance()->IsTrophyPopupDisabled()) {
if (EmulatorSettings.IsTrophyPopupDisabled()) {
return;
} else if (current_trophy_ui.has_value()) {
current_trophy_ui.reset();

View File

@ -31,9 +31,9 @@ int PS4_SYSV_ABI scePadDeviceClassGetExtendedInformation(
s32 handle, OrbisPadDeviceClassExtendedInformation* pExtInfo) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
std::memset(pExtInfo, 0, sizeof(OrbisPadDeviceClassExtendedInformation));
if (EmulatorSettings::GetInstance()->IsUsingSpecialPad()) {
if (EmulatorSettings.IsUsingSpecialPad()) {
pExtInfo->deviceClass =
(OrbisPadDeviceClass)EmulatorSettings::GetInstance()->GetSpecialPadClass();
(OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
}
return ORBIS_OK;
}
@ -109,10 +109,10 @@ int PS4_SYSV_ABI scePadGetControllerInformation(s32 handle, OrbisPadControllerIn
return ORBIS_OK;
}
pInfo->connected = true;
if (EmulatorSettings::GetInstance()->IsUsingSpecialPad()) {
if (EmulatorSettings.IsUsingSpecialPad()) {
pInfo->connectionType = ORBIS_PAD_PORT_TYPE_SPECIAL;
pInfo->deviceClass =
(OrbisPadDeviceClass)EmulatorSettings::GetInstance()->GetSpecialPadClass();
(OrbisPadDeviceClass)EmulatorSettings.GetSpecialPadClass();
}
return ORBIS_OK;
}
@ -260,7 +260,7 @@ int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId userI
if (userId == -1) {
return ORBIS_PAD_ERROR_DEVICE_NO_HANDLE;
}
if (EmulatorSettings::GetInstance()->IsUsingSpecialPad()) {
if (EmulatorSettings.IsUsingSpecialPad()) {
if (type != ORBIS_PAD_PORT_TYPE_SPECIAL)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
} else {
@ -277,7 +277,7 @@ int PS4_SYSV_ABI scePadOpen(Libraries::UserService::OrbisUserServiceUserId userI
int PS4_SYSV_ABI scePadOpenExt(Libraries::UserService::OrbisUserServiceUserId userId, s32 type,
s32 index, const OrbisPadOpenExtParam* pParam) {
LOG_ERROR(Lib_Pad, "(STUBBED) called");
if (EmulatorSettings::GetInstance()->IsUsingSpecialPad()) {
if (EmulatorSettings.IsUsingSpecialPad()) {
if (type != ORBIS_PAD_PORT_TYPE_SPECIAL)
return ORBIS_PAD_ERROR_DEVICE_NOT_CONNECTED;
} else {

View File

@ -48,13 +48,13 @@ namespace Libraries::SaveData {
fs::path SaveInstance::MakeTitleSavePath(Libraries::UserService::OrbisUserServiceUserId user_id,
std::string_view game_serial) {
return EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user_id) / "savedata" /
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" /
game_serial;
}
fs::path SaveInstance::MakeDirSavePath(OrbisUserServiceUserId user_id, std::string_view game_serial,
std::string_view dir_name) {
return EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user_id) / "savedata" /
return EmulatorSettings.GetHomeDir() / std::to_string(user_id) / "savedata" /
game_serial / dir_name;
}
@ -73,7 +73,7 @@ fs::path SaveInstance::GetParamSFOPath(const fs::path& dir_path) {
void SaveInstance::SetupDefaultParamSFO(PSF& param_sfo, std::string dir_name,
std::string game_serial) {
int locale = EmulatorSettings::GetInstance()->GetConsoleLanguage();
int locale = EmulatorSettings.GetConsoleLanguage();
if (!default_title.contains(locale)) {
locale = 1; // default to en_US if not found
}

View File

@ -439,7 +439,7 @@ static Error saveDataMount(const OrbisSaveDataMount2* mount_info,
LOG_INFO(Lib_SaveData, "called with invalid block size");
}
const auto root_save = EmulatorSettings::GetInstance()->GetHomeDir() /
const auto root_save = EmulatorSettings.GetHomeDir() /
std::to_string(mount_info->userId) / "savedata";
fs::create_directories(root_save);
const auto available = fs::space(root_save).available;

View File

@ -18,7 +18,7 @@ std::queue<OrbisSystemServiceEvent> g_event_queue;
std::mutex g_event_queue_mutex;
bool IsSplashVisible() {
return EmulatorSettings::GetInstance()->IsShowSplash() && g_splash_status;
return EmulatorSettings.IsShowSplash() && g_splash_status;
}
int PS4_SYSV_ABI sceAppMessagingClearEventFlag() {
@ -1918,7 +1918,7 @@ s32 PS4_SYSV_ABI sceSystemServiceParamGetInt(OrbisSystemServiceParamId param_id,
}
switch (param_id) {
case OrbisSystemServiceParamId::Lang:
*value = EmulatorSettings::GetInstance()->GetConsoleLanguage();
*value = EmulatorSettings.GetConsoleLanguage();
break;
case OrbisSystemServiceParamId::DateFormat:
*value = u32(OrbisSystemParamDateFormat::FmtDDMMYYYY);

View File

@ -509,7 +509,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetInitialUser(int* user_id) {
LOG_ERROR(Lib_UserService, "user_id is null");
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
*user_id = EmulatorSettings::GetInstance()->GetUserManager().GetDefaultUser().user_id;
*user_id = UserManagement.GetDefaultUser().user_id;
return ORBIS_OK;
}
@ -589,7 +589,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetLoginUserIdList(OrbisUserServiceLoginUserIdLis
userIdList->user_id[i] = ORBIS_USER_SERVICE_USER_ID_INVALID;
}
auto& user_manager = EmulatorSettings::GetInstance()->GetUserManager();
auto& user_manager = UserManagement;
std::vector<User> all_users = user_manager.GetValidUsers();
@ -1084,7 +1084,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserColor(int user_id, OrbisUserServiceUserCol
LOG_ERROR(Lib_UserService, "color is null");
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
*color = (OrbisUserServiceUserColor)EmulatorSettings::GetInstance()
*color = (OrbisUserServiceUserColor)EmulatorSettingsImpl::GetInstance()
->GetUserManager()
.GetUserByID(user_id)
->user_color;
@ -1113,7 +1113,7 @@ s32 PS4_SYSV_ABI sceUserServiceGetUserName(int user_id, char* user_name, std::si
return ORBIS_USER_SERVICE_ERROR_INVALID_ARGUMENT;
}
std::string name = "shadPS4";
auto const* u = EmulatorSettings::GetInstance()->GetUserManager().GetUserByID(user_id);
auto const* u = UserManagement.GetUserByID(user_id);
if (u != nullptr) {
name = u->user_name;
} else {

View File

@ -457,7 +457,7 @@ int PS4_SYSV_ABI Func_D56B43060720B1E0() {
}
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
switch (EmulatorSettings::GetInstance()->GetUsbDeviceBackend()) {
switch (EmulatorSettings.GetUsbDeviceBackend()) {
case UsbBackendType::SkylandersPortal:
usb_backend = std::make_shared<SkylandersPortalBackend>();
break;

View File

@ -269,7 +269,7 @@ void VideoOutDriver::SubmitFlipInternal(VideoOutPort* port, s32 index, s64 flip_
void VideoOutDriver::PresentThread(std::stop_token token) {
const std::chrono::nanoseconds vblank_period(
1000000000 / EmulatorSettings::GetInstance()->GetVblankFrequency());
1000000000 / EmulatorSettings.GetVblankFrequency());
Common::SetCurrentThreadName("shadPS4:PresentThread");
Common::SetCurrentThreadRealtime(vblank_period);

View File

@ -456,8 +456,8 @@ s32 PS4_SYSV_ABI sceVideoOutSetWindowModeMargins(s32 handle, s32 top, s32 bottom
void RegisterLib(Core::Loader::SymbolsResolver* sym) {
driver = std::make_unique<VideoOutDriver>(
EmulatorSettings::GetInstance()->GetInternalScreenWidth(),
EmulatorSettings::GetInstance()->GetInternalScreenHeight());
EmulatorSettings.GetInternalScreenWidth(),
EmulatorSettings.GetInternalScreenHeight());
LIB_FUNCTION("SbU3dwp80lQ", "libSceVideoOut", 1, "libSceVideoOut", sceVideoOutGetFlipStatus);
LIB_FUNCTION("U46NwOiJpys", "libSceVideoOut", 1, "libSceVideoOut", sceVideoOutSubmitFlip);

View File

@ -56,7 +56,7 @@ Linker::Linker() : memory{Memory::Instance()} {}
Linker::~Linker() = default;
void Linker::Execute(const std::vector<std::string>& args) {
if (EmulatorSettings::GetInstance()->IsDebugDump()) {
if (EmulatorSettings.IsDebugDump()) {
DebugDump();
}

View File

@ -37,10 +37,10 @@ void MemoryManager::SetupMemoryRegions(u64 flexible_size, bool use_extended_mem1
bool use_extended_mem2) {
const bool is_neo = ::Libraries::Kernel::sceKernelIsNeoMode();
auto total_size = is_neo ? ORBIS_KERNEL_TOTAL_MEM_PRO : ORBIS_KERNEL_TOTAL_MEM;
if (EmulatorSettings::GetInstance()->IsDevKit()) {
if (EmulatorSettings.IsDevKit()) {
total_size = is_neo ? ORBIS_KERNEL_TOTAL_MEM_DEV_PRO : ORBIS_KERNEL_TOTAL_MEM_DEV;
}
s32 extra_dmem = EmulatorSettings::GetInstance()->GetExtraDmemInMBytes();
s32 extra_dmem = EmulatorSettings.GetExtraDmemInMBytes();
if (extra_dmem != 0) {
LOG_WARNING(Kernel_Vmm,
"extraDmemInMbytes is {} MB! Old Direct Size: {:#x} -> New Direct Size: {:#x}",

View File

@ -166,7 +166,7 @@ public:
}
bool IsSystemLib() {
auto system_path = EmulatorSettings::GetInstance()->GetSysModulesDir();
auto system_path = EmulatorSettings.GetSysModulesDir();
if (file.string().starts_with(system_path.string().c_str())) {
return true;
}

View File

@ -17,7 +17,7 @@ bool UserManager::AddUser(const User& user) {
// Create user home directory and subfolders
const auto user_dir =
EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user.user_id);
EmulatorSettings.GetHomeDir() / std::to_string(user.user_id);
std::error_code ec;
if (!std::filesystem::exists(user_dir)) {
@ -36,7 +36,7 @@ bool UserManager::RemoveUser(s32 user_id) {
if (it == m_users.user.end())
return false; // not found
const auto user_dir = EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(user_id);
const auto user_dir = EmulatorSettings.GetHomeDir() / std::to_string(user_id);
if (std::filesystem::exists(user_dir)) {
std::error_code ec;
@ -81,7 +81,7 @@ std::vector<User> UserManager::CreateDefaultUser() {
default_user.controller_port = 1;
const auto user_dir =
EmulatorSettings::GetInstance()->GetHomeDir() / std::to_string(default_user.user_id);
EmulatorSettings.GetHomeDir() / std::to_string(default_user.user_id);
if (!std::filesystem::exists(user_dir)) {
std::filesystem::create_directory(user_dir);
@ -121,7 +121,7 @@ std::vector<User> UserManager::GetValidUsers() const {
std::vector<User> result;
result.reserve(m_users.user.size());
const auto home_dir = EmulatorSettings::GetInstance()->GetHomeDir();
const auto home_dir = EmulatorSettings.GetHomeDir();
for (const auto& user : m_users.user) {
const auto user_dir = home_dir / std::to_string(user.user_id);

View File

@ -7,6 +7,8 @@
#include <vector>
#include "common/types.h"
#define UserManagement EmulatorSettings.GetUserManager()
struct User {
s32 user_id;
u32 user_color;

View File

@ -205,10 +205,10 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
game_info.game_folder = game_folder;
EmulatorSettings::GetInstance()->Load(id);
EmulatorSettings.Load(id);
// Initialize logging as soon as possible
if (!id.empty() && EmulatorSettings::GetInstance()->IsSeparateLoggingEnabled()) {
if (!id.empty() && EmulatorSettings.IsSeparateLoggingEnabled()) {
Common::Log::Initialize(id + ".log");
} else {
Common::Log::Initialize();
@ -229,46 +229,32 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
LOG_INFO(Config, "Game-specific config used: {}",
EmulatorState::GetInstance()->IsGameSpecifigConfigUsed());
LOG_INFO(Config, "General LogType: {}", EmulatorSettings::GetInstance()->GetLogType());
LOG_INFO(Config, "General isIdenticalLogGrouped: {}",
EmulatorSettings::GetInstance()->IsIdenticalLogGrouped());
LOG_INFO(Config, "General isNeo: {}", EmulatorSettings::GetInstance()->IsNeo());
LOG_INFO(Config, "General isDevKit: {}", EmulatorSettings::GetInstance()->IsDevKit());
LOG_INFO(Config, "General isConnectedToNetwork: {}",
EmulatorSettings::GetInstance()->IsConnectedToNetwork());
LOG_INFO(Config, "General isPsnSignedIn: {}", EmulatorSettings::GetInstance()->IsPSNSignedIn());
LOG_INFO(Config, "GPU isNullGpu: {}", EmulatorSettings::GetInstance()->IsNullGPU());
LOG_INFO(Config, "GPU readbacksMode: {}", EmulatorSettings::GetInstance()->GetReadbacksMode());
LOG_INFO(Config, "General LogType: {}", EmulatorSettings.GetLogType());
LOG_INFO(Config, "General isIdenticalLogGrouped: {}", EmulatorSettings.IsIdenticalLogGrouped());
LOG_INFO(Config, "General isNeo: {}", EmulatorSettings.IsNeo());
LOG_INFO(Config, "General isDevKit: {}", EmulatorSettings.IsDevKit());
LOG_INFO(Config, "General isConnectedToNetwork: {}", EmulatorSettings.IsConnectedToNetwork());
LOG_INFO(Config, "General isPsnSignedIn: {}", EmulatorSettings.IsPSNSignedIn());
LOG_INFO(Config, "GPU isNullGpu: {}", EmulatorSettings.IsNullGPU());
LOG_INFO(Config, "GPU readbacksMode: {}", EmulatorSettings.GetReadbacksMode());
LOG_INFO(Config, "GPU readbackLinearImages: {}",
EmulatorSettings::GetInstance()->IsReadbackLinearImagesEnabled());
LOG_INFO(Config, "GPU directMemoryAccess: {}",
EmulatorSettings::GetInstance()->IsDirectMemoryAccessEnabled());
LOG_INFO(Config, "GPU shouldDumpShaders: {}", EmulatorSettings::GetInstance()->IsDumpShaders());
LOG_INFO(Config, "GPU vblankFrequency: {}",
EmulatorSettings::GetInstance()->GetVblankFrequency());
LOG_INFO(Config, "GPU shouldCopyGPUBuffers: {}",
EmulatorSettings::GetInstance()->IsCopyGpuBuffers());
LOG_INFO(Config, "Vulkan gpuId: {}", EmulatorSettings::GetInstance()->GetGpuId());
LOG_INFO(Config, "Vulkan vkValidation: {}",
EmulatorSettings::GetInstance()->IsVkValidationEnabled());
LOG_INFO(Config, "Vulkan vkValidationCore: {}",
EmulatorSettings::GetInstance()->IsVkValidationCoreEnabled());
LOG_INFO(Config, "Vulkan vkValidationSync: {}",
EmulatorSettings::GetInstance()->IsVkValidationSyncEnabled());
LOG_INFO(Config, "Vulkan vkValidationGpu: {}",
EmulatorSettings::GetInstance()->IsVkValidationGpuEnabled());
LOG_INFO(Config, "Vulkan crashDiagnostics: {}",
EmulatorSettings::GetInstance()->IsVkCrashDiagnosticEnabled());
LOG_INFO(Config, "Vulkan hostMarkers: {}",
EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled());
LOG_INFO(Config, "Vulkan guestMarkers: {}",
EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled());
LOG_INFO(Config, "Vulkan rdocEnable: {}",
EmulatorSettings::GetInstance()->IsRenderdocEnabled());
LOG_INFO(Config, "Vulkan PipelineCacheEnabled: {}",
EmulatorSettings::GetInstance()->IsPipelineCacheEnabled());
EmulatorSettings.IsReadbackLinearImagesEnabled());
LOG_INFO(Config, "GPU directMemoryAccess: {}", EmulatorSettings.IsDirectMemoryAccessEnabled());
LOG_INFO(Config, "GPU shouldDumpShaders: {}", EmulatorSettings.IsDumpShaders());
LOG_INFO(Config, "GPU vblankFrequency: {}", EmulatorSettings.GetVblankFrequency());
LOG_INFO(Config, "GPU shouldCopyGPUBuffers: {}", EmulatorSettings.IsCopyGpuBuffers());
LOG_INFO(Config, "Vulkan gpuId: {}", EmulatorSettings.GetGpuId());
LOG_INFO(Config, "Vulkan vkValidation: {}", EmulatorSettings.IsVkValidationEnabled());
LOG_INFO(Config, "Vulkan vkValidationCore: {}", EmulatorSettings.IsVkValidationCoreEnabled());
LOG_INFO(Config, "Vulkan vkValidationSync: {}", EmulatorSettings.IsVkValidationSyncEnabled());
LOG_INFO(Config, "Vulkan vkValidationGpu: {}", EmulatorSettings.IsVkValidationGpuEnabled());
LOG_INFO(Config, "Vulkan crashDiagnostics: {}", EmulatorSettings.IsVkCrashDiagnosticEnabled());
LOG_INFO(Config, "Vulkan hostMarkers: {}", EmulatorSettings.IsVkHostMarkersEnabled());
LOG_INFO(Config, "Vulkan guestMarkers: {}", EmulatorSettings.IsVkGuestMarkersEnabled());
LOG_INFO(Config, "Vulkan rdocEnable: {}", EmulatorSettings.IsRenderdocEnabled());
LOG_INFO(Config, "Vulkan PipelineCacheEnabled: {}", EmulatorSettings.IsPipelineCacheEnabled());
LOG_INFO(Config, "Vulkan PipelineCacheArchived: {}",
EmulatorSettings::GetInstance()->IsPipelineCacheArchived());
EmulatorSettings.IsPipelineCacheArchived());
hwinfo::Memory ram;
hwinfo::OS os;
@ -345,9 +331,9 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
Common::g_scm_branch, Common::g_scm_desc, game_title);
}
}
window = std::make_unique<Frontend::WindowSDL>(
EmulatorSettings::GetInstance()->GetWindowWidth(),
EmulatorSettings::GetInstance()->GetWindowHeight(), controllers, window_title);
window = std::make_unique<Frontend::WindowSDL>(EmulatorSettings.GetWindowWidth(),
EmulatorSettings.GetWindowHeight(), controllers,
window_title);
g_window = window.get();
@ -378,7 +364,7 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
VideoCore::SetOutputDir(mount_captures_dir, id);
// Mount system fonts
const auto& fonts_dir = EmulatorSettings::GetInstance()->GetFontsDir();
const auto& fonts_dir = EmulatorSettings.GetFontsDir();
if (!std::filesystem::exists(fonts_dir)) {
std::filesystem::create_directory(fonts_dir);
}
@ -428,7 +414,7 @@ void Emulator::Run(std::filesystem::path file, std::vector<std::string> args,
#ifdef ENABLE_DISCORD_RPC
// Discord RPC
if (EmulatorSettings::GetInstance()->IsDiscordRPCEnabled()) {
if (EmulatorSettings.IsDiscordRPCEnabled()) {
auto* rpc = Common::Singleton<DiscordRPCHandler::RPC>::Instance();
if (rpc->getRPCEnabled() == false) {
rpc->init();
@ -584,7 +570,7 @@ void Emulator::LoadSystemModules(const std::string& game_serial) {
{"libSceFreeTypeOt.sprx", nullptr}});
std::vector<std::filesystem::path> found_modules;
const auto& sys_module_path = EmulatorSettings::GetInstance()->GetSysModulesDir();
const auto& sys_module_path = EmulatorSettings.GetSysModulesDir();
for (const auto& entry : std::filesystem::directory_iterator(sys_module_path)) {
found_modules.push_back(entry.path());
}

View File

@ -218,7 +218,7 @@ void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view,
if (draw_data->CmdListsCount == 0) {
return;
}
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
.pLabelName = "ImGui Render",
});
@ -243,7 +243,7 @@ void Render(const vk::CommandBuffer& cmdbuf, const vk::ImageView& image_view,
cmdbuf.beginRendering(render_info);
Vulkan::RenderDrawData(*draw_data, cmdbuf);
cmdbuf.endRendering();
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.endDebugUtilsLabelEXT();
}
}

View File

@ -396,7 +396,7 @@ bool ProcessEvent(const SDL_Event* event) {
if (mouse_pos.x != bd->prev_mouse_pos.x || mouse_pos.y != bd->prev_mouse_pos.y) {
bd->prev_mouse_pos.x = mouse_pos.x;
bd->prev_mouse_pos.y = mouse_pos.y;
if (EmulatorSettings::GetInstance()->GetCursorState() == HideCursorState::Idle) {
if (EmulatorSettings.GetCursorState() == HideCursorState::Idle) {
bd->lastCursorMoveTime = bd->time;
}
}
@ -656,7 +656,7 @@ static void UpdateMouseCursor() {
return;
SdlData* bd = GetBackendData();
s16 cursorState = EmulatorSettings::GetInstance()->GetCursorState();
s16 cursorState = EmulatorSettings.GetCursorState();
ImGuiMouseCursor imgui_cursor = ImGui::GetMouseCursor();
if (io.MouseDrawCursor || imgui_cursor == ImGuiMouseCursor_None ||
cursorState == HideCursorState::Always) {
@ -665,7 +665,7 @@ static void UpdateMouseCursor() {
} else if (cursorState == HideCursorState::Idle &&
bd->time - bd->lastCursorMoveTime >=
EmulatorSettings::GetInstance()->GetCursorHideTimeout() *
EmulatorSettings.GetCursorHideTimeout() *
SDL_GetPerformanceFrequency()) {
bool wasCursorVisible = SDL_CursorVisible();

View File

@ -152,7 +152,7 @@ void WorkerLoop() {
g_job_list.pop_front();
g_job_list_mtx.unlock();
if (EmulatorSettings::GetInstance()->IsVkCrashDiagnosticEnabled()) {
if (EmulatorSettings.IsVkCrashDiagnosticEnabled()) {
// FIXME: Crash diagnostic hangs when building the command buffer here
continue;
}

View File

@ -269,7 +269,7 @@ void GameControllers::TryOpenSDLControllers(GameControllers& controllers) {
slot_taken[i] = true;
c->player_index = i;
AddUserServiceEvent({OrbisUserServiceEventType::Login, i + 1});
if (EmulatorSettings::GetInstance()->IsMotionControlsEnabled()) {
if (EmulatorSettings.IsMotionControlsEnabled()) {
if (SDL_SetGamepadSensorEnabled(c->m_sdl_gamepad, SDL_SENSOR_GYRO, true)) {
c->gyro_poll_rate =
SDL_GetGamepadSensorDataRate(c->m_sdl_gamepad, SDL_SENSOR_GYRO);
@ -369,11 +369,11 @@ namespace GamepadSelect {
int GetDefaultGamepad(SDL_JoystickID* gamepadIDs, int gamepadCount) {
char GUIDbuf[33];
if (EmulatorSettings::GetInstance()->GetDefaultControllerId() != "") {
if (EmulatorSettings.GetDefaultControllerId() != "") {
for (int i = 0; i < gamepadCount; i++) {
SDL_GUIDToString(SDL_GetGamepadGUIDForID(gamepadIDs[i]), GUIDbuf, 33);
std::string currentGUID = std::string(GUIDbuf);
if (currentGUID == EmulatorSettings::GetInstance()->GetDefaultControllerId()) {
if (currentGUID == EmulatorSettings.GetDefaultControllerId()) {
return i;
}
}

View File

@ -338,7 +338,7 @@ std::optional<int> parseInt(const std::string& s) {
void ParseInputConfig(const std::string game_id = "") {
std::string game_id_or_default =
EmulatorSettings::GetInstance()->IsUseUnifiedInputConfig() ? "default" : game_id;
EmulatorSettings.IsUseUnifiedInputConfig() ? "default" : game_id;
const auto config_file = GetInputConfigFile(game_id_or_default);
const auto global_config_file = GetInputConfigFile("global");
@ -767,13 +767,13 @@ void ControllerOutput::FinalizeUpdate(u8 gamepad_index) {
PushSDLEvent(SDL_EVENT_REMOVE_VIRTUAL_USER);
break;
case HOTKEY_VOLUME_UP:
EmulatorSettings::GetInstance()->SetVolumeSlider(
std::clamp(EmulatorSettings::GetInstance()->GetVolumeSlider() + 10, 0, 500));
EmulatorSettings.SetVolumeSlider(
std::clamp(EmulatorSettings.GetVolumeSlider() + 10, 0, 500));
Overlay::ShowVolume();
break;
case HOTKEY_VOLUME_DOWN:
EmulatorSettings::GetInstance()->SetVolumeSlider(
std::clamp(EmulatorSettings::GetInstance()->GetVolumeSlider() - 10, 0, 500));
EmulatorSettings.SetVolumeSlider(
std::clamp(EmulatorSettings.GetVolumeSlider() - 10, 0, 500));
Overlay::ShowVolume();
break;
case HOTKEY_QUIT:

View File

@ -35,8 +35,8 @@ int main(int argc, char* argv[]) {
std::shared_ptr<EmulatorState> m_emu_state = std::make_shared<EmulatorState>();
EmulatorState::SetInstance(m_emu_state);
// Load configurations
std::shared_ptr<EmulatorSettings> emu_settings = std::make_shared<EmulatorSettings>();
EmulatorSettings::SetInstance(emu_settings);
std::shared_ptr<EmulatorSettingsImpl> emu_settings = std::make_shared<EmulatorSettingsImpl>();
EmulatorSettingsImpl::SetInstance(emu_settings);
emu_settings->Load();
// TODO add back trophy key migration without the need of entire previous config framework
@ -110,15 +110,15 @@ int main(int argc, char* argv[]) {
// ---- Utility commands ----
if (addGameFolder) {
EmulatorSettings::GetInstance()->AddGameInstallDir(*addGameFolder);
EmulatorSettings::GetInstance()->Save();
EmulatorSettings.AddGameInstallDir(*addGameFolder);
EmulatorSettings.Save();
std::cout << "Game folder successfully saved.\n";
return 0;
}
if (setAddonFolder) {
EmulatorSettings::GetInstance()->SetAddonInstallDir(*setAddonFolder);
EmulatorSettings::GetInstance()->Save();
EmulatorSettings.SetAddonInstallDir(*setAddonFolder);
EmulatorSettings.Save();
std::cout << "Addon folder successfully saved.\n";
return 0;
}
@ -142,9 +142,9 @@ int main(int argc, char* argv[]) {
if (fullscreenStr) {
if (*fullscreenStr == "true") {
EmulatorSettings::GetInstance()->SetFullScreen(true);
EmulatorSettings.SetFullScreen(true);
} else if (*fullscreenStr == "false") {
EmulatorSettings::GetInstance()->SetFullScreen(false);
EmulatorSettings.SetFullScreen(false);
} else {
std::cerr << "Error: Invalid argument for --fullscreen (use true|false)\n";
return 1;
@ -152,13 +152,13 @@ int main(int argc, char* argv[]) {
}
if (showFps)
EmulatorSettings::GetInstance()->SetShowFpsCounter(true);
EmulatorSettings.SetShowFpsCounter(true);
if (configClean)
EmulatorSettings::GetInstance()->SetConfigMode(ConfigMode::Clean);
EmulatorSettings.SetConfigMode(ConfigMode::Clean);
if (configGlobal)
EmulatorSettings::GetInstance()->SetConfigMode(ConfigMode::Global);
EmulatorSettings.SetConfigMode(ConfigMode::Global);
if (logAppend)
Common::Log::SetAppend();
@ -168,7 +168,7 @@ int main(int argc, char* argv[]) {
if (!std::filesystem::exists(ebootPath)) {
bool found = false;
constexpr int maxDepth = 5;
for (const auto& installDir : EmulatorSettings::GetInstance()->GetGameInstallDirs()) {
for (const auto& installDir : EmulatorSettings.GetGameInstallDirs()) {
if (auto foundPath = Common::FS::FindGameByID(installDir, *gamePath, maxDepth)) {
ebootPath = *foundPath;
found = true;

View File

@ -117,12 +117,12 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
error = true;
}
if (!error) {
SDL_SetWindowFullscreenMode(window, EmulatorSettings::GetInstance()->GetFullScreenMode() ==
SDL_SetWindowFullscreenMode(window, EmulatorSettings.GetFullScreenMode() ==
"Fullscreen"
? displayMode
: NULL);
}
SDL_SetWindowFullscreen(window, EmulatorSettings::GetInstance()->IsFullScreen());
SDL_SetWindowFullscreen(window, EmulatorSettings.IsFullScreen());
SDL_InitSubSystem(SDL_INIT_GAMEPAD);
@ -153,7 +153,7 @@ WindowSDL::WindowSDL(s32 width_, s32 height_, Input::GameControllers* controller
Input::ParseInputConfig(std::string(Common::ElfInfo::Instance().GameSerial()));
Input::GameControllers::TryOpenSDLControllers(controllers);
if (EmulatorSettings::GetInstance()->IsBackgroundControllerInput()) {
if (EmulatorSettings.IsBackgroundControllerInput()) {
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
}
}

View File

@ -58,7 +58,7 @@ Id EmitGetUserData(EmitContext& ctx, IR::ScalarReg reg) {
Id EmitReadConst(EmitContext& ctx, IR::Inst* inst, Id addr, Id offset) {
const u32 flatbuf_off_dw = inst->Flags<u32>();
if (!EmulatorSettings::GetInstance()->IsDirectMemoryAccessEnabled()) {
if (!EmulatorSettings.IsDirectMemoryAccessEnabled()) {
return ctx.EmitFlatbufferLoad(ctx.ConstU32(flatbuf_off_dw));
}
// We can only provide a fallback for immediate offsets.

View File

@ -552,7 +552,7 @@ void Translator::EmitFetch(const GcnInst& inst) {
const auto fetch_data = ParseFetchShader(info);
ASSERT(fetch_data.has_value());
if (EmulatorSettings::GetInstance()->IsDumpShaders()) {
if (EmulatorSettings.IsDumpShaders()) {
using namespace Common::FS;
const auto dump_dir = GetUserPath(PathType::ShaderDir) / "dumps";
if (!std::filesystem::exists(dump_dir)) {

View File

@ -228,7 +228,7 @@ static void GenerateSrtProgram(Info& info, PassInfo& pass_info) {
info.srt_info.walker_func_size =
c.getCurr() - reinterpret_cast<const u8*>(info.srt_info.walker_func);
if (EmulatorSettings::GetInstance()->IsDumpShaders()) {
if (EmulatorSettings.IsDumpShaders()) {
DumpSrtProgram(info, reinterpret_cast<const u8*>(info.srt_info.walker_func),
info.srt_info.walker_func_size);
}

View File

@ -176,7 +176,7 @@ void CollectShaderInfoPass(IR::Program& program, const Profile& profile) {
// info.readconst_types |= Info::ReadConstType::Immediate;
}
if (!EmulatorSettings::GetInstance()->IsDirectMemoryAccessEnabled()) {
if (!EmulatorSettings.IsDirectMemoryAccessEnabled()) {
info.uses_dma = false;
info.readconst_types = Info::ReadConstType::None;
}

View File

@ -19,7 +19,7 @@ namespace Shader::IR {
void DumpProgram(const Program& program, const Info& info, const std::string& type) {
using namespace Common::FS;
if (!EmulatorSettings::GetInstance()->IsDumpShaders()) {
if (!EmulatorSettings.IsDumpShaders()) {
return;
}

View File

@ -230,9 +230,9 @@ Liverpool::Task Liverpool::ProcessGraphics(std::span<const u32> dcb, std::span<c
RESUME_GFX(ce_task);
}
const bool host_markers_enabled =
rasterizer && EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled();
rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
const bool guest_markers_enabled =
rasterizer && EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled();
rasterizer && EmulatorSettings.IsVkGuestMarkersEnabled();
const auto base_addr = reinterpret_cast<uintptr_t>(dcb.data());
while (!dcb.empty()) {
@ -902,7 +902,7 @@ Liverpool::Task Liverpool::ProcessCompute(std::span<const u32> acb, u32 vqid) {
FIBER_ENTER(acb_task_name[vqid]);
auto& queue = asc_queues[{vqid}];
const bool host_markers_enabled =
rasterizer && EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled();
rasterizer && EmulatorSettings.IsVkHostMarkersEnabled();
struct IndirectPatch {
const PM4Header* header;
@ -1205,7 +1205,7 @@ Liverpool::CmdBuffer Liverpool::CopyCmdBuffers(std::span<const u32> dcb, std::sp
void Liverpool::SubmitGfx(std::span<const u32> dcb, std::span<const u32> ccb) {
auto& queue = mapped_queues[GfxQueueId];
if (EmulatorSettings::GetInstance()->IsCopyGpuBuffers()) {
if (EmulatorSettings.IsCopyGpuBuffers()) {
std::tie(dcb, ccb) = CopyCmdBuffers(dcb, ccb);
}

View File

@ -74,7 +74,7 @@ public:
// modified. If we need to flush the flush function is going to perform CPU
// state change.
std::scoped_lock lk{manager->lock};
if (EmulatorSettings::GetInstance()->GetReadbacksMode() !=
if (EmulatorSettings.GetReadbacksMode() !=
GpuReadbacksMode::Disabled &&
manager->template IsRegionModified<Type::GPU>(offset, size)) {
return true;

View File

@ -95,7 +95,7 @@ public:
}
if constexpr (type == Type::CPU) {
UpdateProtection<!enable, false>();
} else if (EmulatorSettings::GetInstance()->GetReadbacksMode() ==
} else if (EmulatorSettings.GetReadbacksMode() ==
GpuReadbacksMode::Precise) {
UpdateProtection<enable, true>();
}
@ -127,7 +127,7 @@ public:
bits.UnsetRange(start_page, end_page);
if constexpr (type == Type::CPU) {
UpdateProtection<true, false>();
} else if (EmulatorSettings::GetInstance()->GetReadbacksMode() !=
} else if (EmulatorSettings.GetReadbacksMode() !=
GpuReadbacksMode::Disabled) {
UpdateProtection<false, true>();
}

View File

@ -95,7 +95,7 @@ void DataBase::Open() {
const auto& game_info = Common::ElfInfo::Instance();
using namespace Common::FS;
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
mz_zip_zero_struct(&zip_ar);
cache_path = GetUserPath(PathType::CacheDir) /
@ -128,7 +128,7 @@ void DataBase::Close() {
io_worker.request_stop();
io_worker.join();
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
mz_zip_writer_finalize_archive(&zip_ar);
mz_zip_writer_end(&zip_ar);
}
@ -142,7 +142,7 @@ bool WriteVector(const BlobType type, std::filesystem::path&& path_, std::vector
auto request = std::packaged_task<void()>{[=]() {
auto path{path_};
path.replace_extension(GetBlobFileExtension(type));
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
ASSERT_MSG(!ar_is_read_only,
"The archive is read-only. Did you forget to call `FinishPreload`?");
if (!mz_zip_writer_add_mem(&zip_ar, path.string().c_str(), v.data(),
@ -169,7 +169,7 @@ template <typename T>
void LoadVector(BlobType type, std::filesystem::path& path, std::vector<T>& v) {
using namespace Common::FS;
path.replace_extension(GetBlobFileExtension(type));
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
int index{-1};
index = mz_zip_reader_locate_file(&zip_ar, path.string().c_str(), nullptr, 0);
if (index < 0) {
@ -192,7 +192,7 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector<u8>&& da
return false;
}
auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived()
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
return WriteVector(type, std::move(path), std::move(data));
@ -203,7 +203,7 @@ bool DataBase::Save(BlobType type, const std::string& name, std::vector<u32>&& d
return false;
}
auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived()
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
return WriteVector(type, std::move(path), std::move(data));
@ -214,7 +214,7 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector<u8>& dat
return;
}
auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived()
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
return LoadVector(type, path, data);
@ -225,7 +225,7 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector<u32>& da
return;
}
auto path = EmulatorSettings::GetInstance()->IsPipelineCacheArchived()
auto path = EmulatorSettings.IsPipelineCacheArchived()
? std::filesystem::path{name}
: cache_path / name;
return LoadVector(type, path, data);
@ -233,7 +233,7 @@ void DataBase::Load(BlobType type, const std::string& name, std::vector<u32>& da
void DataBase::ForEachBlob(BlobType type, const std::function<void(std::vector<u8>&& data)>& func) {
const auto& ext = GetBlobFileExtension(type);
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
const auto num_files = mz_zip_reader_get_num_files(&zip_ar);
for (int index = 0; index < num_files; ++index) {
std::array<char, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE> file_name{};
@ -263,7 +263,7 @@ void DataBase::ForEachBlob(BlobType type, const std::function<void(std::vector<u
}
void DataBase::FinishPreload() {
if (EmulatorSettings::GetInstance()->IsPipelineCacheArchived()) {
if (EmulatorSettings.IsPipelineCacheArchived()) {
mz_zip_writer_init_from_reader(&zip_ar, cache_path.string().c_str());
ar_is_read_only = false;
}

View File

@ -31,7 +31,7 @@ void LoadRenderDoc() {
// Check if we are running by RDoc GUI
HMODULE mod = GetModuleHandleA("renderdoc.dll");
if (!mod && EmulatorSettings::GetInstance()->IsRenderdocEnabled()) {
if (!mod && EmulatorSettings.IsRenderdocEnabled()) {
// If enabled in config, try to load RDoc runtime in offline mode
HKEY h_reg_key;
LONG result = RegOpenKeyExW(HKEY_LOCAL_MACHINE,
@ -67,7 +67,7 @@ void LoadRenderDoc() {
#endif
// Check if we are running by RDoc GUI
void* mod = dlopen(RENDERDOC_LIB, RTLD_NOW | RTLD_NOLOAD);
if (!mod && EmulatorSettings::GetInstance()->IsRenderdocEnabled()) {
if (!mod && EmulatorSettings.IsRenderdocEnabled()) {
// If enabled in config, try to load RDoc runtime in offline mode
if ((mod = dlopen(RENDERDOC_LIB, RTLD_NOW))) {
const auto RENDERDOC_GetAPI =

View File

@ -164,7 +164,7 @@ vk::ImageView FsrPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input,
CreateImages(img);
}
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
.pLabelName = "Host/FSR",
});
@ -387,7 +387,7 @@ vk::ImageView FsrPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input,
.pImageMemoryBarriers = return_barrier.data(),
});
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.endDebugUtilsLabelEXT();
}

View File

@ -188,7 +188,7 @@ void PostProcessingPass::Create(vk::Device device, const vk::Format surface_form
void PostProcessingPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input,
vk::Extent2D input_size, Frame& frame, Settings settings) {
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
.pLabelName = "Host/Post processing",
});
@ -279,7 +279,7 @@ void PostProcessingPass::Render(vk::CommandBuffer cmdbuf, vk::ImageView input,
.pImageMemoryBarriers = &post_barrier,
});
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.endDebugUtilsLabelEXT();
}
}

View File

@ -300,7 +300,7 @@ const GraphicsPipeline* PipelineCache::GetGraphicsPipeline() {
RegisterPipelineData(graphics_key, pipeline_hash, sdata);
++num_new_pipelines;
if (EmulatorSettings::GetInstance()->IsShaderCollect()) {
if (EmulatorSettings.IsShaderCollect()) {
for (auto stage = 0; stage < MaxShaderStages; ++stage) {
if (infos[stage]) {
auto& m = modules[stage];
@ -329,7 +329,7 @@ const ComputePipeline* PipelineCache::GetComputePipeline() {
RegisterPipelineData(compute_key, sdata);
++num_new_pipelines;
if (EmulatorSettings::GetInstance()->IsShaderCollect()) {
if (EmulatorSettings.IsShaderCollect()) {
auto& m = modules[0];
module_related_pipelines[m].emplace_back(compute_key);
}
@ -554,7 +554,7 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim
vk::ShaderModule module;
auto patch = GetShaderPatch(info.pgm_hash, info.stage, perm_idx, "spv");
const bool is_patched = patch && EmulatorSettings::GetInstance()->IsPatchShaders();
const bool is_patched = patch && EmulatorSettings.IsPatchShaders();
if (is_patched) {
LOG_INFO(Loader, "Loaded patch for {} shader {:#x}", info.stage, info.pgm_hash);
module = CompileSPV(*patch, instance.GetDevice());
@ -566,7 +566,7 @@ vk::ShaderModule PipelineCache::CompileModule(Shader::Info& info, Shader::Runtim
const auto name = GetShaderName(info.stage, info.pgm_hash, perm_idx);
Vulkan::SetObjectName(instance.GetDevice(), module, name);
if (EmulatorSettings::GetInstance()->IsShaderCollect()) {
if (EmulatorSettings.IsShaderCollect()) {
DebugState.CollectShader(name, info.l_stage, module, spv, code,
patch ? *patch : std::span<const u32>{}, is_patched);
}
@ -659,7 +659,7 @@ std::string PipelineCache::GetShaderName(Shader::Stage stage, u64 hash,
void PipelineCache::DumpShader(std::span<const u32> code, u64 hash, Shader::Stage stage,
size_t perm_idx, std::string_view ext) {
if (!EmulatorSettings::GetInstance()->IsDumpShaders()) {
if (!EmulatorSettings.IsDumpShaders()) {
return;
}

View File

@ -295,7 +295,7 @@ bool PipelineCache::LoadPipelineStage(Serialization::Archive& ar, size_t stage)
}
void PipelineCache::WarmUp() {
if (!EmulatorSettings::GetInstance()->IsPipelineCacheEnabled()) {
if (!EmulatorSettings.IsPipelineCacheEnabled()) {
return;
}

View File

@ -87,7 +87,7 @@ vk::SurfaceKHR CreateSurface(vk::Instance instance, const Frontend::WindowSDL& e
UNREACHABLE();
}
} else if (window_info.type == Frontend::WindowSystemType::Wayland) {
if (EmulatorSettings::GetInstance()->IsRenderdocEnabled()) {
if (EmulatorSettings.IsRenderdocEnabled()) {
LOG_ERROR(Render_Vulkan,
"RenderDoc is not compatible with Wayland, use an X11 window instead.");
}
@ -200,7 +200,7 @@ std::vector<const char*> GetInstanceExtensions(Frontend::WindowSystemType window
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
}
if (EmulatorSettings::GetInstance()->IsHdrAllowed()) {
if (EmulatorSettings.IsHdrAllowed()) {
extensions.push_back(VK_EXT_SWAPCHAIN_COLOR_SPACE_EXTENSION_NAME);
}
@ -307,11 +307,11 @@ vk::UniqueInstance CreateInstance(Frontend::WindowSystemType window_type, bool e
// Validation settings
vk::Bool32 enable_core =
EmulatorSettings::GetInstance()->IsVkValidationCoreEnabled() ? vk::True : vk::False;
EmulatorSettings.IsVkValidationCoreEnabled() ? vk::True : vk::False;
vk::Bool32 enable_sync =
EmulatorSettings::GetInstance()->IsVkValidationSyncEnabled() ? vk::True : vk::False;
EmulatorSettings.IsVkValidationSyncEnabled() ? vk::True : vk::False;
vk::Bool32 enable_gpuav =
EmulatorSettings::GetInstance()->IsVkValidationGpuEnabled() ? vk::True : vk::False;
EmulatorSettings.IsVkValidationGpuEnabled() ? vk::True : vk::False;
// Crash diagnostics settings
static const auto crash_diagnostic_path =

View File

@ -104,9 +104,9 @@ static vk::Rect2D FitImage(s32 frame_width, s32 frame_height, s32 swapchain_widt
Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_)
: window{window_}, liverpool{liverpool_},
instance{window, EmulatorSettings::GetInstance()->GetGpuId(),
EmulatorSettings::GetInstance()->IsVkValidationEnabled(),
EmulatorSettings::GetInstance()->IsVkCrashDiagnosticEnabled()},
instance{window, EmulatorSettings.GetGpuId(),
EmulatorSettings.IsVkValidationEnabled(),
EmulatorSettings.IsVkCrashDiagnosticEnabled()},
draw_scheduler{instance}, present_scheduler{instance}, flip_scheduler{instance},
swapchain{instance, window},
rasterizer{std::make_unique<Rasterizer>(instance, draw_scheduler, liverpool)},
@ -125,10 +125,10 @@ Presenter::Presenter(Frontend::WindowSDL& window_, AmdGpu::Liverpool* liverpool_
free_queue.push(&frame);
}
fsr_settings.enable = EmulatorSettings::GetInstance()->IsFsrEnabled();
fsr_settings.use_rcas = EmulatorSettings::GetInstance()->IsRcasEnabled();
fsr_settings.enable = EmulatorSettings.IsFsrEnabled();
fsr_settings.use_rcas = EmulatorSettings.IsRcasEnabled();
fsr_settings.rcas_attenuation =
static_cast<float>(EmulatorSettings::GetInstance()->GetRcasAttenuation() / 1000.f);
static_cast<float>(EmulatorSettings.GetRcasAttenuation() / 1000.f);
fsr_pass.Create(device, instance.GetAllocator(), num_images);
pp_pass.Create(device, swapchain.GetSurfaceFormat().format);
@ -467,7 +467,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) {
auto& scheduler = present_scheduler;
const auto cmdbuf = scheduler.CommandBuffer();
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.beginDebugUtilsLabelEXT(vk::DebugUtilsLabelEXT{
.pLabelName = "Present",
});
@ -579,7 +579,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) {
ImGui::SetCursorPos(ImGui::GetCursorStartPos() + offset);
ImGui::Image(game_texture, size);
if (EmulatorSettings::GetInstance()->IsNullGPU()) {
if (EmulatorSettings.IsNullGPU()) {
Core::Devtools::Layer::DrawNullGpuNotice();
}
}
@ -598,7 +598,7 @@ void Presenter::Present(Frame* frame, bool is_reusing_frame) {
}
}
if (EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled()) {
if (EmulatorSettings.IsVkHostMarkersEnabled()) {
cmdbuf.endDebugUtilsLabelEXT();
}

View File

@ -38,7 +38,7 @@ Rasterizer::Rasterizer(const Instance& instance_, Scheduler& scheduler_,
texture_cache{instance, scheduler, liverpool_, buffer_cache, page_manager},
liverpool{liverpool_}, memory{Core::Memory::Instance()},
pipeline_cache{instance, scheduler, liverpool} {
if (!EmulatorSettings::GetInstance()->IsNullGPU()) {
if (!EmulatorSettings.IsNullGPU()) {
liverpool->BindRasterizer(this);
}
memory->SetRasterizer(this);
@ -1278,8 +1278,8 @@ void Rasterizer::UpdateColorBlendingState(const GraphicsPipeline* pipeline) cons
}
void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) {
if ((from_guest && !EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled())) {
if ((from_guest && !EmulatorSettings.IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings.IsVkHostMarkersEnabled())) {
return;
}
const auto cmdbuf = scheduler.CommandBuffer();
@ -1289,8 +1289,8 @@ void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest)
}
void Rasterizer::ScopeMarkerEnd(bool from_guest) {
if ((from_guest && !EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled())) {
if ((from_guest && !EmulatorSettings.IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings.IsVkHostMarkersEnabled())) {
return;
}
const auto cmdbuf = scheduler.CommandBuffer();
@ -1298,8 +1298,8 @@ void Rasterizer::ScopeMarkerEnd(bool from_guest) {
}
void Rasterizer::ScopedMarkerInsert(const std::string_view& str, bool from_guest) {
if ((from_guest && !EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled())) {
if ((from_guest && !EmulatorSettings.IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings.IsVkHostMarkersEnabled())) {
return;
}
const auto cmdbuf = scheduler.CommandBuffer();
@ -1310,8 +1310,8 @@ void Rasterizer::ScopedMarkerInsert(const std::string_view& str, bool from_guest
void Rasterizer::ScopedMarkerInsertColor(const std::string_view& str, const u32 color,
bool from_guest) {
if ((from_guest && !EmulatorSettings::GetInstance()->IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings::GetInstance()->IsVkHostMarkersEnabled())) {
if ((from_guest && !EmulatorSettings.IsVkGuestMarkersEnabled()) ||
(!from_guest && !EmulatorSettings.IsVkHostMarkersEnabled())) {
return;
}
const auto cmdbuf = scheduler.CommandBuffer();

View File

@ -164,7 +164,7 @@ void Swapchain::FindPresentFormat() {
return format == SURFACE_FORMAT_HDR;
}) != formats.end();
// Also make sure that user allowed us to use HDR
supports_hdr &= EmulatorSettings::GetInstance()->IsHdrAllowed();
supports_hdr &= EmulatorSettings.IsHdrAllowed();
// If there is a single undefined surface format, the device doesn't care, so we'll just use
// RGBA sRGB.
@ -199,7 +199,7 @@ void Swapchain::FindPresentMode() {
return;
}
const auto requested_mode = EmulatorSettings::GetInstance()->GetPresentMode();
const auto requested_mode = EmulatorSettings.GetPresentMode();
if (requested_mode == "Mailbox") {
present_mode = vk::PresentModeKHR::eMailbox;
} else if (requested_mode == "Fifo") {
@ -208,7 +208,7 @@ void Swapchain::FindPresentMode() {
present_mode = vk::PresentModeKHR::eImmediate;
} else {
LOG_ERROR(Render_Vulkan, "Unknown present mode {}, defaulting to Mailbox.",
EmulatorSettings::GetInstance()->GetPresentMode());
EmulatorSettings.GetPresentMode());
present_mode = vk::PresentModeKHR::eMailbox;
}

View File

@ -649,7 +649,7 @@ ImageView& TextureCache::FindTexture(ImageId image_id, const ImageDesc& desc) {
Image& image = slot_images[image_id];
if (desc.type == BindingType::Storage) {
image.flags |= ImageFlagBits::GpuModified;
if (EmulatorSettings::GetInstance()->IsReadbackLinearImagesEnabled() &&
if (EmulatorSettings.IsReadbackLinearImagesEnabled() &&
!image.info.props.is_tiled && image.info.guest_address != 0) {
download_images.emplace(image_id);
}
@ -661,7 +661,7 @@ ImageView& TextureCache::FindTexture(ImageId image_id, const ImageDesc& desc) {
ImageView& TextureCache::FindRenderTarget(ImageId image_id, const ImageDesc& desc) {
Image& image = slot_images[image_id];
image.flags |= ImageFlagBits::GpuModified;
if (EmulatorSettings::GetInstance()->IsReadbackLinearImagesEnabled() &&
if (EmulatorSettings.IsReadbackLinearImagesEnabled() &&
!image.info.props.is_tiled) {
download_images.emplace(image_id);
}