Move ConfigChanged out of RenderBase
There is this nice VideoConfig file that's perfect for it
This commit is contained in:
parent
ca5ec13e13
commit
9d125a6e43
|
@ -6,6 +6,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Common/MsgHandler.h"
|
||||||
|
|
||||||
#include "Core/HW/Memmap.h"
|
#include "Core/HW/Memmap.h"
|
||||||
#include "Core/System.h"
|
#include "Core/System.h"
|
||||||
|
|
|
@ -37,19 +37,6 @@ namespace VideoCommon
|
||||||
class AsyncShaderCompiler;
|
class AsyncShaderCompiler;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bitmask containing information about which configuration has changed for the backend.
|
|
||||||
enum ConfigChangeBits : u32
|
|
||||||
{
|
|
||||||
CONFIG_CHANGE_BIT_HOST_CONFIG = (1 << 0),
|
|
||||||
CONFIG_CHANGE_BIT_MULTISAMPLES = (1 << 1),
|
|
||||||
CONFIG_CHANGE_BIT_STEREO_MODE = (1 << 2),
|
|
||||||
CONFIG_CHANGE_BIT_TARGET_SIZE = (1 << 3),
|
|
||||||
CONFIG_CHANGE_BIT_ANISOTROPY = (1 << 4),
|
|
||||||
CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING = (1 << 5),
|
|
||||||
CONFIG_CHANGE_BIT_VSYNC = (1 << 6),
|
|
||||||
CONFIG_CHANGE_BIT_BBOX = (1 << 7)
|
|
||||||
};
|
|
||||||
|
|
||||||
using ClearColor = std::array<float, 4>;
|
using ClearColor = std::array<float, 4>;
|
||||||
|
|
||||||
class AbstractGfx
|
class AbstractGfx
|
||||||
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "VideoCommon/CommandProcessor.h"
|
#include "VideoCommon/CommandProcessor.h"
|
||||||
#include "VideoCommon/FrameDumper.h"
|
#include "VideoCommon/FrameDumper.h"
|
||||||
#include "VideoCommon/FramebufferManager.h"
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
#include "VideoCommon/FreeLookCamera.h"
|
|
||||||
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
#include "VideoCommon/PerformanceMetrics.h"
|
#include "VideoCommon/PerformanceMetrics.h"
|
||||||
|
@ -52,7 +51,6 @@
|
||||||
#include "VideoCommon/PixelShaderManager.h"
|
#include "VideoCommon/PixelShaderManager.h"
|
||||||
#include "VideoCommon/Present.h"
|
#include "VideoCommon/Present.h"
|
||||||
#include "VideoCommon/ShaderCache.h"
|
#include "VideoCommon/ShaderCache.h"
|
||||||
#include "VideoCommon/ShaderGenCommon.h"
|
|
||||||
#include "VideoCommon/Statistics.h"
|
#include "VideoCommon/Statistics.h"
|
||||||
#include "VideoCommon/VertexManagerBase.h"
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
@ -65,11 +63,7 @@ Renderer::Renderer()
|
||||||
m_last_xfb_width{MAX_XFB_WIDTH}, m_last_xfb_height{MAX_XFB_HEIGHT}
|
m_last_xfb_width{MAX_XFB_WIDTH}, m_last_xfb_height{MAX_XFB_HEIGHT}
|
||||||
{
|
{
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
FreeLook::UpdateActiveConfig();
|
|
||||||
CalculateTargetSize();
|
CalculateTargetSize();
|
||||||
|
|
||||||
m_is_game_widescreen = SConfig::GetInstance().bWii && Config::Get(Config::SYSCONF_WIDESCREEN);
|
|
||||||
g_freelook_camera.SetControlType(FreeLook::GetActiveConfig().camera_config.control_type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer() = default;
|
Renderer::~Renderer() = default;
|
||||||
|
@ -288,104 +282,6 @@ bool Renderer::CalculateTargetSize()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CheckForConfigChanges()
|
|
||||||
{
|
|
||||||
const ShaderHostConfig old_shader_host_config = ShaderHostConfig::GetCurrent();
|
|
||||||
const StereoMode old_stereo = g_ActiveConfig.stereo_mode;
|
|
||||||
const u32 old_multisamples = g_ActiveConfig.iMultisamples;
|
|
||||||
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
|
||||||
const int old_efb_access_tile_size = g_ActiveConfig.iEFBAccessTileSize;
|
|
||||||
const auto old_texture_filtering_mode = g_ActiveConfig.texture_filtering_mode;
|
|
||||||
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_vertex_manager->OnConfigChange();
|
|
||||||
|
|
||||||
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()))
|
|
||||||
{
|
|
||||||
g_graphics_mod_manager->Load(*g_ActiveConfig.graphics_mod_config);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update texture cache settings with any changed options.
|
|
||||||
g_texture_cache->OnConfigChanged(g_ActiveConfig);
|
|
||||||
|
|
||||||
// EFB tile cache doesn't need to notify the backend.
|
|
||||||
if (old_efb_access_tile_size != g_ActiveConfig.iEFBAccessTileSize)
|
|
||||||
g_framebuffer_manager->SetEFBCacheTileSize(std::max(g_ActiveConfig.iEFBAccessTileSize, 0));
|
|
||||||
|
|
||||||
// Determine which (if any) settings have changed.
|
|
||||||
ShaderHostConfig new_host_config = ShaderHostConfig::GetCurrent();
|
|
||||||
u32 changed_bits = 0;
|
|
||||||
if (old_shader_host_config.bits != new_host_config.bits)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_HOST_CONFIG;
|
|
||||||
if (old_stereo != g_ActiveConfig.stereo_mode)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_STEREO_MODE;
|
|
||||||
if (old_multisamples != g_ActiveConfig.iMultisamples)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_MULTISAMPLES;
|
|
||||||
if (old_anisotropy != g_ActiveConfig.iMaxAnisotropy)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_ANISOTROPY;
|
|
||||||
if (old_texture_filtering_mode != g_ActiveConfig.texture_filtering_mode)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING;
|
|
||||||
if (old_vsync != g_ActiveConfig.bVSyncActive)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_VSYNC;
|
|
||||||
if (old_bbox != g_ActiveConfig.bBBoxEnable)
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_BBOX;
|
|
||||||
if (CalculateTargetSize())
|
|
||||||
changed_bits |= CONFIG_CHANGE_BIT_TARGET_SIZE;
|
|
||||||
|
|
||||||
g_presenter->CheckForConfigChanges(changed_bits);
|
|
||||||
|
|
||||||
// No changes?
|
|
||||||
if (changed_bits == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Notify the backend of the changes, if any.
|
|
||||||
g_gfx->OnConfigChanged(changed_bits);
|
|
||||||
|
|
||||||
// If there's any shader changes, wait for the GPU to finish before destroying anything.
|
|
||||||
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
|
||||||
{
|
|
||||||
g_gfx->WaitForGPUIdle();
|
|
||||||
g_gfx->SetPipeline(nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Framebuffer changed?
|
|
||||||
if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE |
|
|
||||||
CONFIG_CHANGE_BIT_TARGET_SIZE))
|
|
||||||
{
|
|
||||||
g_framebuffer_manager->RecreateEFBFramebuffer();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Reload shaders if host config has changed.
|
|
||||||
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
|
||||||
{
|
|
||||||
OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
|
|
||||||
g_vertex_manager->InvalidatePipelineObject();
|
|
||||||
g_shader_cache->SetHostConfig(new_host_config);
|
|
||||||
g_shader_cache->Reload();
|
|
||||||
g_framebuffer_manager->RecompileShaders();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
|
||||||
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
|
||||||
{
|
|
||||||
BPFunctions::SetScissorAndViewport();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MathUtil::Rectangle<int> Renderer::ConvertEFBRectangle(const MathUtil::Rectangle<int>& rc) const
|
MathUtil::Rectangle<int> Renderer::ConvertEFBRectangle(const MathUtil::Rectangle<int>& rc) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,11 +108,10 @@ public:
|
||||||
// Will forcibly reload all textures on the next swap
|
// Will forcibly reload all textures on the next swap
|
||||||
void ForceReloadTextures();
|
void ForceReloadTextures();
|
||||||
|
|
||||||
protected:
|
|
||||||
std::tuple<int, int> CalculateTargetScale(int x, int y) const;
|
|
||||||
bool CalculateTargetSize();
|
bool CalculateTargetSize();
|
||||||
|
|
||||||
void CheckForConfigChanges();
|
protected:
|
||||||
|
std::tuple<int, int> CalculateTargetScale(int x, int y) const;
|
||||||
|
|
||||||
void CheckFifoRecording();
|
void CheckFifoRecording();
|
||||||
void RecordVideoMemory();
|
void RecordVideoMemory();
|
||||||
|
|
|
@ -8,12 +8,27 @@
|
||||||
#include "Common/CPUDetect.h"
|
#include "Common/CPUDetect.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Common/StringUtil.h"
|
#include "Common/StringUtil.h"
|
||||||
|
|
||||||
#include "Core/Config/GraphicsSettings.h"
|
#include "Core/Config/GraphicsSettings.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/Core.h"
|
#include "Core/Core.h"
|
||||||
#include "Core/Movie.h"
|
#include "Core/Movie.h"
|
||||||
|
|
||||||
|
#include "VideoCommon/AbstractGfx.h"
|
||||||
|
#include "VideoCommon/BPFunctions.h"
|
||||||
#include "VideoCommon/DriverDetails.h"
|
#include "VideoCommon/DriverDetails.h"
|
||||||
|
#include "VideoCommon/FramebufferManager.h"
|
||||||
|
#include "VideoCommon/FreeLookCamera.h"
|
||||||
|
#include "VideoCommon/GraphicsModSystem/Config/GraphicsMod.h"
|
||||||
|
#include "VideoCommon/GraphicsModSystem/Runtime/GraphicsModManager.h"
|
||||||
#include "VideoCommon/OnScreenDisplay.h"
|
#include "VideoCommon/OnScreenDisplay.h"
|
||||||
|
#include "VideoCommon/Present.h"
|
||||||
|
#include "VideoCommon/RenderBase.h"
|
||||||
|
#include "VideoCommon/ShaderGenCommon.h"
|
||||||
|
#include "VideoCommon/TextureCacheBase.h"
|
||||||
|
#include "VideoCommon/VertexManagerBase.h"
|
||||||
|
|
||||||
#include "VideoCommon/VideoCommon.h"
|
#include "VideoCommon/VideoCommon.h"
|
||||||
|
|
||||||
VideoConfig g_Config;
|
VideoConfig g_Config;
|
||||||
|
@ -227,3 +242,102 @@ u32 VideoConfig::GetShaderPrecompilerThreads() const
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckForConfigChanges()
|
||||||
|
{
|
||||||
|
const ShaderHostConfig old_shader_host_config = ShaderHostConfig::GetCurrent();
|
||||||
|
const StereoMode old_stereo = g_ActiveConfig.stereo_mode;
|
||||||
|
const u32 old_multisamples = g_ActiveConfig.iMultisamples;
|
||||||
|
const int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
||||||
|
const int old_efb_access_tile_size = g_ActiveConfig.iEFBAccessTileSize;
|
||||||
|
const auto old_texture_filtering_mode = g_ActiveConfig.texture_filtering_mode;
|
||||||
|
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_vertex_manager->OnConfigChange();
|
||||||
|
|
||||||
|
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()))
|
||||||
|
{
|
||||||
|
g_graphics_mod_manager->Load(*g_ActiveConfig.graphics_mod_config);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update texture cache settings with any changed options.
|
||||||
|
g_texture_cache->OnConfigChanged(g_ActiveConfig);
|
||||||
|
|
||||||
|
// EFB tile cache doesn't need to notify the backend.
|
||||||
|
if (old_efb_access_tile_size != g_ActiveConfig.iEFBAccessTileSize)
|
||||||
|
g_framebuffer_manager->SetEFBCacheTileSize(std::max(g_ActiveConfig.iEFBAccessTileSize, 0));
|
||||||
|
|
||||||
|
// Determine which (if any) settings have changed.
|
||||||
|
ShaderHostConfig new_host_config = ShaderHostConfig::GetCurrent();
|
||||||
|
u32 changed_bits = 0;
|
||||||
|
if (old_shader_host_config.bits != new_host_config.bits)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_HOST_CONFIG;
|
||||||
|
if (old_stereo != g_ActiveConfig.stereo_mode)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_STEREO_MODE;
|
||||||
|
if (old_multisamples != g_ActiveConfig.iMultisamples)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_MULTISAMPLES;
|
||||||
|
if (old_anisotropy != g_ActiveConfig.iMaxAnisotropy)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_ANISOTROPY;
|
||||||
|
if (old_texture_filtering_mode != g_ActiveConfig.texture_filtering_mode)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING;
|
||||||
|
if (old_vsync != g_ActiveConfig.bVSyncActive)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_VSYNC;
|
||||||
|
if (old_bbox != g_ActiveConfig.bBBoxEnable)
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_BBOX;
|
||||||
|
if (g_renderer->CalculateTargetSize())
|
||||||
|
changed_bits |= CONFIG_CHANGE_BIT_TARGET_SIZE;
|
||||||
|
|
||||||
|
g_presenter->CheckForConfigChanges(changed_bits);
|
||||||
|
|
||||||
|
// No changes?
|
||||||
|
if (changed_bits == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Notify the backend of the changes, if any.
|
||||||
|
g_gfx->OnConfigChanged(changed_bits);
|
||||||
|
|
||||||
|
// If there's any shader changes, wait for the GPU to finish before destroying anything.
|
||||||
|
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
||||||
|
{
|
||||||
|
g_gfx->WaitForGPUIdle();
|
||||||
|
g_gfx->SetPipeline(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Framebuffer changed?
|
||||||
|
if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE |
|
||||||
|
CONFIG_CHANGE_BIT_TARGET_SIZE))
|
||||||
|
{
|
||||||
|
g_framebuffer_manager->RecreateEFBFramebuffer();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reload shaders if host config has changed.
|
||||||
|
if (changed_bits & (CONFIG_CHANGE_BIT_HOST_CONFIG | CONFIG_CHANGE_BIT_MULTISAMPLES))
|
||||||
|
{
|
||||||
|
OSD::AddMessage("Video config changed, reloading shaders.", OSD::Duration::NORMAL);
|
||||||
|
g_vertex_manager->InvalidatePipelineObject();
|
||||||
|
g_shader_cache->SetHostConfig(new_host_config);
|
||||||
|
g_shader_cache->Reload();
|
||||||
|
g_framebuffer_manager->RecompileShaders();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Viewport and scissor rect have to be reset since they will be scaled differently.
|
||||||
|
if (changed_bits & CONFIG_CHANGE_BIT_TARGET_SIZE)
|
||||||
|
{
|
||||||
|
BPFunctions::SetScissorAndViewport();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,20 @@ enum class TriState : int
|
||||||
Auto
|
Auto
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Bitmask containing information about which configuration has changed for the backend.
|
||||||
|
enum ConfigChangeBits : u32
|
||||||
|
{
|
||||||
|
CONFIG_CHANGE_BIT_HOST_CONFIG = (1 << 0),
|
||||||
|
CONFIG_CHANGE_BIT_MULTISAMPLES = (1 << 1),
|
||||||
|
CONFIG_CHANGE_BIT_STEREO_MODE = (1 << 2),
|
||||||
|
CONFIG_CHANGE_BIT_TARGET_SIZE = (1 << 3),
|
||||||
|
CONFIG_CHANGE_BIT_ANISOTROPY = (1 << 4),
|
||||||
|
CONFIG_CHANGE_BIT_FORCE_TEXTURE_FILTERING = (1 << 5),
|
||||||
|
CONFIG_CHANGE_BIT_VSYNC = (1 << 6),
|
||||||
|
CONFIG_CHANGE_BIT_BBOX = (1 << 7)
|
||||||
|
};
|
||||||
|
|
||||||
// NEVER inherit from this class.
|
// NEVER inherit from this class.
|
||||||
struct VideoConfig final
|
struct VideoConfig final
|
||||||
{
|
{
|
||||||
|
@ -307,3 +321,4 @@ extern VideoConfig g_ActiveConfig;
|
||||||
|
|
||||||
// Called every frame.
|
// Called every frame.
|
||||||
void UpdateActiveConfig();
|
void UpdateActiveConfig();
|
||||||
|
void CheckForConfigChanges();
|
||||||
|
|
Loading…
Reference in New Issue