diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index b263b72131..fc94f32ab7 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -477,7 +477,7 @@ void GPUCommon::UpdateCmdInfo() { } void GPUCommon::BeginHostFrame() { - UpdateVsyncInterval(resized_); + UpdateVsyncInterval(displayResized_); ReapplyGfxState(); // TODO: Assume config may have changed - maybe move to resize. @@ -607,22 +607,39 @@ bool GPUCommon::BusyDrawing() { return false; } -void GPUCommon::Resized() { - resized_ = true; +void GPUCommon::NotifyConfigChanged() { + configChanged_ = true; +} + +void GPUCommon::NotifyRenderResized() { + renderResized_ = true; +} + +void GPUCommon::NotifyDisplayResized() { + displayResized_ = true; } // Called once per frame. Might also get called during the pause screen // if "transparent". void GPUCommon::CheckResized() { - if (resized_) { + if (configChanged_) { + ClearCacheNextFrame(); gstate_c.useFlags = CheckGPUFeatures(); - BuildReportingInfo(); - framebufferManager_->NotifyDisplayResized(); - framebufferManager_->NotifyRenderResized(); drawEngineCommon_->NotifyConfigChanged(); + shaderManager_->DirtyLastShader(); // Don't think this is needed, at all. textureCache_->NotifyConfigChanged(); - shaderManager_->DirtyLastShader(); - resized_ = false; + BuildReportingInfo(); + configChanged_ = false; + } + + if (displayResized_) { + framebufferManager_->NotifyDisplayResized(); + displayResized_ = false; + } + + if (renderResized_) { + framebufferManager_->NotifyRenderResized(); + renderResized_ = false; } } diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index 4c9a5d323f..d9e7246d08 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -97,7 +97,10 @@ public: interruptsEnabled_ = enable; } - void Resized() override; + void NotifyDisplayResized() override; + void NotifyRenderResized() override; + void NotifyConfigChanged() override; + void DumpNextFrame() override; void ExecuteOp(u32 op, u32 diff) override; @@ -357,7 +360,9 @@ protected: bool dumpThisFrame_ = false; bool debugRecording_; bool interruptsEnabled_; - bool resized_ = false; + bool displayResized_ = false; + bool renderResized_ = false; + bool configChanged_ = false; bool sawExactEqualDepth_ = false; DrawType lastDraw_ = DRAW_UNKNOWN; GEPrimitiveType lastPrim_ = GE_PRIM_INVALID; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index 69260e8625..8f7398aee6 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -255,7 +255,10 @@ public: virtual void DoState(PointerWrap &p) = 0; // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. - virtual void Resized() = 0; + virtual void NotifyDisplayResized() = 0; + virtual void NotifyRenderResized() = 0; + virtual void NotifyConfigChanged() = 0; + virtual void ClearShaderCache() = 0; virtual void CleanupBeforeUI() = 0; virtual bool FramebufferDirty() = 0; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 4c6ff090ee..2203c14ab9 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -445,7 +445,10 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw) presentation_ = new PresentationCommon(draw_); presentation_->SetLanguage(draw_->GetShaderLanguageDesc().shaderLanguage); } - Resized(); + + NotifyConfigChanged(); + NotifyRenderResized(); + NotifyDisplayResized(); } void SoftGPU::DeviceLost() { @@ -701,7 +704,7 @@ bool SoftGPU::ClearDirty(uint32_t addr, uint32_t bytes, SoftGPUVRAMDirty value) return result; } -void SoftGPU::Resized() { +void SoftGPU::NotifyRenderResized() { // Force the render params to 480x272 so other things work. if (g_Config.IsPortrait()) { PSP_CoreParameter().renderWidth = 272; @@ -710,7 +713,9 @@ void SoftGPU::Resized() { PSP_CoreParameter().renderWidth = 480; PSP_CoreParameter().renderHeight = 272; } +} +void SoftGPU::NotifyDisplayResized() { if (presentation_) { presentation_->UpdateDisplaySize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); presentation_->UpdateRenderSize(PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); @@ -718,6 +723,8 @@ void SoftGPU::Resized() { } } +void SoftGPU::NotifyConfigChanged() {} + void SoftGPU::FastRunLoop(DisplayList &list) { PROFILE_THIS_SCOPE("soft_runloop"); const auto *cmdInfo = softgpuCmdInfo; diff --git a/GPU/Software/SoftGpu.h b/GPU/Software/SoftGpu.h index 112d9af3a2..508baa6d0e 100644 --- a/GPU/Software/SoftGpu.h +++ b/GPU/Software/SoftGpu.h @@ -149,7 +149,10 @@ public: void DeviceLost() override; void DeviceRestore() override; - void Resized() override; + void NotifyRenderResized() override; + void NotifyDisplayResized() override; + void NotifyConfigChanged() override; + void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) override { primaryInfo = "Software"; fullInfo = "Software"; diff --git a/Qt/QtMain.cpp b/Qt/QtMain.cpp index bba1f1ae2b..f5a9300616 100644 --- a/Qt/QtMain.cpp +++ b/Qt/QtMain.cpp @@ -418,7 +418,7 @@ QString MainUI::InputBoxGetQString(QString title, QString defaultValue) { void MainUI::resizeGL(int w, int h) { if (UpdateScreenScale(w, h)) { - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_displayResized", ""); } xscale = w / this->width(); yscale = h / this->height(); diff --git a/Qt/mainwindow.h b/Qt/mainwindow.h index 864a658b58..fa7d3ceb6f 100644 --- a/Qt/mainwindow.h +++ b/Qt/mainwindow.h @@ -119,25 +119,26 @@ private slots: void moreSettingsAct() { NativeMessageReceived("settings", ""); } void bufferRenderAct() { - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_renderResized", ""); + NativeMessageReceived("gpu_configChanged", ""); } void linearAct() { g_Config.iTexFiltering = (g_Config.iTexFiltering != 0) ? 0 : 3; } void renderingResolutionGroup_triggered(QAction *action) { g_Config.iInternalResolution = action->data().toInt(); - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_renderResized", ""); } void windowGroup_triggered(QAction *action) { SetWindowScale(action->data().toInt()); } void displayLayoutGroup_triggered(QAction *action) { g_Config.iSmallDisplayZoomType = action->data().toInt(); - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_displayResized", ""); } void autoframeskipAct() { g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip; if (g_Config.bSkipBufferEffects) { g_Config.bSkipBufferEffects = false; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); } } void frameSkippingGroup_triggered(QAction *action) { g_Config.iFrameSkip = action->data().toInt(); } @@ -146,19 +147,19 @@ private slots: void screenScalingFilterGroup_triggered(QAction *action) { g_Config.iBufFilter = action->data().toInt(); } void textureScalingLevelGroup_triggered(QAction *action) { g_Config.iTexScalingLevel = action->data().toInt(); - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } void textureScalingTypeGroup_triggered(QAction *action) { g_Config.iTexScalingType = action->data().toInt(); - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } void deposterizeAct() { g_Config.bTexDeposterize = !g_Config.bTexDeposterize; - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } void transformAct() { g_Config.bHardwareTransform = !g_Config.bHardwareTransform; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); } void vertexCacheAct() { g_Config.bVertexCache = !g_Config.bVertexCache; } void frameskipAct() { g_Config.iFrameSkip = !g_Config.iFrameSkip; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index bfbc7edf8c..0ff7a9f0a9 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -660,7 +660,7 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { if (g_Config.bDumpFrames == g_Config.bDumpAudio) { g_Config.bDumpFrames = !g_Config.bDumpFrames; g_Config.bDumpAudio = !g_Config.bDumpAudio; - } else { + } else { // This hotkey should always toggle both audio and video together. // So let's make sure that's the only outcome even if video OR audio was already being dumped. if (g_Config.bDumpFrames) { @@ -705,7 +705,7 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { g_Config.bSaveNewTextures = !g_Config.bSaveNewTextures; if (g_Config.bSaveNewTextures) { osm.Show(sc->T("saveNewTextures_true", "Textures will now be saved to your storage"), 2.0); - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } else { osm.Show(sc->T("saveNewTextures_false", "Texture saving was disabled"), 2.0); } @@ -716,7 +716,7 @@ void EmuScreen::onVKeyDown(int virtualKeyCode) { osm.Show(sc->T("replaceTextures_true", "Texture replacement enabled"), 2.0); else osm.Show(sc->T("replaceTextures_false", "Textures no longer are being replaced"), 2.0); - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); break; case VIRTKEY_RAPID_FIRE: __CtrlSetRapidFire(true); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index abe73f5e7a..d3d2e60202 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1391,8 +1391,8 @@ void GameSettingsScreen::onFinish(DialogResult result) { KeyMap::UpdateNativeMenuKeys(); // Wipe some caches after potentially changing settings. - NativeMessageReceived("gpu_resized", ""); - NativeMessageReceived("gpu_clearCache", ""); + // Let's not send resize messages here, handled elsewhere. + NativeMessageReceived("gpu_configChanged", ""); } void GameSettingsScreen::sendMessage(const char *message, const char *value) { @@ -1717,7 +1717,8 @@ UI::EventReturn GameSettingsScreen::OnLanguageChange(UI::EventParams &e) { UI::EventReturn GameSettingsScreen::OnPostProcShaderChange(UI::EventParams &e) { g_Config.vPostShaderNames.erase(std::remove(g_Config.vPostShaderNames.begin(), g_Config.vPostShaderNames.end(), "Off"), g_Config.vPostShaderNames.end()); - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); + NativeMessageReceived("gpu_renderResized", ""); // To deal with shaders that can change render resolution like upscaling. NativeMessageReceived("postshader_updated", ""); return UI::EVENT_DONE; } @@ -1733,7 +1734,7 @@ UI::EventReturn GameSettingsScreen::OnTextureShader(UI::EventParams &e) { } UI::EventReturn GameSettingsScreen::OnTextureShaderChange(UI::EventParams &e) { - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); RecreateViews(); // Update setting name g_Config.bTexHardwareScaling = g_Config.sTextureShaderName != "Off"; return UI::EVENT_DONE; @@ -1903,7 +1904,7 @@ void DeveloperToolsScreen::CreateViews() { void DeveloperToolsScreen::onFinish(DialogResult result) { g_Config.Save("DeveloperToolsScreen::onFinish"); - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); } void GameSettingsScreen::CallbackRestoreDefaults(bool yes) { diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index 0bea47395a..1403515476 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1168,7 +1168,7 @@ void NativeRender(GraphicsContext *graphicsContext) { #if !PPSSPP_PLATFORM(WINDOWS) && !defined(ANDROID) PSP_CoreParameter().pixelWidth = pixel_xres; PSP_CoreParameter().pixelHeight = pixel_yres; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_displayResized", ""); #endif } else { // INFO_LOG(G3D, "Polling graphics context"); @@ -1189,10 +1189,10 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { if (msg == "inputDeviceConnectedID") { nextInputDeviceID = parseLong(value); } - if (msg == "inputDeviceConnected") { + else if (msg == "inputDeviceConnected") { KeyMap::NotifyPadConnected(nextInputDeviceID, value); } - if (msg == "bgImage_updated") { + else if (msg == "bgImage_updated") { if (!value.empty()) { Path dest = GetSysDirectory(DIRECTORY_SYSTEM) / (endsWithNoCase(value, ".jpg") ? "background.jpg" : "background.png"); File::Copy(Path(value), dest); @@ -1200,20 +1200,29 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { UIBackgroundShutdown(); // It will init again automatically. We can't init outside a frame on Vulkan. } - if (msg == "savestate_displayslot") { + else if (msg == "savestate_displayslot") { auto sy = GetI18NCategory("System"); std::string msg = StringFromFormat("%s: %d", sy->T("Savestate Slot"), SaveState::GetCurrentSlot() + 1); // Show for the same duration as the preview. osm.Show(msg, 2.0f, 0xFFFFFF, -1, true, "savestate_slot"); } - if (msg == "gpu_resized" || msg == "gpu_clearCache") { + else if (msg == "gpu_displayResized") { if (gpu) { - gpu->ClearCacheNextFrame(); - gpu->Resized(); + gpu->NotifyDisplayResized(); + } + } + else if (msg == "gpu_renderResized") { + if (gpu) { + gpu->NotifyRenderResized(); + } + } + else if (msg == "gpu_configChanged") { + if (gpu) { + gpu->NotifyConfigChanged(); } Reporting::UpdateConfig(); } - if (msg == "core_powerSaving") { + else if (msg == "core_powerSaving") { if (value != "false") { auto sy = GetI18NCategory("System"); #if PPSSPP_PLATFORM(ANDROID) @@ -1224,7 +1233,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { } Core_SetPowerSaving(value != "false"); } - if (msg == "permission_granted" && value == "storage") { + else if (msg == "permission_granted" && value == "storage") { #if PPSSPP_PLATFORM(ANDROID) CreateDirectoriesAndroid(); #endif @@ -1240,7 +1249,7 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) { PostLoadConfig(); g_Config.iGPUBackend = gpuBackend; } - if (msg == "app_resumed" || msg == "got_focus") { + else if (msg == "app_resumed" || msg == "got_focus") { // Assume that the user may have modified things. MemoryStick_NotifyWrite(); } @@ -1345,7 +1354,7 @@ bool NativeAxis(const AxisInput &axis) { // only handle tilt events if tilt is enabled. if (g_Config.iTiltInputType == TILT_NULL) { - // if tilt events are disabled, then run it through the usual way. + // if tilt events are disabled, then run it through the usual way. if (screenManager) { return screenManager->axis(axis); } else { @@ -1411,7 +1420,7 @@ bool NativeAxis(const AxisInput &axis) { currentTilt.y_ = -axis.value; } break; - + case JOYSTICK_AXIS_OUYA_UNKNOWN1: case JOYSTICK_AXIS_OUYA_UNKNOWN2: case JOYSTICK_AXIS_OUYA_UNKNOWN3: @@ -1433,7 +1442,7 @@ bool NativeAxis(const AxisInput &axis) { //then a value of 70-80 is the way to go. float xSensitivity = g_Config.iTiltSensitivityX / 50.0; float ySensitivity = g_Config.iTiltSensitivityY / 50.0; - + //now transform out current tilt to the calibrated coordinate system Tilt trueTilt = GenTilt(baseTilt, currentTilt, g_Config.bInvertTiltX, g_Config.bInvertTiltY, g_Config.fDeadzoneRadius, xSensitivity, ySensitivity); diff --git a/UWP/App.cpp b/UWP/App.cpp index aa850ae81a..13611a04f2 100644 --- a/UWP/App.cpp +++ b/UWP/App.cpp @@ -57,20 +57,20 @@ void App::Initialize(CoreApplicationView^ applicationView) { CoreApplication::Resuming += ref new EventHandler(this, &App::OnResuming); - // At this point we have access to the device. + // At this point we have access to the device. // We can create the device-dependent resources. m_deviceResources = std::make_shared(); } // Called when the CoreWindow object is created (or re-created). void App::SetWindow(CoreWindow^ window) { - window->SizeChanged += + window->SizeChanged += ref new TypedEventHandler(this, &App::OnWindowSizeChanged); window->VisibilityChanged += ref new TypedEventHandler(this, &App::OnVisibilityChanged); - window->Closed += + window->Closed += ref new TypedEventHandler(this, &App::OnWindowClosed); DisplayInformation^ currentDisplayInformation = DisplayInformation::GetForCurrentView(); @@ -267,7 +267,7 @@ void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ ar PSP_CoreParameter().pixelWidth = (int)(width * scale); PSP_CoreParameter().pixelHeight = (int)(height * scale); if (UpdateScreenScale((int)width, (int)height)) { - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_displayResized", ""); } } diff --git a/Windows/MainWindow.cpp b/Windows/MainWindow.cpp index 733e270db3..1eb68f441f 100644 --- a/Windows/MainWindow.cpp +++ b/Windows/MainWindow.cpp @@ -238,7 +238,7 @@ namespace MainWindow g_Config.iInternalResolution = 0; } - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_renderResized", ""); } void CorrectCursor() { @@ -302,7 +302,8 @@ namespace MainWindow DEBUG_LOG(SYSTEM, "Pixel width/height: %dx%d", PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); if (UpdateScreenScale(width, height)) { - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_displayResized", ""); + NativeMessageReceived("gpu_renderResized", ""); } // Don't save the window state if fullscreen. diff --git a/Windows/MainWindowMenu.cpp b/Windows/MainWindowMenu.cpp index b8e8b10c94..37c01cb3ed 100644 --- a/Windows/MainWindowMenu.cpp +++ b/Windows/MainWindowMenu.cpp @@ -472,7 +472,7 @@ namespace MainWindow { // not static void setTexScalingMultiplier(int level) { g_Config.iTexScalingLevel = level; - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } static void setTexFiltering(int type) { @@ -485,12 +485,12 @@ namespace MainWindow { static void setTexScalingType(int type) { g_Config.iTexScalingType = type; - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); } static void setSkipBufferEffects(bool skip) { g_Config.bSkipBufferEffects = skip; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); } static void setFrameSkipping(int framesToSkip = -1) { @@ -744,7 +744,7 @@ namespace MainWindow { g_Config.bAutoFrameSkip = !g_Config.bAutoFrameSkip; if (g_Config.bAutoFrameSkip && g_Config.bSkipBufferEffects) { g_Config.bSkipBufferEffects = false; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); } break; @@ -761,7 +761,7 @@ namespace MainWindow { case ID_TEXTURESCALING_DEPOSTERIZE: g_Config.bTexDeposterize = !g_Config.bTexDeposterize; - NativeMessageReceived("gpu_clearCache", ""); + NativeMessageReceived("gpu_configChanged", ""); break; case ID_OPTIONS_DIRECT3D9: @@ -790,7 +790,7 @@ namespace MainWindow { case ID_OPTIONS_SKIP_BUFFER_EFFECTS: g_Config.bSkipBufferEffects = !g_Config.bSkipBufferEffects; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); osm.ShowOnOff(gr->T("Skip Buffer Effects"), g_Config.bSkipBufferEffects); break; @@ -801,7 +801,7 @@ namespace MainWindow { case ID_OPTIONS_HARDWARETRANSFORM: g_Config.bHardwareTransform = !g_Config.bHardwareTransform; - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_configChanged", ""); osm.ShowOnOff(gr->T("Hardware Transform"), g_Config.bHardwareTransform); break; @@ -1045,7 +1045,7 @@ namespace MainWindow { g_Config.vPostShaderNames.push_back(availableShaders[index]); g_Config.bShaderChainRequires60FPS = PostShaderChainRequires60FPS(GetFullPostShadersChain(g_Config.vPostShaderNames)); - NativeMessageReceived("gpu_resized", ""); + NativeMessageReceived("gpu_renderResized", ""); NativeMessageReceived("postshader_updated", ""); break; }