VideoCommon: support dynamically updating game mods at runtime
This commit is contained in:
parent
892678648e
commit
69839df1eb
|
@ -136,6 +136,22 @@ bool Renderer::Initialize()
|
|||
return false;
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.bGraphicMods)
|
||||
{
|
||||
// If a config change occurred in a previous session,
|
||||
// remember the old change count value. By setting
|
||||
// our current change count to the old value, we
|
||||
// avoid loading the stale data when we
|
||||
// check for config changes.
|
||||
const u32 old_game_mod_changes = g_ActiveConfig.graphics_mod_config ?
|
||||
g_ActiveConfig.graphics_mod_config->GetChangeCount() :
|
||||
0;
|
||||
g_ActiveConfig.graphics_mod_config = GraphicsModGroupConfig(SConfig::GetInstance().GetGameID());
|
||||
g_ActiveConfig.graphics_mod_config->Load();
|
||||
g_ActiveConfig.graphics_mod_config->SetChangeCount(old_game_mod_changes);
|
||||
m_graphics_mod_manager.Load(*g_ActiveConfig.graphics_mod_config);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -466,12 +482,27 @@ void Renderer::CheckForConfigChanges()
|
|||
const bool old_force_filtering = g_ActiveConfig.bForceFiltering;
|
||||
const bool old_vsync = g_ActiveConfig.bVSyncActive;
|
||||
const bool old_bbox = g_ActiveConfig.bBBoxEnable;
|
||||
const u32 old_game_mod_changes =
|
||||
g_ActiveConfig.graphics_mod_config ? g_ActiveConfig.graphics_mod_config->GetChangeCount() : 0;
|
||||
const bool old_graphics_mods_enabled = g_ActiveConfig.bGraphicMods;
|
||||
|
||||
UpdateActiveConfig();
|
||||
FreeLook::UpdateActiveConfig();
|
||||
|
||||
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
|
||||
|
||||
if (g_ActiveConfig.bGraphicMods && !old_graphics_mods_enabled)
|
||||
{
|
||||
g_ActiveConfig.graphics_mod_config = GraphicsModGroupConfig(SConfig::GetInstance().GetGameID());
|
||||
g_ActiveConfig.graphics_mod_config->Load();
|
||||
}
|
||||
|
||||
if (g_ActiveConfig.graphics_mod_config &&
|
||||
(old_game_mod_changes != g_ActiveConfig.graphics_mod_config->GetChangeCount()))
|
||||
{
|
||||
m_graphics_mod_manager.Load(*g_ActiveConfig.graphics_mod_config);
|
||||
}
|
||||
|
||||
// Update texture cache settings with any changed options.
|
||||
g_texture_cache->OnConfigChanged(g_ActiveConfig);
|
||||
|
||||
|
|
|
@ -154,6 +154,9 @@ void TextureCacheBase::OnConfigChanged(const VideoConfig& config)
|
|||
HiresTexture::Update();
|
||||
}
|
||||
|
||||
const u32 change_count =
|
||||
config.graphics_mod_config ? config.graphics_mod_config->GetChangeCount() : 0;
|
||||
|
||||
// TODO: Invalidating texcache is really stupid in some of these cases
|
||||
if (config.iSafeTextureCache_ColorSamples != backup_config.color_samples ||
|
||||
config.bTexFmtOverlayEnable != backup_config.texfmt_overlay ||
|
||||
|
@ -161,7 +164,9 @@ void TextureCacheBase::OnConfigChanged(const VideoConfig& config)
|
|||
config.bHiresTextures != backup_config.hires_textures ||
|
||||
config.bEnableGPUTextureDecoding != backup_config.gpu_texture_decoding ||
|
||||
config.bDisableCopyToVRAM != backup_config.disable_vram_copies ||
|
||||
config.bArbitraryMipmapDetection != backup_config.arbitrary_mipmap_detection)
|
||||
config.bArbitraryMipmapDetection != backup_config.arbitrary_mipmap_detection ||
|
||||
config.bGraphicMods != backup_config.graphics_mods ||
|
||||
change_count != backup_config.graphics_mod_change_count)
|
||||
{
|
||||
Invalidate();
|
||||
TexDecoder_SetTexFmtOverlayOptions(config.bTexFmtOverlayEnable, config.bTexFmtOverlayCenter);
|
||||
|
@ -257,6 +262,8 @@ void TextureCacheBase::SetBackupConfig(const VideoConfig& config)
|
|||
backup_config.disable_vram_copies = config.bDisableCopyToVRAM;
|
||||
backup_config.arbitrary_mipmap_detection = config.bArbitraryMipmapDetection;
|
||||
backup_config.graphics_mods = config.bGraphicMods;
|
||||
backup_config.graphics_mod_change_count =
|
||||
config.graphics_mod_config ? config.graphics_mod_config->GetChangeCount() : 0;
|
||||
}
|
||||
|
||||
TextureCacheBase::TCacheEntry*
|
||||
|
|
|
@ -378,6 +378,7 @@ private:
|
|||
bool disable_vram_copies;
|
||||
bool arbitrary_mipmap_detection;
|
||||
bool graphics_mods;
|
||||
u32 graphics_mod_change_count;
|
||||
};
|
||||
BackupConfig backup_config = {};
|
||||
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoCommon/GraphicsModSystem/Config/GraphicsModGroup.h"
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
|
||||
// Log in two categories, and save three other options in the same byte
|
||||
|
@ -112,6 +114,7 @@ struct VideoConfig final
|
|||
bool bEnableGPUTextureDecoding = false;
|
||||
int iBitrateKbps = 0;
|
||||
bool bGraphicMods = false;
|
||||
std::optional<GraphicsModGroupConfig> graphics_mod_config;
|
||||
|
||||
// Hacks
|
||||
bool bEFBAccessEnable = false;
|
||||
|
|
Loading…
Reference in New Issue