Settings: Split into GPU and main settings

That way the GPU thread copy doesn't need fields it never touches.
This commit is contained in:
Stenzek 2024-12-21 14:53:13 +10:00
parent 6b754e6759
commit 62285dcf33
No known key found for this signature in database
15 changed files with 211 additions and 214 deletions

View File

@ -632,7 +632,7 @@ bool FullscreenUI::AreAnyDialogsOpen()
ImGuiFullscreen::IsFileSelectorOpen());
}
void FullscreenUI::CheckForConfigChanges(const Settings& old_settings)
void FullscreenUI::CheckForConfigChanges(const GPUSettings& old_settings)
{
// NOTE: Called on GPU thread.
}

View File

@ -13,13 +13,13 @@
class SmallStringBase;
struct Settings;
struct GPUSettings;
namespace FullscreenUI {
bool Initialize();
bool IsInitialized();
bool HasActiveWindow();
void CheckForConfigChanges(const Settings& old_settings);
void CheckForConfigChanges(const GPUSettings& old_settings);
void OnSystemStarted();
void OnSystemResumed();
void OnSystemDestroyed();

View File

@ -103,7 +103,7 @@ bool GPUBackend::Initialize(bool clear_vram, Error* error)
return true;
}
void GPUBackend::UpdateSettings(const Settings& old_settings)
void GPUBackend::UpdateSettings(const GPUSettings& old_settings)
{
FlushRender();
@ -774,8 +774,8 @@ GPUDevice::PresentResult GPUBackend::PresentDisplay()
GSVector4i display_rect;
GSVector4i draw_rect;
CalculateDrawRect(g_gpu_device->GetMainSwapChain()->GetWidth(), g_gpu_device->GetMainSwapChain()->GetHeight(),
!g_gpu_settings.debugging.show_vram, true, &display_rect, &draw_rect);
return RenderDisplay(nullptr, display_rect, draw_rect, !g_gpu_settings.debugging.show_vram);
!g_gpu_settings.gpu_show_vram, true, &display_rect, &draw_rect);
return RenderDisplay(nullptr, display_rect, draw_rect, !g_gpu_settings.gpu_show_vram);
}
GPUDevice::PresentResult GPUBackend::RenderDisplay(GPUTexture* target, const GSVector4i display_rect,
@ -943,7 +943,7 @@ GPUDevice::PresentResult GPUBackend::RenderDisplay(GPUTexture* target, const GSV
if (really_postfx)
{
DebugAssert(!g_gpu_settings.debugging.show_vram);
DebugAssert(!g_gpu_settings.gpu_show_vram);
// "original size" in postfx includes padding.
const float upscale_x =
@ -978,7 +978,7 @@ void GPUBackend::SendDisplayToMediaCapture(MediaCapture* cap)
(g_gpu_settings.display_screenshot_mode != DisplayScreenshotMode::UncorrectedInternalResolution);
const bool postfx = (g_gpu_settings.display_screenshot_mode != DisplayScreenshotMode::InternalResolution);
GSVector4i display_rect, draw_rect;
CalculateDrawRect(target->GetWidth(), target->GetHeight(), !g_gpu_settings.debugging.show_vram, apply_aspect_ratio,
CalculateDrawRect(target->GetWidth(), target->GetHeight(), !g_gpu_settings.gpu_show_vram, apply_aspect_ratio,
&display_rect, &draw_rect);
// Not cleared by RenderDisplay().
@ -1228,7 +1228,7 @@ void GPUBackend::CalculateDrawRect(s32 window_width, s32 window_height, bool app
{
const bool integer_scale = (g_gpu_settings.display_scaling == DisplayScalingMode::NearestInteger ||
g_gpu_settings.display_scaling == DisplayScalingMode::BilinearInteger);
const bool show_vram = g_gpu_settings.debugging.show_vram;
const bool show_vram = g_gpu_settings.gpu_show_vram;
const u32 display_width = show_vram ? VRAM_WIDTH : m_display_width;
const u32 display_height = show_vram ? VRAM_HEIGHT : m_display_height;
const s32 display_origin_left = show_vram ? 0 : m_display_origin_left;
@ -1421,15 +1421,14 @@ bool GPUBackend::RenderScreenshotToBuffer(u32 width, u32 height, const GSVector4
void GPUBackend::CalculateScreenshotSize(DisplayScreenshotMode mode, u32* width, u32* height, GSVector4i* display_rect,
GSVector4i* draw_rect) const
{
const bool internal_resolution =
(mode != DisplayScreenshotMode::ScreenResolution || g_gpu_settings.debugging.show_vram);
const bool internal_resolution = (mode != DisplayScreenshotMode::ScreenResolution || g_gpu_settings.gpu_show_vram);
if (internal_resolution && m_display_texture_view_width != 0 && m_display_texture_view_height != 0)
{
if (mode == DisplayScreenshotMode::InternalResolution)
{
float f_width = static_cast<float>(m_display_texture_view_width);
float f_height = static_cast<float>(m_display_texture_view_height);
if (!g_gpu_settings.debugging.show_vram)
if (!g_gpu_settings.gpu_show_vram)
GPU::ApplyPixelAspectRatioToSize(m_display_pixel_aspect_ratio, &f_width, &f_height);
// DX11 won't go past 16K texture size.
@ -1462,7 +1461,7 @@ void GPUBackend::CalculateScreenshotSize(DisplayScreenshotMode mode, u32* width,
{
*width = g_gpu_device->HasMainSwapChain() ? g_gpu_device->GetMainSwapChain()->GetWidth() : 1;
*height = g_gpu_device->HasMainSwapChain() ? g_gpu_device->GetMainSwapChain()->GetHeight() : 1;
CalculateDrawRect(*width, *height, true, !g_settings.debugging.show_vram, display_rect, draw_rect);
CalculateDrawRect(*width, *height, true, !g_settings.gpu_show_vram, display_rect, draw_rect);
}
}

View File

@ -22,7 +22,7 @@ class SmallStringBase;
class GPUFramebuffer;
class GPUPipeline;
struct Settings;
struct GPUSettings;
class StateWrapper;
namespace System {
@ -77,7 +77,7 @@ public:
virtual bool Initialize(bool upload_vram, Error* error);
virtual void UpdateSettings(const Settings& old_settings);
virtual void UpdateSettings(const GPUSettings& old_settings);
/// Returns the current resolution scale.
virtual u32 GetResolutionScale() const = 0;

View File

@ -931,7 +931,7 @@ void GPU::FinishVRAMWrite()
if (m_blit_remaining_words == 0)
{
if (g_settings.debugging.dump_cpu_to_vram_copies)
if (g_settings.gpu_dump_cpu_to_vram_copies)
{
DumpVRAMToFile(TinyString::from_format("cpu_to_vram_copy_{}.png", s_cpu_to_vram_dump_id++), m_vram_transfer.width,
m_vram_transfer.height, sizeof(u16) * m_vram_transfer.width, m_blit_buffer.data(), true);
@ -995,7 +995,7 @@ bool GPU::HandleCopyRectangleVRAMToCPUCommand()
// ensure VRAM shadow is up to date
ReadVRAM(m_vram_transfer.x, m_vram_transfer.y, m_vram_transfer.width, m_vram_transfer.height);
if (g_settings.debugging.dump_vram_to_cpu_copies)
if (g_settings.gpu_dump_vram_to_cpu_copies)
{
DumpVRAMToFile(TinyString::from_format("vram_to_cpu_copy_{}.png", s_vram_to_cpu_dump_id++), m_vram_transfer.width,
m_vram_transfer.height, sizeof(u16) * VRAM_WIDTH,

View File

@ -439,7 +439,7 @@ void GPU_HW::RestoreDeviceContext()
m_batch_ubo_dirty = true;
}
void GPU_HW::UpdateSettings(const Settings& old_settings)
void GPU_HW::UpdateSettings(const GPUSettings& old_settings)
{
GPUBackend::UpdateSettings(old_settings);
@ -3669,7 +3669,7 @@ void GPU_HW::UpdateDisplay(const GPUBackendUpdateDisplayCommand* cmd)
GPUTextureCache::Compact();
if (g_gpu_settings.debugging.show_vram)
if (g_gpu_settings.gpu_show_vram)
{
if (IsUsingMultisampling())
{

View File

@ -72,7 +72,7 @@ public:
void RestoreDeviceContext() override;
protected:
void UpdateSettings(const Settings& old_settings) override;
void UpdateSettings(const GPUSettings& old_settings) override;
void UpdateResolutionScale() override;

View File

@ -590,7 +590,7 @@ bool GPUTextureCache::Initialize(GPU_HW* backend)
return true;
}
void GPUTextureCache::UpdateSettings(bool use_texture_cache, const Settings& old_settings)
void GPUTextureCache::UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings)
{
if (use_texture_cache)
{

View File

@ -9,7 +9,7 @@ class Image;
class GPUTexture;
class StateWrapper;
struct Settings;
struct GPUSettings;
class GPU_HW;
//////////////////////////////////////////////////////////////////////////
@ -104,7 +104,7 @@ struct Source
};
bool Initialize(GPU_HW* backend);
void UpdateSettings(bool use_texture_cache, const Settings& old_settings);
void UpdateSettings(bool use_texture_cache, const GPUSettings& old_settings);
bool GetStateSize(StateWrapper& sw, u32* size);
bool DoState(StateWrapper& sw, bool skip);

View File

@ -356,7 +356,7 @@ bool GPU_SW::CopyOut(u32 src_x, u32 src_y, u32 skip_x, u32 width, u32 height, u3
void GPU_SW::UpdateDisplay(const GPUBackendUpdateDisplayCommand* cmd)
{
if (!g_settings.debugging.show_vram)
if (!g_settings.gpu_show_vram)
{
if (cmd->display_disabled)
{

View File

@ -36,9 +36,6 @@
LOG_CHANNEL(GPUThread);
// TODO: Smaller settings struct.
// TODO: Remove g_gpu pointer.
namespace GPUThread {
enum : u32
{
@ -83,7 +80,7 @@ static void ReconfigureOnThread(GPUThreadReconfigureCommand* cmd);
static bool CreateGPUBackendOnThread(GPURenderer renderer, bool upload_vram, Error* error);
static void DestroyGPUBackendOnThread();
static void UpdateSettingsOnThread(const Settings& old_settings);
static void UpdateSettingsOnThread(const GPUSettings& old_settings);
static void UpdateRunIdle();
@ -932,7 +929,7 @@ void GPUThread::DestroyGPUBackendOnThread()
s_state.gpu_backend.reset();
}
void GPUThread::UpdateSettingsOnThread(const Settings& old_settings)
void GPUThread::UpdateSettingsOnThread(const GPUSettings& old_settings)
{
if (g_gpu_device)
{
@ -1008,7 +1005,7 @@ void GPUThread::UpdateSettings(bool gpu_settings_changed, bool device_settings_c
RunOnThread([settings = g_settings]() {
VERBOSE_LOG("Updating GPU settings on thread...");
Settings old_settings = std::move(g_gpu_settings);
GPUSettings old_settings = std::move(g_gpu_settings);
g_gpu_settings = std::move(settings);
UpdateSettingsOnThread(old_settings);

View File

@ -453,29 +453,29 @@ void ImGuiManager::DrawEnhancementsOverlay(const GPUBackend* gpu)
text.append_format(" CDR={}x", g_settings.cdrom_read_speedup);
if (g_settings.cdrom_seek_speedup != 1)
text.append_format(" CDS={}x", g_settings.cdrom_seek_speedup);
if (g_settings.gpu_resolution_scale != 1)
text.append_format(" IR={}x", g_settings.gpu_resolution_scale);
if (g_settings.gpu_multisamples != 1)
if (g_gpu_settings.gpu_resolution_scale != 1)
text.append_format(" IR={}x", g_gpu_settings.gpu_resolution_scale);
if (g_gpu_settings.gpu_multisamples != 1)
{
text.append_format(" {}x{}", g_settings.gpu_multisamples, g_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
text.append_format(" {}x{}", g_gpu_settings.gpu_multisamples, g_gpu_settings.gpu_per_sample_shading ? "SSAA" : "MSAA");
}
if (g_settings.gpu_true_color)
if (g_gpu_settings.gpu_true_color)
text.append(" TrueCol");
text.append_format(" DI={}", Settings::GetDisplayDeinterlacingModeName(g_settings.display_deinterlacing_mode));
text.append_format(" DI={}", Settings::GetDisplayDeinterlacingModeName(g_gpu_settings.display_deinterlacing_mode));
if (g_settings.gpu_force_video_timing == ForceVideoTimingMode::NTSC && System::GetRegion() == ConsoleRegion::PAL)
text.append(" PAL60");
if (g_settings.gpu_force_video_timing == ForceVideoTimingMode::PAL && System::GetRegion() != ConsoleRegion::PAL)
text.append(" NTSC50");
if (g_settings.gpu_texture_filter != GPUTextureFilter::Nearest)
if (g_gpu_settings.gpu_texture_filter != GPUTextureFilter::Nearest)
{
if (g_settings.gpu_sprite_texture_filter != g_settings.gpu_texture_filter)
if (g_gpu_settings.gpu_sprite_texture_filter != g_gpu_settings.gpu_texture_filter)
{
text.append_format(" {}/{}", Settings::GetTextureFilterName(g_settings.gpu_texture_filter),
Settings::GetTextureFilterName(g_settings.gpu_sprite_texture_filter));
text.append_format(" {}/{}", Settings::GetTextureFilterName(g_gpu_settings.gpu_texture_filter),
Settings::GetTextureFilterName(g_gpu_settings.gpu_sprite_texture_filter));
}
else
{
text.append_format(" {}", Settings::GetTextureFilterName(g_settings.gpu_texture_filter));
text.append_format(" {}", Settings::GetTextureFilterName(g_gpu_settings.gpu_texture_filter));
}
}
if (g_settings.gpu_widescreen_hack && g_settings.display_aspect_ratio != DisplayAspectRatio::Auto &&
@ -483,8 +483,8 @@ void ImGuiManager::DrawEnhancementsOverlay(const GPUBackend* gpu)
{
text.append(" WSHack");
}
if (g_settings.gpu_line_detect_mode != GPULineDetectMode::Disabled)
text.append_format(" LD={}", Settings::GetLineDetectModeName(g_settings.gpu_line_detect_mode));
if (g_gpu_settings.gpu_line_detect_mode != GPULineDetectMode::Disabled)
text.append_format(" LD={}", Settings::GetLineDetectModeName(g_gpu_settings.gpu_line_detect_mode));
if (g_settings.gpu_pgxp_enable)
{
text.append(" PGXP");

View File

@ -30,7 +30,7 @@
LOG_CHANNEL(Settings);
ALIGN_TO_CACHE_LINE Settings g_settings;
ALIGN_TO_CACHE_LINE Settings g_gpu_settings;
ALIGN_TO_CACHE_LINE GPUSettings g_gpu_settings;
const char* SettingInfo::StringDefaultValue() const
{
@ -88,6 +88,8 @@ float SettingInfo::FloatStepValue() const
return step_value ? StringUtil::FromChars<float>(step_value).value_or(fallback_value) : fallback_value;
}
GPUSettings::GPUSettings() = default;
#ifdef DYNAMIC_HOST_PAGE_SIZE
// See note in settings.h - 16K ends up faster with LUT because of nearby code/data.
const CPUFastmemMode Settings::DEFAULT_CPU_FASTMEM_MODE =
@ -253,6 +255,9 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
gpu_pgxp_depth_buffer = si.GetBoolValue("GPU", "PGXPDepthBuffer", false);
gpu_pgxp_disable_2d = si.GetBoolValue("GPU", "PGXPDisableOn2DPolygons", false);
SetPGXPDepthClearThreshold(si.GetFloatValue("GPU", "PGXPDepthClearThreshold", DEFAULT_GPU_PGXP_DEPTH_THRESHOLD));
gpu_show_vram = si.GetBoolValue("Debug", "ShowVRAM");
gpu_dump_cpu_to_vram_copies = si.GetBoolValue("Debug", "DumpCPUToVRAMCopies");
gpu_dump_vram_to_cpu_copies = si.GetBoolValue("Debug", "DumpVRAMToCPUCopies");
gpu_dump_fast_replay_mode = si.GetBoolValue("GPU", "DumpFastReplayMode", false);
display_deinterlacing_mode =
@ -424,13 +429,9 @@ void Settings::Load(const SettingsInterface& si, const SettingsInterface& contro
achievements_leaderboard_duration =
si.GetIntValue("Cheevos", "LeaderboardsDuration", DEFAULT_LEADERBOARD_NOTIFICATION_TIME);
debugging.show_vram = si.GetBoolValue("Debug", "ShowVRAM");
debugging.dump_cpu_to_vram_copies = si.GetBoolValue("Debug", "DumpCPUToVRAMCopies");
debugging.dump_vram_to_cpu_copies = si.GetBoolValue("Debug", "DumpVRAMToCPUCopies");
#ifndef __ANDROID__
debugging.enable_gdb_server = si.GetBoolValue("Debug", "EnableGDBServer");
debugging.gdb_server_port = static_cast<u16>(si.GetUIntValue("Debug", "GDBServerPort", DEFAULT_GDB_SERVER_PORT));
enable_gdb_server = si.GetBoolValue("Debug", "EnableGDBServer");
gdb_server_port = static_cast<u16>(si.GetUIntValue("Debug", "GDBServerPort", DEFAULT_GDB_SERVER_PORT));
#endif
texture_replacements.enable_texture_replacements =
@ -585,6 +586,9 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.SetBoolValue("GPU", "PGXPDepthBuffer", gpu_pgxp_depth_buffer);
si.SetBoolValue("GPU", "PGXPDisableOn2DPolygons", gpu_pgxp_disable_2d);
si.SetFloatValue("GPU", "PGXPDepthClearThreshold", GetPGXPDepthClearThreshold());
si.SetBoolValue("Debug", "ShowVRAM", gpu_show_vram);
si.SetBoolValue("Debug", "DumpCPUToVRAMCopies", gpu_dump_cpu_to_vram_copies);
si.SetBoolValue("Debug", "DumpVRAMToCPUCopies", gpu_dump_vram_to_cpu_copies);
si.SetBoolValue("GPU", "DumpFastReplayMode", gpu_dump_fast_replay_mode);
si.SetStringValue("GPU", "DeinterlacingMode", GetDisplayDeinterlacingModeName(display_deinterlacing_mode));
@ -701,17 +705,10 @@ void Settings::Save(SettingsInterface& si, bool ignore_base) const
si.SetIntValue("Cheevos", "NotificationsDuration", achievements_notification_duration);
si.SetIntValue("Cheevos", "LeaderboardsDuration", achievements_leaderboard_duration);
if (!ignore_base)
{
si.SetBoolValue("Debug", "ShowVRAM", debugging.show_vram);
si.SetBoolValue("Debug", "DumpCPUToVRAMCopies", debugging.dump_cpu_to_vram_copies);
si.SetBoolValue("Debug", "DumpVRAMToCPUCopies", debugging.dump_vram_to_cpu_copies);
#ifndef __ANDROID__
si.SetBoolValue("Debug", "EnableGDBServer", debugging.enable_gdb_server);
si.SetUIntValue("Debug", "GDBServerPort", debugging.gdb_server_port);
si.SetBoolValue("Debug", "EnableGDBServer", enable_gdb_server);
si.SetUIntValue("Debug", "GDBServerPort", gdb_server_port);
#endif
}
si.SetBoolValue("TextureReplacements", "EnableTextureReplacements", texture_replacements.enable_texture_replacements);
si.SetBoolValue("TextureReplacements", "EnableVRAMWriteReplacements",
@ -1083,12 +1080,12 @@ void Settings::FixIncompatibleSettings(const SettingsInterface& si, bool display
}
#ifndef __ANDROID__
g_settings.debugging.enable_gdb_server = false;
g_settings.enable_gdb_server = false;
#endif
g_settings.debugging.show_vram = false;
g_settings.debugging.dump_cpu_to_vram_copies = false;
g_settings.debugging.dump_vram_to_cpu_copies = false;
g_settings.gpu_show_vram = false;
g_settings.gpu_dump_cpu_to_vram_copies = false;
g_settings.gpu_dump_vram_to_cpu_copies = false;
}
}
@ -1783,7 +1780,7 @@ const char* Settings::GetDisplayAspectRatioDisplayName(DisplayAspectRatio ar)
"DisplayAspectRatio");
}
float Settings::GetDisplayAspectRatioValue() const
float GPUSettings::GetDisplayAspectRatioValue() const
{
return s_display_aspect_ratio_values[static_cast<size_t>(display_aspect_ratio)];
}

View File

@ -57,48 +57,17 @@ struct SettingInfo
float FloatStepValue() const;
};
struct Settings
struct GPUSettings
{
Settings();
GPUSettings();
ConsoleRegion region = DEFAULT_CONSOLE_REGION;
CPUExecutionMode cpu_execution_mode = DEFAULT_CPU_EXECUTION_MODE;
CPUFastmemMode cpu_fastmem_mode = DEFAULT_CPU_FASTMEM_MODE;
bool cpu_overclock_enable : 1 = false;
bool cpu_overclock_active : 1 = false;
bool cpu_recompiler_memory_exceptions : 1 = false;
bool cpu_recompiler_block_linking : 1 = true;
bool cpu_recompiler_icache : 1 = false;
u32 cpu_overclock_numerator = 1;
u32 cpu_overclock_denominator = 1;
float emulation_speed = 1.0f;
float fast_forward_speed = 0.0f;
float turbo_speed = 0.0f;
bool sync_to_host_refresh_rate : 1 = false;
bool inhibit_screensaver : 1 = true;
bool pause_on_focus_loss : 1 = false;
bool pause_on_controller_disconnection : 1 = false;
bool save_state_on_exit : 1 = true;
bool create_save_state_backups : 1 = DEFAULT_SAVE_STATE_BACKUPS;
bool confim_power_off : 1 = true;
bool load_devices_from_save_states : 1 = false;
bool apply_compatibility_settings : 1 = true;
bool apply_game_settings : 1 = true;
bool disable_all_enhancements : 1 = false;
bool enable_discord_presence : 1 = false;
bool rewind_enable : 1 = false;
float rewind_save_frequency = 10.0f;
u16 rewind_save_slots = 10;
u8 runahead_frames = 0;
std::string gpu_adapter;
GPURenderer gpu_renderer = DEFAULT_GPU_RENDERER;
std::string gpu_adapter;
u8 gpu_resolution_scale = 1;
u8 gpu_multisamples = 1;
u8 gpu_max_queued_frames = DEFAULT_GPU_MAX_QUEUED_FRAMES;
bool gpu_use_thread : 1 = true;
bool gpu_use_software_renderer_for_readbacks : 1 = false;
bool gpu_use_debug_device : 1 = false;
@ -118,6 +87,11 @@ struct Settings
bool gpu_accurate_blending : 1 = false;
bool gpu_widescreen_hack : 1 = false;
bool gpu_texture_cache : 1 = false;
bool gpu_show_vram : 1 = false;
bool gpu_dump_cpu_to_vram_copies : 1 = false;
bool gpu_dump_vram_to_cpu_copies : 1 = false;
bool gpu_dump_fast_replay_mode : 1 = false;
bool gpu_pgxp_enable : 1 = false;
bool gpu_pgxp_culling : 1 = true;
bool gpu_pgxp_texture_correction : 1 = true;
@ -127,6 +101,7 @@ struct Settings
bool gpu_pgxp_preserve_proj_fp : 1 = false;
bool gpu_pgxp_depth_buffer : 1 = false;
bool gpu_pgxp_disable_2d : 1 = false;
ForceVideoTimingMode gpu_force_video_timing = DEFAULT_FORCE_VIDEO_TIMING_MODE;
GPUTextureFilter gpu_texture_filter = DEFAULT_GPU_TEXTURE_FILTER;
GPUTextureFilter gpu_sprite_texture_filter = DEFAULT_GPU_TEXTURE_FILTER;
@ -176,62 +151,6 @@ struct Settings
float gpu_pgxp_tolerance = -1.0f;
float gpu_pgxp_depth_clear_threshold = DEFAULT_GPU_PGXP_DEPTH_THRESHOLD / GPU_PGXP_DEPTH_THRESHOLD_SCALE;
SaveStateCompressionMode save_state_compression = DEFAULT_SAVE_STATE_COMPRESSION_MODE;
u8 cdrom_readahead_sectors = DEFAULT_CDROM_READAHEAD_SECTORS;
CDROMMechaconVersion cdrom_mechacon_version = DEFAULT_CDROM_MECHACON_VERSION;
bool cdrom_region_check : 1 = false;
bool cdrom_subq_skew : 1 = false;
bool cdrom_load_image_to_ram : 1 = false;
bool cdrom_load_image_patches : 1 = false;
bool cdrom_mute_cd_audio : 1 = false;
u32 cdrom_read_speedup = 1;
u32 cdrom_seek_speedup = 1;
std::string audio_driver;
std::string audio_output_device;
u32 audio_output_volume = 100;
u32 audio_fast_forward_volume = 100;
AudioStreamParameters audio_stream_parameters;
AudioBackend audio_backend = AudioStream::DEFAULT_BACKEND;
bool audio_output_muted : 1 = false;
bool use_old_mdec_routines : 1 = false;
bool pcdrv_enable : 1 = false;
bool export_shared_memory : 1 = false;
// timing hacks section
TickCount dma_max_slice_ticks = DEFAULT_DMA_MAX_SLICE_TICKS;
TickCount dma_halt_ticks = DEFAULT_DMA_HALT_TICKS;
u32 gpu_fifo_size = DEFAULT_GPU_FIFO_SIZE;
TickCount gpu_max_run_ahead = DEFAULT_GPU_MAX_RUN_AHEAD;
// achievements
bool achievements_enabled : 1 = false;
bool achievements_hardcore_mode : 1 = false;
bool achievements_notifications : 1 = true;
bool achievements_leaderboard_notifications : 1 = true;
bool achievements_sound_effects : 1 = true;
bool achievements_overlays : 1 = true;
bool achievements_encore_mode : 1 = false;
bool achievements_spectator_mode : 1 = false;
bool achievements_unofficial_test_mode : 1 = false;
bool achievements_use_raintegration : 1 = false;
s32 achievements_notification_duration = DEFAULT_ACHIEVEMENT_NOTIFICATION_TIME;
s32 achievements_leaderboard_duration = DEFAULT_LEADERBOARD_NOTIFICATION_TIME;
struct DebugSettings
{
#ifndef __ANDROID__
u16 gdb_server_port = DEFAULT_GDB_SERVER_PORT;
bool enable_gdb_server : 1 = false;
#endif
bool show_vram : 1 = false;
bool dump_cpu_to_vram_copies : 1 = false;
bool dump_vram_to_cpu_copies : 1 = false;
} debugging;
// texture replacements
struct TextureReplacementSettings
{
@ -285,11 +204,143 @@ struct Settings
bool operator!=(const TextureReplacementSettings& rhs) const;
} texture_replacements;
float GetDisplayAspectRatioValue() const;
ALWAYS_INLINE bool IsUsingSoftwareRenderer() const { return (gpu_renderer == GPURenderer::Software); }
ALWAYS_INLINE bool IsUsingAccurateBlending() const { return (gpu_accurate_blending && !gpu_true_color); }
ALWAYS_INLINE bool UsingPGXPCPUMode() const { return gpu_pgxp_enable && gpu_pgxp_cpu; }
ALWAYS_INLINE bool UsingPGXPDepthBuffer() const { return gpu_pgxp_enable && gpu_pgxp_depth_buffer; }
ALWAYS_INLINE float GetPGXPDepthClearThreshold() const
{
return gpu_pgxp_depth_clear_threshold * GPU_PGXP_DEPTH_THRESHOLD_SCALE;
}
ALWAYS_INLINE void SetPGXPDepthClearThreshold(float value)
{
gpu_pgxp_depth_clear_threshold = value / GPU_PGXP_DEPTH_THRESHOLD_SCALE;
}
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::Automatic;
static constexpr GPUTextureFilter DEFAULT_GPU_TEXTURE_FILTER = GPUTextureFilter::Nearest;
static constexpr GPULineDetectMode DEFAULT_GPU_LINE_DETECT_MODE = GPULineDetectMode::Disabled;
static constexpr GPUDownsampleMode DEFAULT_GPU_DOWNSAMPLE_MODE = GPUDownsampleMode::Disabled;
static constexpr GPUWireframeMode DEFAULT_GPU_WIREFRAME_MODE = GPUWireframeMode::Disabled;
static constexpr GPUDumpCompressionMode DEFAULT_GPU_DUMP_COMPRESSION_MODE = GPUDumpCompressionMode::ZstDefault;
static constexpr float DEFAULT_GPU_PGXP_DEPTH_THRESHOLD = 300.0f;
static constexpr float GPU_PGXP_DEPTH_THRESHOLD_SCALE = 4096.0f;
static constexpr DisplayDeinterlacingMode DEFAULT_DISPLAY_DEINTERLACING_MODE = DisplayDeinterlacingMode::Progressive;
static constexpr DisplayCropMode DEFAULT_DISPLAY_CROP_MODE = DisplayCropMode::Overscan;
static constexpr DisplayAspectRatio DEFAULT_DISPLAY_ASPECT_RATIO = DisplayAspectRatio::Auto;
static constexpr DisplayAlignment DEFAULT_DISPLAY_ALIGNMENT = DisplayAlignment::Center;
static constexpr DisplayRotation DEFAULT_DISPLAY_ROTATION = DisplayRotation::Normal;
static constexpr DisplayScalingMode DEFAULT_DISPLAY_SCALING = DisplayScalingMode::BilinearSmooth;
static constexpr ForceVideoTimingMode DEFAULT_FORCE_VIDEO_TIMING_MODE = ForceVideoTimingMode::Disabled;
static constexpr DisplayExclusiveFullscreenControl DEFAULT_DISPLAY_EXCLUSIVE_FULLSCREEN_CONTROL =
DisplayExclusiveFullscreenControl::Automatic;
static constexpr DisplayScreenshotMode DEFAULT_DISPLAY_SCREENSHOT_MODE = DisplayScreenshotMode::ScreenResolution;
static constexpr DisplayScreenshotFormat DEFAULT_DISPLAY_SCREENSHOT_FORMAT = DisplayScreenshotFormat::PNG;
static constexpr u8 DEFAULT_DISPLAY_SCREENSHOT_QUALITY = 85;
static constexpr float DEFAULT_DISPLAY_PRE_FRAME_SLEEP_BUFFER = 2.0f;
static constexpr float DEFAULT_OSD_SCALE = 100.0f;
#ifndef __ANDROID__
static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 2;
#else
static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 3;
#endif
};
struct Settings : public GPUSettings
{
Settings();
ConsoleRegion region = DEFAULT_CONSOLE_REGION;
CPUExecutionMode cpu_execution_mode = DEFAULT_CPU_EXECUTION_MODE;
CPUFastmemMode cpu_fastmem_mode = DEFAULT_CPU_FASTMEM_MODE;
bool cpu_overclock_enable : 1 = false;
bool cpu_overclock_active : 1 = false;
bool cpu_recompiler_memory_exceptions : 1 = false;
bool cpu_recompiler_block_linking : 1 = true;
bool cpu_recompiler_icache : 1 = false;
u32 cpu_overclock_numerator = 1;
u32 cpu_overclock_denominator = 1;
float emulation_speed = 1.0f;
float fast_forward_speed = 0.0f;
float turbo_speed = 0.0f;
bool sync_to_host_refresh_rate : 1 = false;
bool inhibit_screensaver : 1 = true;
bool pause_on_focus_loss : 1 = false;
bool pause_on_controller_disconnection : 1 = false;
bool save_state_on_exit : 1 = true;
bool create_save_state_backups : 1 = DEFAULT_SAVE_STATE_BACKUPS;
bool confim_power_off : 1 = true;
bool load_devices_from_save_states : 1 = false;
bool apply_compatibility_settings : 1 = true;
bool apply_game_settings : 1 = true;
bool disable_all_enhancements : 1 = false;
bool enable_discord_presence : 1 = false;
bool rewind_enable : 1 = false;
float rewind_save_frequency = 10.0f;
u16 rewind_save_slots = 10;
u8 runahead_frames = 0;
SaveStateCompressionMode save_state_compression = DEFAULT_SAVE_STATE_COMPRESSION_MODE;
u8 cdrom_readahead_sectors = DEFAULT_CDROM_READAHEAD_SECTORS;
CDROMMechaconVersion cdrom_mechacon_version = DEFAULT_CDROM_MECHACON_VERSION;
bool cdrom_region_check : 1 = false;
bool cdrom_subq_skew : 1 = false;
bool cdrom_load_image_to_ram : 1 = false;
bool cdrom_load_image_patches : 1 = false;
bool cdrom_mute_cd_audio : 1 = false;
u32 cdrom_read_speedup = 1;
u32 cdrom_seek_speedup = 1;
std::string audio_driver;
std::string audio_output_device;
u32 audio_output_volume = 100;
u32 audio_fast_forward_volume = 100;
AudioStreamParameters audio_stream_parameters;
AudioBackend audio_backend = AudioStream::DEFAULT_BACKEND;
bool audio_output_muted : 1 = false;
bool use_old_mdec_routines : 1 = false;
bool pcdrv_enable : 1 = false;
bool export_shared_memory : 1 = false;
// timing hacks section
TickCount dma_max_slice_ticks = DEFAULT_DMA_MAX_SLICE_TICKS;
TickCount dma_halt_ticks = DEFAULT_DMA_HALT_TICKS;
u32 gpu_fifo_size = DEFAULT_GPU_FIFO_SIZE;
TickCount gpu_max_run_ahead = DEFAULT_GPU_MAX_RUN_AHEAD;
// achievements
bool achievements_enabled : 1 = false;
bool achievements_hardcore_mode : 1 = false;
bool achievements_notifications : 1 = true;
bool achievements_leaderboard_notifications : 1 = true;
bool achievements_sound_effects : 1 = true;
bool achievements_overlays : 1 = true;
bool achievements_encore_mode : 1 = false;
bool achievements_spectator_mode : 1 = false;
bool achievements_unofficial_test_mode : 1 = false;
bool achievements_use_raintegration : 1 = false;
s32 achievements_notification_duration = DEFAULT_ACHIEVEMENT_NOTIFICATION_TIME;
s32 achievements_leaderboard_duration = DEFAULT_LEADERBOARD_NOTIFICATION_TIME;
#ifndef __ANDROID__
u16 gdb_server_port = DEFAULT_GDB_SERVER_PORT;
bool enable_gdb_server : 1 = false;
#endif
bool bios_tty_logging : 1 = false;
bool bios_patch_fast_boot : 1 = DEFAULT_FAST_BOOT_VALUE;
bool bios_fast_forward_boot : 1 = false;
bool enable_8mb_ram : 1 = false;
bool gpu_dump_fast_replay_mode : 1 = false;
std::array<ControllerType, NUM_CONTROLLER_AND_CARD_PORTS> controller_types{};
std::array<MemoryCardType, NUM_CONTROLLER_AND_CARD_PORTS> memory_card_types{};
@ -306,33 +357,14 @@ struct Settings
std::string pcdrv_root;
bool pcdrv_enable_writes = false;
ALWAYS_INLINE bool IsUsingSoftwareRenderer() const { return (gpu_renderer == GPURenderer::Software); }
ALWAYS_INLINE bool IsUsingAccurateBlending() const { return (gpu_accurate_blending && !gpu_true_color); }
ALWAYS_INLINE bool IsRunaheadEnabled() const { return (runahead_frames > 0); }
ALWAYS_INLINE PGXPMode GetPGXPMode()
{
return gpu_pgxp_enable ? (gpu_pgxp_cpu ? PGXPMode::CPU : PGXPMode::Memory) : PGXPMode::Disabled;
}
ALWAYS_INLINE bool UsingPGXPDepthBuffer() const { return gpu_pgxp_enable && gpu_pgxp_depth_buffer; }
ALWAYS_INLINE bool UsingPGXPCPUMode() const { return gpu_pgxp_enable && gpu_pgxp_cpu; }
ALWAYS_INLINE float GetPGXPDepthClearThreshold() const
{
return gpu_pgxp_depth_clear_threshold * GPU_PGXP_DEPTH_THRESHOLD_SCALE;
}
ALWAYS_INLINE void SetPGXPDepthClearThreshold(float value)
{
gpu_pgxp_depth_clear_threshold = value / GPU_PGXP_DEPTH_THRESHOLD_SCALE;
}
ALWAYS_INLINE s32 GetAudioOutputVolume(bool fast_forwarding) const
{
return audio_output_muted ? 0 : (fast_forwarding ? audio_fast_forward_volume : audio_output_volume);
}
float GetDisplayAspectRatioValue() const;
ALWAYS_INLINE bool IsPort1MultitapEnabled() const
{
return (multitap_mode == MultitapMode::Port1Only || multitap_mode == MultitapMode::BothPorts);
@ -498,15 +530,7 @@ struct Settings
static const char* GetPIODeviceTypeModeName(PIODeviceType type);
static const char* GetPIODeviceTypeModeDisplayName(PIODeviceType type);
static constexpr GPURenderer DEFAULT_GPU_RENDERER = GPURenderer::Automatic;
static constexpr GPUTextureFilter DEFAULT_GPU_TEXTURE_FILTER = GPUTextureFilter::Nearest;
static constexpr GPULineDetectMode DEFAULT_GPU_LINE_DETECT_MODE = GPULineDetectMode::Disabled;
static constexpr GPUDownsampleMode DEFAULT_GPU_DOWNSAMPLE_MODE = GPUDownsampleMode::Disabled;
static constexpr GPUWireframeMode DEFAULT_GPU_WIREFRAME_MODE = GPUWireframeMode::Disabled;
static constexpr GPUDumpCompressionMode DEFAULT_GPU_DUMP_COMPRESSION_MODE = GPUDumpCompressionMode::ZstDefault;
static constexpr ConsoleRegion DEFAULT_CONSOLE_REGION = ConsoleRegion::Auto;
static constexpr float DEFAULT_GPU_PGXP_DEPTH_THRESHOLD = 300.0f;
static constexpr float GPU_PGXP_DEPTH_THRESHOLD_SCALE = 4096.0f;
// Prefer recompiler when supported.
#ifdef ENABLE_RECOMPILER
@ -524,21 +548,6 @@ struct Settings
static constexpr CPUFastmemMode DEFAULT_CPU_FASTMEM_MODE = CPUFastmemMode::LUT;
#endif
static constexpr DisplayDeinterlacingMode DEFAULT_DISPLAY_DEINTERLACING_MODE = DisplayDeinterlacingMode::Progressive;
static constexpr DisplayCropMode DEFAULT_DISPLAY_CROP_MODE = DisplayCropMode::Overscan;
static constexpr DisplayAspectRatio DEFAULT_DISPLAY_ASPECT_RATIO = DisplayAspectRatio::Auto;
static constexpr DisplayAlignment DEFAULT_DISPLAY_ALIGNMENT = DisplayAlignment::Center;
static constexpr DisplayRotation DEFAULT_DISPLAY_ROTATION = DisplayRotation::Normal;
static constexpr DisplayScalingMode DEFAULT_DISPLAY_SCALING = DisplayScalingMode::BilinearSmooth;
static constexpr ForceVideoTimingMode DEFAULT_FORCE_VIDEO_TIMING_MODE = ForceVideoTimingMode::Disabled;
static constexpr DisplayExclusiveFullscreenControl DEFAULT_DISPLAY_EXCLUSIVE_FULLSCREEN_CONTROL =
DisplayExclusiveFullscreenControl::Automatic;
static constexpr DisplayScreenshotMode DEFAULT_DISPLAY_SCREENSHOT_MODE = DisplayScreenshotMode::ScreenResolution;
static constexpr DisplayScreenshotFormat DEFAULT_DISPLAY_SCREENSHOT_FORMAT = DisplayScreenshotFormat::PNG;
static constexpr u8 DEFAULT_DISPLAY_SCREENSHOT_QUALITY = 85;
static constexpr float DEFAULT_DISPLAY_PRE_FRAME_SLEEP_BUFFER = 2.0f;
static constexpr float DEFAULT_OSD_SCALE = 100.0f;
static constexpr u8 DEFAULT_CDROM_READAHEAD_SECTORS = 8;
static constexpr CDROMMechaconVersion DEFAULT_CDROM_MECHACON_VERSION = CDROMMechaconVersion::VC1A;
@ -568,19 +577,14 @@ struct Settings
static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = true;
static constexpr bool DEFAULT_FAST_BOOT_VALUE = false;
static constexpr u16 DEFAULT_GDB_SERVER_PORT = 2345;
// TODO: Maybe lower? But that means fast CPU threads would always stall, could be a problem for power management.
static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 2;
#else
static constexpr bool DEFAULT_SAVE_STATE_BACKUPS = false;
static constexpr bool DEFAULT_FAST_BOOT_VALUE = true;
static constexpr u8 DEFAULT_GPU_MAX_QUEUED_FRAMES = 3;
#endif
};
// TODO: Use smaller copy for GPU thread copy.
ALIGN_TO_CACHE_LINE extern Settings g_settings; // CPU thread copy.
ALIGN_TO_CACHE_LINE extern Settings g_gpu_settings; // GPU thread copy.
ALIGN_TO_CACHE_LINE extern GPUSettings g_gpu_settings; // GPU thread copy.
namespace EmuFolders {
extern std::string AppRoot;

View File

@ -1827,8 +1827,8 @@ bool System::BootSystem(SystemBootParameters parameters, Error* error)
PlatformMisc::SuspendScreensaver();
#ifdef ENABLE_GDB_SERVER
if (g_settings.debugging.enable_gdb_server)
GDBServer::Initialize(g_settings.debugging.gdb_server_port);
if (g_settings.enable_gdb_server)
GDBServer::Initialize(g_settings.gdb_server_port);
#endif
Host::OnSystemStarted();
@ -4413,7 +4413,7 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
g_settings.display_active_end_offset != old_settings.display_active_end_offset ||
g_settings.display_line_start_offset != old_settings.display_line_start_offset ||
g_settings.display_line_end_offset != old_settings.display_line_end_offset ||
g_settings.debugging.show_vram != old_settings.debugging.show_vram ||
g_settings.gpu_show_vram != old_settings.gpu_show_vram ||
g_settings.rewind_enable != old_settings.rewind_enable ||
g_settings.runahead_frames != old_settings.runahead_frames ||
g_settings.texture_replacements.enable_texture_replacements !=
@ -4550,12 +4550,12 @@ void System::CheckForSettingsChanges(const Settings& old_settings)
}
#ifdef ENABLE_GDB_SERVER
if (g_settings.debugging.enable_gdb_server != old_settings.debugging.enable_gdb_server ||
g_settings.debugging.gdb_server_port != old_settings.debugging.gdb_server_port)
if (g_settings.enable_gdb_server != old_settings.enable_gdb_server ||
g_settings.gdb_server_port != old_settings.gdb_server_port)
{
GDBServer::Shutdown();
if (g_settings.debugging.enable_gdb_server)
GDBServer::Initialize(g_settings.debugging.gdb_server_port);
if (g_settings.enable_gdb_server)
GDBServer::Initialize(g_settings.gdb_server_port);
}
#endif
}
@ -5678,7 +5678,7 @@ void System::RequestDisplaySize(float scale /*= 0.0f*/)
scale = GPUBackend::IsUsingHardwareBackend() ? static_cast<float>(g_settings.gpu_resolution_scale) : 1.0f;
float requested_width, requested_height;
if (g_settings.debugging.show_vram)
if (g_settings.gpu_show_vram)
{
requested_width = static_cast<float>(VRAM_WIDTH) * scale;
requested_height = static_cast<float>(VRAM_HEIGHT) * scale;