diff --git a/Common/GPU/Vulkan/VulkanRenderManager.h b/Common/GPU/Vulkan/VulkanRenderManager.h index 29fda811e7..1f7dad7f53 100644 --- a/Common/GPU/Vulkan/VulkanRenderManager.h +++ b/Common/GPU/Vulkan/VulkanRenderManager.h @@ -290,6 +290,10 @@ public: compileMutex_.unlock(); } + void AssertInRenderPass() const { + _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); + } + // This is the first call in a draw operation. Instead of asserting like we used to, you can now check the // return value and skip the draw if we're in a bad state. In that case, call ReportBadState. // The old assert wasn't very helpful in figuring out what caused it anyway... diff --git a/Common/Render/DrawBuffer.cpp b/Common/Render/DrawBuffer.cpp index 5310dd612b..a6503d3236 100644 --- a/Common/Render/DrawBuffer.cpp +++ b/Common/Render/DrawBuffer.cpp @@ -534,6 +534,7 @@ void DrawBuffer::MeasureTextRect(FontID font_id, std::string_view text, const Bo std::string toMeasure = std::string(text); AtlasWordWrapper wrapper(*font, fontscalex, toMeasure, bounds.w, wrap); toMeasure = wrapper.Wrapped(); + MeasureText(font_id, toMeasure, w, h); } else { MeasureText(font_id, text, w, h); } @@ -592,7 +593,7 @@ void DrawBuffer::DrawTextRect(FontID font, std::string_view text, float x, float // This allows each line to be horizontally centered by itself. for (const std::string &line : lines) { - DrawText(font, line.c_str(), x, baseY, color, align); + DrawText(font, line, x, baseY, color, align); float tw, th; MeasureText(font, line, &tw, &th); diff --git a/Core/Dialog/PSPSaveDialog.cpp b/Core/Dialog/PSPSaveDialog.cpp index 144336e507..37a98b9f57 100755 --- a/Core/Dialog/PSPSaveDialog.cpp +++ b/Core/Dialog/PSPSaveDialog.cpp @@ -539,10 +539,10 @@ void PSPSaveDialog::DisplaySaveDataInfo1() { titleStyle.color = CalcFadedColor(0xFFC0C0C0); PPGeStyle textStyle = FadedStyle(PPGeAlign::BOX_LEFT, 0.5f); - PPGeDrawText(titleTxt.c_str(), 180, 136, titleStyle); - PPGeDrawText(timeTxt.c_str(), 180, 137, textStyle); - PPGeDrawText(saveTitleTxt.c_str(), 175, 159, saveTitleStyle); - PPGeDrawTextWrapped(saveDetailTxt.c_str(), 175, 181, 480 - 175, 250 - 181, textStyle); + PPGeDrawText(titleTxt, 180, 136, titleStyle); + PPGeDrawText(timeTxt, 180, 137, textStyle); + PPGeDrawText(saveTitleTxt, 175, 159, saveTitleStyle); + PPGeDrawTextWrapped(saveDetailTxt, 175, 181, 480 - 175, 250 - 181, textStyle); } } diff --git a/Core/SaveState.cpp b/Core/SaveState.cpp index 49ac73c0af..bc3950e15c 100644 --- a/Core/SaveState.cpp +++ b/Core/SaveState.cpp @@ -913,25 +913,26 @@ namespace SaveState return Status::SUCCESS; } - void Process() - { + // NOTE: This can cause ending of the current renderpass, due to the readback needed for the screenshot. + bool Process() { rewindStates.Process(); if (!needsProcess) - return; + return false; needsProcess = false; if (!__KernelIsRunning()) { ERROR_LOG(Log::SaveState, "Savestate failure: Unable to load without kernel, this should never happen."); - return; + return false; } std::vector operations = Flush(); SaveStart state; - for (size_t i = 0, n = operations.size(); i < n; ++i) - { + bool readbackImage = false; + + for (size_t i = 0, n = operations.size(); i < n; ++i) { Operation &op = operations[i]; CChunkFileReader::Error result; Status callbackResult; @@ -984,7 +985,7 @@ namespace SaveState break; case SAVESTATE_SAVE: - INFO_LOG(Log::SaveState, "Saving state to %s", op.filename.c_str()); + INFO_LOG(Log::SaveState, "Saving state to '%s'", op.filename.c_str()); title = g_paramSFO.GetValueString("TITLE"); if (title.empty()) { // Homebrew title @@ -1068,6 +1069,7 @@ namespace SaveState } else { screenshotFailures = 0; } + readbackImage = true; break; } default: @@ -1083,6 +1085,8 @@ namespace SaveState // Avoid triggering frame skipping due to slowdown __DisplaySetWasPaused(); } + + return readbackImage; } void NotifySaveData() { diff --git a/Core/SaveState.h b/Core/SaveState.h index b059725d52..32431218ef 100644 --- a/Core/SaveState.h +++ b/Core/SaveState.h @@ -104,7 +104,7 @@ namespace SaveState bool IsOldVersion(); // Check if there's any save stating needing to be done. Normally called once per frame. - void Process(); + bool Process(); // Notify save state code that new save data has been written. void NotifySaveData(); diff --git a/Core/System.cpp b/Core/System.cpp index 155c3bbba3..9bca1c1705 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -623,7 +623,6 @@ void PSP_RunLoopWhileState() { } void PSP_RunLoopUntil(u64 globalticks) { - SaveState::Process(); if (coreState == CORE_POWERDOWN || coreState == CORE_BOOT_ERROR || coreState == CORE_RUNTIME_ERROR) { return; } else if (coreState == CORE_STEPPING) { diff --git a/GPU/Common/DrawEngineCommon.h b/GPU/Common/DrawEngineCommon.h index 4ee167a1b5..1d9532155b 100644 --- a/GPU/Common/DrawEngineCommon.h +++ b/GPU/Common/DrawEngineCommon.h @@ -147,6 +147,10 @@ public: virtual void ClearTrackedVertexArrays() {} + void AssertEmpty() { + _dbg_assert_(numDrawVerts_ == 0 && numDrawInds_ == 0); + } + protected: virtual bool UpdateUseHWTessellation(bool enabled) const { return enabled; } void UpdatePlanes(); diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index a8cc23b299..e6526fa089 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -628,6 +628,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) { } if (!hasImage) { draw_->BindFramebufferAsRenderTarget(nullptr, { Draw::RPAction::CLEAR, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "CopyToCurrentFboFromDisplayRam"); + presentation_->NotifyPresent(); return; } diff --git a/GPU/Vulkan/DebugVisVulkan.cpp b/GPU/Vulkan/DebugVisVulkan.cpp index f259fafe8f..b6d59965b5 100644 --- a/GPU/Vulkan/DebugVisVulkan.cpp +++ b/GPU/Vulkan/DebugVisVulkan.cpp @@ -92,7 +92,7 @@ void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) { int y = starty; ui->SetFontScale(0.7f, 0.7f); - ui->DrawTextShadow(str.str().c_str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + ui->DrawTextShadow(str.str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); ui->SetFontScale(1.0f, 1.0f); ui->Flush(); } @@ -115,7 +115,7 @@ void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) { std::string text = ui->GetDrawContext()->GetGpuProfileString(); ui->SetFontScale(0.4f, 0.4f); - ui->DrawTextShadow(text.c_str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); + ui->DrawTextShadow(text, x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII); ui->SetFontScale(1.0f, 1.0f); ui->Flush(); } diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index b03a8556a0..e20c5d0535 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -174,11 +174,15 @@ void DrawEngineVulkan::BeginFrame() { tessDataTransferVulkan->SetPushPool(pushUBO_); DirtyAllUBOs(); + + AssertEmpty(); } void DrawEngineVulkan::EndFrame() { stats_.pushVertexSpaceUsed = (int)pushVertex_->GetUsedThisFrame(); stats_.pushIndexSpaceUsed = (int)pushIndex_->GetUsedThisFrame(); + + AssertEmpty(); } void DrawEngineVulkan::DirtyAllUBOs() { @@ -212,6 +216,8 @@ void DrawEngineVulkan::Invalidate(InvalidationCallbackFlags flags) { void DrawEngineVulkan::DoFlush() { VulkanRenderManager *renderManager = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); + renderManager->AssertInRenderPass(); + PROFILE_THIS_SCOPE("Flush"); bool tess = gstate_c.submitType == SubmitType::HW_BEZIER || gstate_c.submitType == SubmitType::HW_SPLINE; diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index f374228b64..d91f97c04b 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1369,6 +1369,9 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { framebufferBound = true; } draw->SetTargetSize(g_display.pixel_xres, g_display.pixel_yres); + } else { + // Some other screen bound the backbuffer first. + framebufferBound = true; } g_OSD.NudgeSidebar(); @@ -1376,6 +1379,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { if (mode & ScreenRenderMode::TOP) { System_Notify(SystemNotification::KEEP_SCREEN_AWAKE); } else if (!Core_ShouldRunBehind() && strcmp(screenManager()->topScreen()->tag(), "DevMenu") != 0) { + // NOTE: The strcmp is != 0 - so all popped-over screens EXCEPT DevMenu // Just to make sure. if (PSP_IsInited() && !skipBufferEffects) { _dbg_assert_(gpu); @@ -1383,7 +1387,10 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { gpu->CopyDisplayToOutput(true); PSP_EndHostFrame(); } - if (!framebufferBound && (!gpu || !gpu->PresentedThisFrame())) { + if (gpu->PresentedThisFrame()) { + framebufferBound = true; + } + if (!framebufferBound) { draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, }, "EmuScreen_Behind"); } // Need to make sure the UI texture is available, for "darken". @@ -1445,6 +1452,12 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { uint32_t clearColor = 0; if (!blockedExecution) { PSP_BeginHostFrame(); + if (SaveState::Process()) { + // We might have lost the framebuffer bind if we had one, due to a readback. + if (framebufferBound) { + draw->BindFramebufferAsRenderTarget(nullptr, { RPAction::CLEAR, RPAction::CLEAR, RPAction::CLEAR, clearColor }, "EmuScreen_SavestateRebind"); + } + } PSP_RunLoopWhileState(); flags |= ScreenRenderFlags::HANDLED_THROTTLING; @@ -1486,10 +1499,6 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) { break; } - if (framebufferBound && gpu) { - gpu->PresentedThisFrame(); - } - PSP_EndHostFrame(); // This place rougly matches how libretro handles it (after retro_frame). diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 9c3ec15454..1e4e43e61b 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -785,7 +785,7 @@ void LogoScreen::DrawForeground(UIContext &dc) { // Add some emoji for testing. apiName += CodepointToUTF8(0x1F41B) + CodepointToUTF8(0x1F41C) + CodepointToUTF8(0x1F914); #endif - dc.DrawText(gr->T_cstr(apiName.c_str()), bounds.centerX(), ppsspp_org_y + 50, textColor, ALIGN_CENTER); + dc.DrawText(gr->T(apiName.c_str()), bounds.centerX(), ppsspp_org_y + 50, textColor, ALIGN_CENTER); #endif dc.Flush(); diff --git a/UI/SavedataScreen.cpp b/UI/SavedataScreen.cpp index d42dd469dd..02d0c2f2a5 100644 --- a/UI/SavedataScreen.cpp +++ b/UI/SavedataScreen.cpp @@ -96,7 +96,6 @@ void SavedataView::UpdateGame(GameInfo *ginfo) { if (!ginfo->Ready(GameInfoFlags::PARAM_SFO | GameInfoFlags::SIZE)) { return; } - _dbg_assert_(savedataTitle_); if (savedataTitle_) { savedataTitle_->SetText(ginfo->GetParamSFO().GetValueString("SAVEDATA_TITLE")); } diff --git a/build.gradle b/build.gradle index 1b8280e0d4..1008141208 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:8.7.0' + classpath 'com.android.tools.build:gradle:8.7.1' } }