diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index df39023714..1f922011b5 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -532,7 +532,7 @@ u32 GPUCommon::Continue(bool *runList) { else { if (sceKernelGetCompiledSdkVersion() >= 0x02000000) - return 0x80000004; + return 0x80000004; // matches SCE_KERNEL_ERROR_BAD_ARGUMENT but doesn't really seem like it. Maybe that error code is more general. return -1; } diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index db544f6c74..f61d4fb270 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -1283,6 +1283,9 @@ void EmuScreen::deviceLost() { UIScreen::deviceLost(); if (imguiInited_) { + if (imDebugger_) { + imDebugger_->DeviceLost(); + } ImGui_ImplThin3d_DestroyDeviceObjects(); } } diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 265d8d76ac..142e3b19a6 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -1914,8 +1914,6 @@ void DeveloperToolsScreen::CreateViews() { cpuTests->SetEnabled(TestsAvailable()); #endif - list->Add(new CheckBox(&g_Config.bUseOldAtrac, dev->T("Use the old sceAtrac implementation"))); - AddOverlayList(list, screenManager()); list->Add(new CheckBox(&g_Config.bEnableLogging, dev->T("Enable Logging")))->OnClick.Handle(this, &DeveloperToolsScreen::OnLoggingChanged); @@ -1991,6 +1989,8 @@ void DeveloperToolsScreen::CreateViews() { auto displayRefreshRate = list->Add(new PopupSliderChoice(&g_Config.iDisplayRefreshRate, 60, 1000, 60, dev->T("Display refresh rate"), 1, screenManager())); displayRefreshRate->SetFormat(si->T("%d Hz")); + list->Add(new CheckBox(&g_Config.bUseOldAtrac, dev->T("Use the old sceAtrac implementation"))); + list->Add(new ItemHeader("Dump file types")); list->Add(new BitCheckBox(&g_Config.iDumpFileTypes, (int)DumpFileType::EBOOT, dev->T("Dump Decrypted Eboot", "Dump Decrypted EBOOT.BIN (If Encrypted) When Booting Game"))); list->Add(new BitCheckBox(&g_Config.iDumpFileTypes, (int)DumpFileType::PRX, dev->T("PRX"))); diff --git a/UI/ImDebugger/ImDebugger.cpp b/UI/ImDebugger/ImDebugger.cpp index 51e5dbece3..681d40e29b 100644 --- a/UI/ImDebugger/ImDebugger.cpp +++ b/UI/ImDebugger/ImDebugger.cpp @@ -649,12 +649,28 @@ static void DrawInternals(ImConfig &cfg) { {DIRECTORY_CUSTOM_THEMES, "CUSTOM_THEMES"}, }; - if (ImGui::CollapsingHeader("Directories", ImGuiTreeNodeFlags_DefaultOpen)) { + if (ImGui::CollapsingHeader("GetSysDirectory")) { for (auto &dir : dirs) { ImGui::Text("%s: %s", dir.name, GetSysDirectory(dir.dir).c_str()); } } + if (ImGui::CollapsingHeader("Memory")) { + ImGui::Text("Base pointer: %p", Memory::base); + ImGui::Text("Main memory size: %08x", Memory::g_MemorySize); + if (ImGui::Button("Copy to clipboard")) { + System_CopyStringToClipboard(StringFromFormat("0x%p", Memory::base)); + } + } + + if (ImGui::CollapsingHeader("ImGui state")) { + const auto &io = ImGui::GetIO(); + ImGui::Text("WantCaptureMouse: %s", BoolStr(io.WantCaptureMouse)); + ImGui::Text("WantCaptureKeyboard: %s", BoolStr(io.WantCaptureKeyboard)); + ImGui::Text("WantCaptureMouseUnlessPopupClose: %s", BoolStr(io.WantCaptureMouseUnlessPopupClose)); + ImGui::Text("WantTextInput: %s", BoolStr(io.WantTextInput)); + } + ImGui::End(); } @@ -672,15 +688,6 @@ static void DrawAdhoc(ImConfig &cfg) { default: break; } - auto &io = ImGui::GetIO(); - - /* - ImGui::Text("WantCaptureMouse: %s", BoolStr(io.WantCaptureMouse)); - ImGui::Text("WantCaptureKeyboard: %s", BoolStr(io.WantCaptureKeyboard)); - ImGui::Text("WantCaptureMouseUnlessPopupClose: %s", BoolStr(io.WantCaptureMouseUnlessPopupClose)); - ImGui::Text("WantTextInput: %s", BoolStr(io.WantTextInput)); - */ - ImGui::Text("sceNetAdhoc inited: %s", BoolStr(netAdhocInited)); ImGui::Text("sceNetAdhocctl inited: %s", BoolStr(netAdhocctlInited)); ImGui::Text("sceNetAdhocctl state: %s", AdhocCtlStateToString(NetAdhocctl_GetState())); @@ -1710,6 +1717,9 @@ void DrawHLEModules(ImConfig &config) { case 'I': amask[i] = 'd'; break; case 'f': case 'F': amask[i] = 'x'; break; + default: + // others go straight through (p) + break; } } w.F("%s 0x%08x %d %s", func.name, func.ID, strlen(func.argmask), amask.c_str()).endl(); @@ -2422,6 +2432,11 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro ImGui::End(); } +void ImDebugger::DeviceLost() { + pixelViewer_.DeviceLost(); + geDebugger_.DeviceLost(); +} + Path ImDebugger::ConfigPath() { return GetSysDirectory(DIRECTORY_SYSTEM) / "imdebugger.ini"; } diff --git a/UI/ImDebugger/ImDebugger.h b/UI/ImDebugger/ImDebugger.h index 5353349685..d93e66e181 100644 --- a/UI/ImDebugger/ImDebugger.h +++ b/UI/ImDebugger/ImDebugger.h @@ -237,6 +237,7 @@ public: void PostCmd(ImCommand cmd) { externalCommand_ = cmd; } + void DeviceLost(); private: Path ConfigPath(); diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index f57a950113..a7756b3782 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -197,6 +197,13 @@ ImGePixelViewer::~ImGePixelViewer() { texture_->Release(); } +void ImGePixelViewer::DeviceLost() { + if (texture_) { + texture_->Release(); + texture_ = nullptr; + } +} + bool ImGePixelViewer::Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *draw, float zoom) { if (dirty_) { UpdateTexture(draw); @@ -269,8 +276,9 @@ void ImGePixelViewer::UpdateTexture(Draw::DrawContext *draw) { int bpp = BufferFormatBytesPerPixel(format); int srcBytes = width * stride * bpp; - if (stride > width) + if (stride > width) { srcBytes -= stride - width; + } if (Memory::ValidSize(addr, srcBytes) != srcBytes) { // TODO: Show a message that the address is out of bounds. return; @@ -375,6 +383,13 @@ ImGeReadbackViewer::~ImGeReadbackViewer() { delete[] data_; } +void ImGeReadbackViewer::DeviceLost() { + if (texture_) { + texture_->Release(); + texture_ = nullptr; + } +} + bool ImGeReadbackViewer::Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *draw, float zoom) { FramebufferManagerCommon *fbmanager = gpuDebug->GetFramebufferManagerCommon(); if (!vfb || !vfb->fbo || !fbmanager) { @@ -461,6 +476,7 @@ bool ImGeReadbackViewer::Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *dr bool ImGeReadbackViewer::FormatValueAt(char *buf, size_t bufSize, int x, int y) const { if (!vfb || !vfb->fbo || !data_) { snprintf(buf, bufSize, "N/A"); + return true; } int bpp = (int)Draw::DataFormatSizeInBytes(readbackFmt_); int offset = (y * vfb->fbo->Width() + x) * bpp; @@ -751,6 +767,11 @@ ImGeDebuggerWindow::ImGeDebuggerWindow() { selectedAspect_ = Draw::Aspect::COLOR_BIT; } +void ImGeDebuggerWindow::DeviceLost() { + rbViewer_.DeviceLost(); + swViewer_.DeviceLost(); +} + void ImGeDebuggerWindow::NotifyStep() { reloadPreview_ = true; disasmView_.NotifyStep(); diff --git a/UI/ImDebugger/ImGe.h b/UI/ImDebugger/ImGe.h index a68f52eac4..e2066a4fd5 100644 --- a/UI/ImDebugger/ImGe.h +++ b/UI/ImDebugger/ImGe.h @@ -70,6 +70,7 @@ struct ImGePixelViewer : public PixelLookup { dirty_ = true; } bool FormatValueAt(char *buf, size_t bufSize, int x, int y) const override; + void DeviceLost(); uint32_t addr = 0x04110000; uint16_t stride = 512; @@ -95,6 +96,7 @@ struct ImGeReadbackViewer : public PixelLookup { dirty_ = true; } bool FormatValueAt(char *buf, size_t bufSize, int x, int y) const override; + void DeviceLost(); // TODO: This is unsafe! If you load state for example with the debugger open... // We need to re-fetch this each frame from the parameters. @@ -124,6 +126,9 @@ public: viewer_.stride = stride; viewer_.format = format; } + void DeviceLost() { + viewer_.DeviceLost(); + } private: ImGePixelViewer viewer_; @@ -140,6 +145,7 @@ public: return "GE Debugger"; } void NotifyStep(); + void DeviceLost(); private: ImGeDisasmView disasmView_;