VideoCommon: pass the EFB buffer scale into the FramebufferManager instead of pulling it from config, in the future this will allow us to have multiple framebuffers

This commit is contained in:
iwubcode 2025-11-05 21:52:54 -06:00
parent 2170080f53
commit 2f20c12d82
5 changed files with 17 additions and 16 deletions

View File

@ -45,9 +45,9 @@ FramebufferManager::~FramebufferManager()
DestroyEFBFramebuffer(); DestroyEFBFramebuffer();
} }
bool FramebufferManager::Initialize() bool FramebufferManager::Initialize(int efb_scale)
{ {
if (!CreateEFBFramebuffer()) if (!CreateEFBFramebuffer(efb_scale))
{ {
PanicAlertFmt("Failed to create EFB framebuffer"); PanicAlertFmt("Failed to create EFB framebuffer");
return false; return false;
@ -90,14 +90,14 @@ bool FramebufferManager::Initialize()
return true; return true;
} }
void FramebufferManager::RecreateEFBFramebuffer() void FramebufferManager::RecreateEFBFramebuffer(int efb_scale)
{ {
FlushEFBPokes(); FlushEFBPokes();
InvalidatePeekCache(true); InvalidatePeekCache(true);
DestroyReadbackFramebuffer(); DestroyReadbackFramebuffer();
DestroyEFBFramebuffer(); DestroyEFBFramebuffer();
if (!CreateEFBFramebuffer() || !CreateReadbackFramebuffer()) if (!CreateEFBFramebuffer(efb_scale) || !CreateReadbackFramebuffer())
PanicAlertFmt("Failed to recreate EFB framebuffer"); PanicAlertFmt("Failed to recreate EFB framebuffer");
} }
@ -210,12 +210,12 @@ float FramebufferManager::EFBToScaledYf(float y) const
return y * ((float)GetEFBHeight() / (float)EFB_HEIGHT); return y * ((float)GetEFBHeight() / (float)EFB_HEIGHT);
} }
std::tuple<u32, u32> FramebufferManager::CalculateTargetSize() std::tuple<u32, u32> FramebufferManager::CalculateTargetSize(int efb_scale)
{ {
if (g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL) if (efb_scale == EFB_SCALE_AUTO_INTEGRAL)
m_efb_scale = g_presenter->AutoIntegralScale(); m_efb_scale = g_presenter->AutoIntegralScale();
else else
m_efb_scale = g_ActiveConfig.iEFBScale; m_efb_scale = efb_scale;
const u32 max_size = g_backend_info.MaxTextureSize; const u32 max_size = g_backend_info.MaxTextureSize;
if (max_size < EFB_WIDTH * m_efb_scale) if (max_size < EFB_WIDTH * m_efb_scale)
@ -227,9 +227,9 @@ std::tuple<u32, u32> FramebufferManager::CalculateTargetSize()
return std::make_tuple(new_efb_width, new_efb_height); return std::make_tuple(new_efb_width, new_efb_height);
} }
bool FramebufferManager::CreateEFBFramebuffer() bool FramebufferManager::CreateEFBFramebuffer(int efb_scale)
{ {
auto [width, height] = CalculateTargetSize(); auto [width, height] = CalculateTargetSize(efb_scale);
const TextureConfig efb_color_texture_config = GetEFBColorTextureConfig(width, height); const TextureConfig efb_color_texture_config = GetEFBColorTextureConfig(width, height);
const TextureConfig efb_depth_texture_config = GetEFBDepthTextureConfig(width, height); const TextureConfig efb_depth_texture_config = GetEFBDepthTextureConfig(width, height);

View File

@ -85,10 +85,10 @@ public:
float EFBToScaledYf(float y) const; float EFBToScaledYf(float y) const;
// First-time setup. // First-time setup.
bool Initialize(); bool Initialize(int efb_scale);
// Recreate EFB framebuffers, call when the EFB size (IR) changes. // Recreate EFB framebuffers, call when the EFB size (IR) changes.
void RecreateEFBFramebuffer(); void RecreateEFBFramebuffer(int efb_scale);
// Recompile shaders, use when MSAA mode changes. // Recompile shaders, use when MSAA mode changes.
void RecompileShaders(); void RecompileShaders();
@ -160,7 +160,7 @@ protected:
bool needs_flush; bool needs_flush;
}; };
bool CreateEFBFramebuffer(); bool CreateEFBFramebuffer(int efb_scale);
void DestroyEFBFramebuffer(); void DestroyEFBFramebuffer();
bool CompileConversionPipelines(); bool CompileConversionPipelines();
@ -189,7 +189,7 @@ protected:
void DrawPokeVertices(const EFBPokeVertex* vertices, u32 vertex_count, void DrawPokeVertices(const EFBPokeVertex* vertices, u32 vertex_count,
const AbstractPipeline* pipeline); const AbstractPipeline* pipeline);
std::tuple<u32, u32> CalculateTargetSize(); std::tuple<u32, u32> CalculateTargetSize(int efb_scale);
void DoLoadState(PointerWrap& p); void DoLoadState(PointerWrap& p);
void DoSaveState(PointerWrap& p); void DoSaveState(PointerWrap& p);

View File

@ -329,7 +329,7 @@ void Presenter::OnBackbufferSet(bool size_changed, bool is_first_set)
if (size_changed && !is_first_set && g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL && if (size_changed && !is_first_set && g_ActiveConfig.iEFBScale == EFB_SCALE_AUTO_INTEGRAL &&
m_auto_resolution_scale != AutoIntegralScale()) m_auto_resolution_scale != AutoIntegralScale())
{ {
g_framebuffer_manager->RecreateEFBFramebuffer(); g_framebuffer_manager->RecreateEFBFramebuffer(g_ActiveConfig.iEFBScale);
} }
if (size_changed || is_first_set) if (size_changed || is_first_set)
{ {

View File

@ -310,7 +310,8 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() || if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() ||
!g_perf_query->Initialize() || !g_presenter->Initialize() || !g_perf_query->Initialize() || !g_presenter->Initialize() ||
!g_framebuffer_manager->Initialize() || !g_texture_cache->Initialize() || !g_framebuffer_manager->Initialize(g_ActiveConfig.iEFBScale) ||
!g_texture_cache->Initialize() ||
(g_backend_info.bSupportsBBox && !g_bounding_box->Initialize()) || (g_backend_info.bSupportsBBox && !g_bounding_box->Initialize()) ||
!g_graphics_mod_manager->Initialize()) !g_graphics_mod_manager->Initialize())
{ {

View File

@ -369,7 +369,7 @@ void CheckForConfigChanges()
if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE | if (changed_bits & (CONFIG_CHANGE_BIT_MULTISAMPLES | CONFIG_CHANGE_BIT_STEREO_MODE |
CONFIG_CHANGE_BIT_TARGET_SIZE | CONFIG_CHANGE_BIT_HDR)) CONFIG_CHANGE_BIT_TARGET_SIZE | CONFIG_CHANGE_BIT_HDR))
{ {
g_framebuffer_manager->RecreateEFBFramebuffer(); g_framebuffer_manager->RecreateEFBFramebuffer(g_ActiveConfig.iEFBScale);
} }
if (old_scale != g_framebuffer_manager->GetEFBScale()) if (old_scale != g_framebuffer_manager->GetEFBScale())