From ec63663ad5a9ff2c7f2dd0659f3cc20f1ae293b2 Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 23 Sep 2015 12:25:38 +0200 Subject: [PATCH] More consistent handling of resolution changes. Should help #7995 --- GPU/Common/FramebufferCommon.cpp | 16 ++++++++++ GPU/Common/FramebufferCommon.h | 2 ++ GPU/Directx9/FramebufferDX9.cpp | 27 +++++++++++++++- GPU/GLES/Framebuffer.cpp | 35 +++++++++++++++++---- Windows/MainWindow.cpp | 53 -------------------------------- Windows/MainWindow.h | 1 - 6 files changed, 73 insertions(+), 61 deletions(-) diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 0d0d32abc7..3f034ad294 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -16,6 +16,9 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include + +#include "i18n/i18n.h" #include "Common/Common.h" #include "Core/Config.h" #include "Core/CoreParameter.h" @@ -25,6 +28,7 @@ #include "GPU/Common/FramebufferCommon.h" #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" +#include "UI/OnScreenDisplay.h" // Gross dependency! void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) { float outW; @@ -829,3 +833,15 @@ void FramebufferManagerCommon::UpdateFramebufUsage(VirtualFramebuffer *vfb) { checkFlag(FB_USAGE_TEXTURE, vfb->last_frame_used); checkFlag(FB_USAGE_RENDERTARGET, vfb->last_frame_render); } + +void FramebufferManagerCommon::ShowScreenResolution() { + I18NCategory *gr = GetI18NCategory("Graphics"); + + std::ostringstream messageStream; + messageStream << gr->T("Internal Resolution") << ": "; + messageStream << PSP_CoreParameter().renderWidth << "x" << PSP_CoreParameter().renderHeight << " "; + messageStream << gr->T("Window Size") << ": "; + messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight; + + osm.Show(messageStream.str(), 2.0f); +} \ No newline at end of file diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index 79053a032f..3602df8285 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -230,6 +230,8 @@ protected: virtual void NotifyRenderFramebufferSwitched(VirtualFramebuffer *prevVfb, VirtualFramebuffer *vfb, bool isClearingDepth) = 0; virtual void NotifyRenderFramebufferUpdated(VirtualFramebuffer *vfb, bool vfbFormatChanged) = 0; + void ShowScreenResolution(); + bool ShouldDownloadFramebuffer(const VirtualFramebuffer *vfb) const; void FindTransferFramebuffers(VirtualFramebuffer *&dstBuffer, VirtualFramebuffer *&srcBuffer, u32 dstBasePtr, int dstStride, int &dstX, int &dstY, u32 srcBasePtr, int srcStride, int &srcX, int &srcY, int &srcWidth, int &srcHeight, int &dstWidth, int &dstHeight, int bpp) const; diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index 5f1e6fecf0..e1302fdcdd 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -39,6 +39,8 @@ #include +void ShowScreenResolution(); + namespace DX9 { static void ConvertFromRGBA8888(u8 *dst, u8 *src, u32 dstStride, u32 srcStride, u32 width, u32 height, GEBufferFormat format); @@ -1107,13 +1109,36 @@ namespace DX9 { void FramebufferManagerDX9::EndFrame() { if (resized_) { DestroyAllFBOs(); - dxstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); + dxstate.viewport.set(0, 0, pixelWidth_, pixelHeight_); + // 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) { // auto mode + // Use the longest dimension + if (g_Config.IsPortrait()) { + zoom = (pixelWidth_ + 479) / 480; + } else { + zoom = (pixelHeight_ + 479) / 480; + } + } + if (zoom <= 1) + 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; + } + resized_ = false; } #if 0 // We flush to memory last requested framebuffer, if any PackFramebufferAsync_(NULL); #endif + ShowScreenResolution(); } void FramebufferManagerDX9::DeviceLost() { diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 9b41809612..d33fa41d4d 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -1653,18 +1653,41 @@ void FramebufferManager::PackFramebufferSync_(VirtualFramebuffer *vfb, int x, in fbo_unbind_read(); } +#ifdef _WIN32 +void ShowScreenResolution(); +#endif + void FramebufferManager::EndFrame() { if (resized_) { DestroyAllFBOs(); glstate.viewport.set(0, 0, pixelWidth_, pixelHeight_); -#ifndef _WIN32 // We do the same thing elsewhere + + // 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) // auto mode - zoom = (pixelWidth_ + 479) / 480; - PSP_CoreParameter().renderWidth = 480 * zoom; - PSP_CoreParameter().renderHeight = 272 * zoom; -#endif + if (zoom == 0) { // auto mode + // Use the longest dimension + if (g_Config.IsPortrait()) { + zoom = (pixelWidth_ + 479) / 480; + } else { + zoom = (pixelHeight_ + 479) / 480; + } + } + if (zoom <= 1) + 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; + } + resized_ = false; +#ifdef _WIN32 + ShowScreenResolution(); +#endif } #ifndef USING_GLES2 diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 10be6beaba..6d3358dd57 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -200,45 +200,6 @@ namespace MainWindow rcOuter.top = g_Config.iWindowY; } - static void ShowScreenResolution() { - I18NCategory *gr = GetI18NCategory("Graphics"); - - std::ostringstream messageStream; - messageStream << gr->T("Internal Resolution") << ": "; - messageStream << PSP_CoreParameter().renderWidth << "x" << PSP_CoreParameter().renderHeight << " "; - messageStream << gr->T("Window Size") << ": "; - messageStream << PSP_CoreParameter().pixelWidth << "x" << PSP_CoreParameter().pixelHeight; - - osm.Show(messageStream.str(), 2.0f); - } - - static void UpdateRenderResolution() { - RECT rc; - GetClientRect(hwndMain, &rc); - - // 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) { // auto mode - // Use the longest dimension - if (g_Config.IsPortrait()) { - zoom = (rc.bottom - rc.top + 479) / 480; - } else { - zoom = (rc.right - rc.left + 479) / 480; - } - } - if (zoom <= 1) - 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; - } - } - static bool IsWindowSmall() { // Can't take this from config as it will not be set if windows is maximized. RECT rc; @@ -259,7 +220,6 @@ namespace MainWindow GetWindowRectAtResolution(480 * (int)zoom, 272 * (int)zoom, rc, rcOuter); } MoveWindow(hwndMain, rcOuter.left, rcOuter.top, rcOuter.right - rcOuter.left, rcOuter.bottom - rcOuter.top, TRUE); - ShowScreenResolution(); } void SetInternalResolution(int res) { @@ -276,9 +236,6 @@ namespace MainWindow if (gpu) gpu->Resized(); - - UpdateRenderResolution(); - ShowScreenResolution(); } void CorrectCursor() { @@ -320,8 +277,6 @@ namespace MainWindow PSP_CoreParameter().pixelHeight = height; } - UpdateRenderResolution(); - if (UpdateScreenScale(width, height, IsWindowSmall())) { NativeMessageReceived("gpu resized", ""); } @@ -395,10 +350,6 @@ namespace MainWindow CorrectCursor(); - bool showOSM = (g_Config.iInternalResolution == RESOLUTION_AUTO); - if (showOSM) { - ShowScreenResolution(); - } ShowOwnedPopups(hwndMain, goingFullscreen ? FALSE : TRUE); W32Util::MakeTopMost(hwndMain, g_Config.bTopMost); @@ -902,10 +853,6 @@ namespace MainWindow TranslateMenus(hwndMain, menu); break; - case WM_USER_UPDATE_SCREEN: - ShowScreenResolution(); - break; - case WM_USER_WINDOW_TITLE_CHANGED: UpdateWindowTitle(); break; diff --git a/Windows/MainWindow.h b/Windows/MainWindow.h index 294993081a..d2459edfeb 100644 --- a/Windows/MainWindow.h +++ b/Windows/MainWindow.h @@ -11,7 +11,6 @@ namespace MainWindow enum { WM_USER_SAVESTATE_FINISH = WM_USER + 100, WM_USER_UPDATE_UI = WM_USER + 101, - WM_USER_UPDATE_SCREEN = WM_USER + 102, WM_USER_WINDOW_TITLE_CHANGED = WM_USER + 103, WM_USER_BROWSE_BOOT_DONE = WM_USER + 104, WM_USER_TOGGLE_FULLSCREEN = WM_USER + 105,