From d9195c68b310c08c1df9c2fcef00379521191768 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 16 May 2020 00:31:14 -0700 Subject: [PATCH] GPU: Move calculating render res to presentation. Since it best understands what the first postshader wants. --- GPU/Common/FramebufferCommon.cpp | 40 ++++--------------------- GPU/Common/FramebufferCommon.h | 2 +- GPU/Common/PresentationCommon.cpp | 49 +++++++++++++++++++++++++++++++ GPU/Common/PresentationCommon.h | 2 ++ 4 files changed, 58 insertions(+), 35 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 8d3b0d42c4..e3701b6d48 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -1669,41 +1669,13 @@ void FramebufferManagerCommon::SetSafeSize(u16 w, u16 h) { } void FramebufferManagerCommon::Resized() { - // Check if postprocessing shader is doing upscaling as it requires native resolution - const ShaderInfo *shaderInfo = nullptr; - if (g_Config.sPostShaderName != "Off") { - shaderInfo = GetPostShaderInfo(g_Config.sPostShaderName); - } - - postShaderIsUpscalingFilter_ = shaderInfo ? shaderInfo->isUpscalingFilter : false; - postShaderSSAAFilterLevel_ = shaderInfo ? shaderInfo->SSAAFilterLevel : 0; - - // Actually, auto mode should be more granular... - // Round up to a zoom factor for the render size. - int zoom = g_Config.iInternalResolution; - if (zoom == 0 || postShaderSSAAFilterLevel_ >= 2) { - // auto mode, use the longest dimension - if (!g_Config.IsPortrait()) { - zoom = (PSP_CoreParameter().pixelWidth + 479) / 480; - } else { - zoom = (PSP_CoreParameter().pixelHeight + 479) / 480; - } - if (postShaderSSAAFilterLevel_ >= 2) - zoom *= postShaderSSAAFilterLevel_; - } - if (zoom <= 1 || postShaderIsUpscalingFilter_) - zoom = 1; - - if (g_Config.IsPortrait()) { - PSP_CoreParameter().renderWidth = 272 * zoom; - PSP_CoreParameter().renderHeight = 480 * zoom; - } else { - PSP_CoreParameter().renderWidth = 480 * zoom; - PSP_CoreParameter().renderHeight = 272 * zoom; - } - gstate_c.skipDrawReason &= ~SKIPDRAW_NON_DISPLAYED_FB; + int w, h; + presentation_->CalculateRenderResolution(&w, &h, &postShaderIsUpscalingFilter_, &postShaderIsSupersampling_); + PSP_CoreParameter().renderWidth = w; + PSP_CoreParameter().renderHeight = h; + if (UpdateSize()) { DestroyAllFBOs(); } @@ -1785,7 +1757,7 @@ void FramebufferManagerCommon::ShowScreenResolution() { messageStream << PSP_CoreParameter().renderWidth << "x" << PSP_CoreParameter().renderHeight << " "; if (postShaderIsUpscalingFilter_) { messageStream << gr->T("(upscaling)") << " "; - } else if (postShaderSSAAFilterLevel_ >= 2) { + } else if (postShaderIsSupersampling_) { messageStream << gr->T("(supersampling)") << " "; } messageStream << gr->T("Window Size") << ": "; diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 72cd4dd15d..f95a12670f 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -383,7 +383,7 @@ protected: bool useBufferedRendering_ = false; bool postShaderIsUpscalingFilter_ = false; - int postShaderSSAAFilterLevel_ = 0; + bool postShaderIsSupersampling_ = false; std::vector vfbs_; std::vector bvfbs_; // blitting framebuffers (for download) diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index 58b954a17a..7f3f08dc69 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -676,3 +676,52 @@ void PresentationCommon::CopyToOutput(OutputFlags flags, int uvRotation, float u draw_->BindPipeline(nullptr); } + +void PresentationCommon::CalculateRenderResolution(int *width, int *height, bool *upscaling, bool *ssaa) { + // Check if postprocessing shader is doing upscaling as it requires native resolution + std::vector shaderInfo; + if (g_Config.sPostShaderName != "Off") { + ReloadAllPostShaderInfo(); + shaderInfo = GetPostShaderChain(g_Config.sPostShaderName); + } + + bool firstIsUpscalingFilter = shaderInfo.empty() ? false : shaderInfo.front()->isUpscalingFilter; + int firstSSAAFilterLevel = shaderInfo.empty() ? 0 : shaderInfo.front()->SSAAFilterLevel; + + // Actually, auto mode should be more granular... + // Round up to a zoom factor for the render size. + int zoom = g_Config.iInternalResolution; + if (zoom == 0 || firstSSAAFilterLevel >= 2) { + // auto mode, use the longest dimension + if (!g_Config.IsPortrait()) { + zoom = (PSP_CoreParameter().pixelWidth + 479) / 480; + } else { + zoom = (PSP_CoreParameter().pixelHeight + 479) / 480; + } + if (firstSSAAFilterLevel >= 2) + zoom *= firstSSAAFilterLevel; + } + if (zoom <= 1 || firstIsUpscalingFilter) + zoom = 1; + + if (upscaling) { + *upscaling = firstIsUpscalingFilter; + for (auto &info : shaderInfo) { + *upscaling = *upscaling || info->isUpscalingFilter; + } + } + if (ssaa) { + *ssaa = firstSSAAFilterLevel >= 2; + for (auto &info : shaderInfo) { + *ssaa = *ssaa || info->SSAAFilterLevel >= 2; + } + } + + if (g_Config.IsPortrait()) { + *width = 272 * zoom; + *height = 480 * zoom; + } else { + *width = 480 * zoom; + *height = 272 * zoom; + } +} diff --git a/GPU/Common/PresentationCommon.h b/GPU/Common/PresentationCommon.h index cff644927d..eae2834abf 100644 --- a/GPU/Common/PresentationCommon.h +++ b/GPU/Common/PresentationCommon.h @@ -100,6 +100,8 @@ public: void SourceFramebuffer(Draw::Framebuffer *fb, int bufferWidth, int bufferHeight); void CopyToOutput(OutputFlags flags, int uvRotation, float u0, float v0, float u1, float v1); + void CalculateRenderResolution(int *width, int *height, bool *upscaling, bool *ssaa); + protected: void CreateDeviceObjects(); void DestroyDeviceObjects();