VideoCommon: Move last EFB scale handling to CalculateTargetSize
This commit is contained in:
parent
afc25fdca0
commit
00a0a91513
|
@ -865,7 +865,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
|
||||
// Resize the back buffers NOW to avoid flickering
|
||||
if (CalculateTargetSize() || xfbchanged || windowResized ||
|
||||
m_last_efb_scale != g_ActiveConfig.iEFBScale ||
|
||||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
|
||||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||
{
|
||||
|
@ -885,11 +884,8 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
|
||||
UpdateDrawRectangle();
|
||||
|
||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
|
||||
D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr);
|
||||
|
||||
g_framebuffer_manager.reset();
|
||||
|
|
|
@ -153,7 +153,6 @@ void VideoBackend::Video_Prepare()
|
|||
g_texture_cache = std::make_unique<TextureCache>();
|
||||
g_vertex_manager = std::make_unique<VertexManager>();
|
||||
g_perf_query = std::make_unique<PerfQuery>();
|
||||
g_renderer->InitializeCommon();
|
||||
VertexShaderCache::Init();
|
||||
PixelShaderCache::Init();
|
||||
GeometryShaderCache::Init();
|
||||
|
|
|
@ -821,7 +821,6 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||
|
||||
// Resize the back buffers NOW to avoid flickering
|
||||
if (CalculateTargetSize() || xfb_changed || window_resized ||
|
||||
m_last_efb_scale != g_ActiveConfig.iEFBScale ||
|
||||
s_last_multisamples != g_ActiveConfig.iMultisamples ||
|
||||
s_last_stereo_mode != (g_ActiveConfig.iStereoMode > 0))
|
||||
{
|
||||
|
@ -854,11 +853,8 @@ void Renderer::SwapImpl(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height
|
|||
|
||||
UpdateDrawRectangle();
|
||||
|
||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
s_last_stereo_mode = g_ActiveConfig.iStereoMode > 0;
|
||||
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
|
||||
D3D::GetBackBuffer()->TransitionToResourceState(D3D::current_command_list,
|
||||
D3D12_RESOURCE_STATE_RENDER_TARGET);
|
||||
D3D::current_command_list->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV12(), FALSE,
|
||||
|
|
|
@ -168,7 +168,6 @@ void VideoBackend::Video_Prepare()
|
|||
g_vertex_manager = std::make_unique<VertexManager>();
|
||||
g_perf_query = std::make_unique<PerfQuery>();
|
||||
g_xfb_encoder = std::make_unique<XFBEncoder>();
|
||||
g_renderer->InitializeCommon();
|
||||
ShaderCache::Init();
|
||||
ShaderConstantsManager::Init();
|
||||
StaticShaderCache::Init();
|
||||
|
|
|
@ -67,7 +67,6 @@ void VideoBackend::Video_Prepare()
|
|||
g_perf_query = std::make_unique<PerfQuery>();
|
||||
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
||||
g_texture_cache = std::make_unique<TextureCache>();
|
||||
g_renderer->InitializeCommon();
|
||||
VertexShaderCache::s_instance = std::make_unique<VertexShaderCache>();
|
||||
GeometryShaderCache::s_instance = std::make_unique<GeometryShaderCache>();
|
||||
PixelShaderCache::s_instance = std::make_unique<PixelShaderCache>();
|
||||
|
|
|
@ -773,8 +773,6 @@ void Renderer::Shutdown()
|
|||
|
||||
void Renderer::Init()
|
||||
{
|
||||
InitializeCommon();
|
||||
|
||||
// Initialize the FramebufferManager
|
||||
g_framebuffer_manager =
|
||||
std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
|
||||
|
@ -1353,13 +1351,11 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
bool window_resized = false;
|
||||
int window_width = static_cast<int>(std::max(GLInterface->GetBackBufferWidth(), 1u));
|
||||
int window_height = static_cast<int>(std::max(GLInterface->GetBackBufferHeight(), 1u));
|
||||
if (window_width != m_backbuffer_width || window_height != m_backbuffer_height ||
|
||||
m_last_efb_scale != g_ActiveConfig.iEFBScale)
|
||||
if (window_width != m_backbuffer_width || window_height != m_backbuffer_height)
|
||||
{
|
||||
window_resized = true;
|
||||
m_backbuffer_width = window_width;
|
||||
m_backbuffer_height = window_height;
|
||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
}
|
||||
|
||||
bool target_size_changed = CalculateTargetSize();
|
||||
|
@ -1390,8 +1386,6 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight,
|
|||
g_framebuffer_manager.reset();
|
||||
g_framebuffer_manager =
|
||||
std::make_unique<FramebufferManager>(m_target_width, m_target_height, s_MSAASamples);
|
||||
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -181,7 +181,6 @@ void VideoSoftware::Video_Prepare()
|
|||
g_vertex_manager = std::make_unique<SWVertexLoader>();
|
||||
g_perf_query = std::make_unique<PerfQuery>();
|
||||
g_texture_cache = std::make_unique<TextureCache>();
|
||||
g_renderer->InitializeCommon();
|
||||
SWRenderer::Init();
|
||||
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
||||
}
|
||||
|
|
|
@ -1012,10 +1012,7 @@ void Renderer::CheckForTargetResize(u32 fb_width, u32 fb_stride, u32 fb_height)
|
|||
|
||||
// Changing the XFB source area may alter the target size.
|
||||
if (CalculateTargetSize())
|
||||
{
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
ResizeEFBTextures();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::CheckForSurfaceChange()
|
||||
|
@ -1095,6 +1092,7 @@ void Renderer::CheckForConfigChanges()
|
|||
int old_anisotropy = g_ActiveConfig.iMaxAnisotropy;
|
||||
int old_stereo_mode = g_ActiveConfig.iStereoMode;
|
||||
int old_aspect_ratio = g_ActiveConfig.iAspectRatio;
|
||||
int old_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
bool old_force_filtering = g_ActiveConfig.bForceFiltering;
|
||||
bool old_ssaa = g_ActiveConfig.bSSAA;
|
||||
bool old_use_xfb = g_ActiveConfig.bUseXFB;
|
||||
|
@ -1111,7 +1109,7 @@ void Renderer::CheckForConfigChanges()
|
|||
bool anisotropy_changed = old_anisotropy != g_ActiveConfig.iMaxAnisotropy;
|
||||
bool force_texture_filtering_changed = old_force_filtering != g_ActiveConfig.bForceFiltering;
|
||||
bool stereo_changed = old_stereo_mode != g_ActiveConfig.iStereoMode;
|
||||
bool efb_scale_changed = m_last_efb_scale != g_ActiveConfig.iEFBScale;
|
||||
bool efb_scale_changed = old_efb_scale != g_ActiveConfig.iEFBScale;
|
||||
bool aspect_changed = old_aspect_ratio != g_ActiveConfig.iAspectRatio;
|
||||
bool use_xfb_changed = old_use_xfb != g_ActiveConfig.bUseXFB;
|
||||
bool use_realxfb_changed = old_use_realxfb != g_ActiveConfig.bUseRealXFB;
|
||||
|
@ -1122,7 +1120,6 @@ void Renderer::CheckForConfigChanges()
|
|||
// Handle settings that can cause the target rectangle to change.
|
||||
if (efb_scale_changed || aspect_changed || use_xfb_changed || use_realxfb_changed)
|
||||
{
|
||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
if (CalculateTargetSize())
|
||||
ResizeEFBTextures();
|
||||
}
|
||||
|
@ -1166,10 +1163,7 @@ void Renderer::OnSwapChainResized()
|
|||
m_backbuffer_height = m_swap_chain->GetHeight();
|
||||
UpdateDrawRectangle();
|
||||
if (CalculateTargetSize())
|
||||
{
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
ResizeEFBTextures();
|
||||
}
|
||||
}
|
||||
|
||||
void Renderer::BindEFBToStateTracker()
|
||||
|
|
|
@ -49,7 +49,7 @@ void PixelShaderManager::Dirty()
|
|||
// Any constants that can changed based on settings should be re-calculated
|
||||
s_bFogRangeAdjustChanged = true;
|
||||
|
||||
SetEfbScaleChanged();
|
||||
SetEfbScaleChanged(g_renderer->EFBToScaledXf(1), g_renderer->EFBToScaledYf(1));
|
||||
SetFogParamChanged();
|
||||
|
||||
dirty = true;
|
||||
|
@ -159,10 +159,10 @@ void PixelShaderManager::SetViewportChanged()
|
|||
true; // TODO: Shouldn't be necessary with an accurate fog range adjust implementation
|
||||
}
|
||||
|
||||
void PixelShaderManager::SetEfbScaleChanged()
|
||||
void PixelShaderManager::SetEfbScaleChanged(float scalex, float scaley)
|
||||
{
|
||||
constants.efbscale[0] = 1.0f / g_renderer->EFBToScaledXf(1);
|
||||
constants.efbscale[1] = 1.0f / g_renderer->EFBToScaledYf(1);
|
||||
constants.efbscale[0] = 1.0f / scalex;
|
||||
constants.efbscale[1] = 1.0f / scaley;
|
||||
dirty = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ public:
|
|||
static void SetTexDims(int texmapid, u32 width, u32 height);
|
||||
static void SetZTextureBias();
|
||||
static void SetViewportChanged();
|
||||
static void SetEfbScaleChanged();
|
||||
static void SetEfbScaleChanged(float scalex, float scaley);
|
||||
static void SetZSlope(float dfdx, float dfdy, float f0);
|
||||
static void SetIndMatrixChanged(int matrixidx);
|
||||
static void SetZTextureTypeChanged();
|
||||
|
|
|
@ -166,6 +166,8 @@ bool Renderer::CalculateTargetSize()
|
|||
int newEFBWidth, newEFBHeight;
|
||||
newEFBWidth = newEFBHeight = 0;
|
||||
|
||||
m_last_efb_scale = g_ActiveConfig.iEFBScale;
|
||||
|
||||
// TODO: Ugly. Clean up
|
||||
switch (m_last_efb_scale)
|
||||
{
|
||||
|
@ -231,6 +233,7 @@ bool Renderer::CalculateTargetSize()
|
|||
{
|
||||
m_target_width = newEFBWidth;
|
||||
m_target_height = newEFBHeight;
|
||||
PixelShaderManager::SetEfbScaleChanged(EFBToScaledXf(1), EFBToScaledYf(1));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -614,11 +617,6 @@ void Renderer::UpdateDrawRectangle()
|
|||
m_target_rectangle.bottom = YOffset + iHeight;
|
||||
}
|
||||
|
||||
void Renderer::InitializeCommon()
|
||||
{
|
||||
PixelShaderManager::SetEfbScaleChanged();
|
||||
}
|
||||
|
||||
void Renderer::SetWindowSize(int width, int height)
|
||||
{
|
||||
if (width < 1)
|
||||
|
|
|
@ -79,10 +79,6 @@ public:
|
|||
virtual void RestoreState() {}
|
||||
virtual void ResetAPIState() {}
|
||||
virtual void RestoreAPIState() {}
|
||||
// Some of the methods called by here assume g_renderer is initialized, therefore
|
||||
// we must call it after constructing the backend's Renderer instance.
|
||||
void InitializeCommon();
|
||||
|
||||
// Ideal internal resolution - determined by display resolution (automatic scaling) and/or a
|
||||
// multiple of the native EFB resolution
|
||||
int GetTargetWidth() { return m_target_width; }
|
||||
|
|
Loading…
Reference in New Issue