Merge pull request #21240 from hrydgard/even-more-fixes

Fix crashes in the ImGeDebugger
This commit is contained in:
Henrik Rydgård
2026-02-11 14:31:24 +01:00
committed by GitHub
6 changed files with 48 additions and 30 deletions
+4
View File
@@ -2472,6 +2472,10 @@ int sceKernelWakeupThread(SceUID uid) {
return hleLogVerbose(Log::sceKernel, 0, "woke thread at %i", t->nt.wakeupCount);
}
} else {
if (uid == (SceUID)-1) {
// Common error (for example in Power Stone). Let's log at debug level.
return hleLogDebug(Log::sceKernel, error, "bad thread id");
}
return hleLogError(Log::sceKernel, error, "bad thread id");
}
}
+4 -3
View File
@@ -332,11 +332,12 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, VFSBackend *dir, bool isOverri
}
std::string badFilenames;
constexpr int MaxBadFilenameCount = 5; // How many to list in the popup
if (ini.HasSection("hashes")) {
const Section *hashesSection = ini.GetOrCreateSection("hashes");
// Format: hashname = filename.png
bool checkFilenames = saveEnabled_ && !g_Config.bIgnoreTextureFilenames && !vfsIsZip_;
const bool checkFilenames = saveEnabled_ && !g_Config.bIgnoreTextureFilenames && !vfsIsZip_;
for (const auto &line : hashesSection->Lines()) {
if (line.Key().empty())
@@ -362,9 +363,9 @@ bool TextureReplacer::LoadIniValues(IniFile &ini, VFSBackend *dir, bool isOverri
#endif
if (bad) {
badFileNameCount++;
if (badFileNameCount == 10) {
if (badFileNameCount == MaxBadFilenameCount) {
badFilenames.append("...");
} else if (badFileNameCount < 10) {
} else if (badFileNameCount < MaxBadFilenameCount) {
badFilenames.append(v);
badFilenames.push_back('\n');
}
+2 -2
View File
@@ -1670,8 +1670,6 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
// Reset the viewport. Needed in case Cardboard or something similar was enabled.
draw->SetViewport(viewport);
runImDebugger();
Draw::BackendState state = draw->GetCurrentBackendState();
if (!(mode & ScreenRenderMode::TOP)) {
@@ -1815,6 +1813,8 @@ ScreenRenderFlags EmuScreen::RunEmulation(bool skipBufferEffects) {
}
}
runImDebugger();
return flags;
}
+14 -4
View File
@@ -570,6 +570,10 @@ ImGeReadbackViewer::~ImGeReadbackViewer() {
delete[] data_;
}
VirtualFramebuffer *ImGeReadbackViewer::GetVFB(FramebufferManagerCommon *fbMan) const {
return fbMan->GetExactVFB(gstate.getFrameBufAddress(), gstate.FrameBufStride(), gstate.FrameBufFormat());
}
void ImGeReadbackViewer::DeviceLost() {
if (texture_) {
texture_->Release();
@@ -578,8 +582,10 @@ void ImGeReadbackViewer::DeviceLost() {
}
bool ImGeReadbackViewer::Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *draw, float zoom) {
FramebufferManagerCommon *fbmanager = gpuDebug->GetFramebufferManagerCommon();
if (!vfb || !vfb->fbo || !fbmanager) {
FramebufferManagerCommon *fbMan = gpuDebug->GetFramebufferManagerCommon();
VirtualFramebuffer *vfb = GetVFB(fbMan);
if (!vfb || !vfb->fbo || !fbMan) {
ImGui::TextUnformatted("(N/A)");
return false;
}
@@ -661,6 +667,8 @@ bool ImGeReadbackViewer::Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *dr
}
bool ImGeReadbackViewer::FormatValueAt(char *buf, size_t bufSize, int x, int y) const {
FramebufferManagerCommon *fbMan = gpuDebug->GetFramebufferManagerCommon();
VirtualFramebuffer *vfb = GetVFB(fbMan);
if (!vfb || !vfb->fbo || !data_) {
snprintf(buf, bufSize, "N/A");
return true;
@@ -990,7 +998,9 @@ void ImGeDebuggerWindow::NotifyStep() {
FramebufferManagerCommon *fbman = gpuDebug->GetFramebufferManagerCommon();
if (fbman) {
rbViewer_.vfb = fbman->GetExactVFB(gstate.getFrameBufAddress(), gstate.FrameBufStride(), gstate.FrameBufFormat());
rbViewer_.fbAddr = gstate.getFrameBufAddress();
rbViewer_.fbStride = gstate.FrameBufStride();
rbViewer_.fbFormat = gstate.FrameBufFormat();
rbViewer_.aspect = selectedAspect_;
}
rbViewer_.Snapshot();
@@ -1199,7 +1209,7 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
ImGui::Text("Total bytes to transfer: %d", gstate.getTransferWidth() * gstate.getTransferHeight() * gstate.getTransferBpp());
} else {
// Visualize prim by default (even if we're not directly on a prim instruction).
VirtualFramebuffer *vfb = rbViewer_.vfb;
VirtualFramebuffer *vfb = rbViewer_.GetVFB(gpuDebug->GetFramebufferManagerCommon());
if (vfb) {
if (vfb->fbo) {
ImGui::Text("Framebuffer: %s", vfb->fbo->Tag());
+6 -3
View File
@@ -100,9 +100,12 @@ struct ImGeReadbackViewer : public PixelLookup {
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.
VirtualFramebuffer *vfb = nullptr;
VirtualFramebuffer *GetVFB(FramebufferManagerCommon *fbMan) const;
// We need to re-fetch the vfb each frame from these parameters.
u32 fbAddr = 0;
u32 fbStride = 0;
GEBufferFormat fbFormat = GE_FORMAT_INVALID;
// This specifies what to show
Draw::Aspect aspect;
+18 -18
View File
@@ -294,8 +294,8 @@ void GameButton::Draw(UIContext &dc) {
ImageID imageIcon = ImageID::invalid();
bool drawBackground = true;
switch (ginfo->fileType) {
case IdentifiedFileType::PSP_ELF: imageIcon = ImageID("I_DEBUGGER"); drawBackground = false; break;
case IdentifiedFileType::UNKNOWN_ELF: imageIcon = ImageID("I_CROSS"); drawBackground = false; break;
case IdentifiedFileType::PSP_ELF: imageIcon = ImageID("I_APP"); drawBackground = false; break;
case IdentifiedFileType::UNKNOWN_ELF: imageIcon = ImageID("I_APP"); drawBackground = false; break;
case IdentifiedFileType::PPSSPP_GE_DUMP: imageIcon = ImageID("I_DISPLAY"); break;
case IdentifiedFileType::PSX_ISO:
case IdentifiedFileType::PSP_PS1_PBP: imageIcon = ImageID("I_PSX_ISO"); break;
@@ -309,6 +309,15 @@ void GameButton::Draw(UIContext &dc) {
default: break;
}
if (ginfo->Ready(GameInfoFlags::ICON)) {
if (ginfo->icon.texture && drawBackground) {
texture = ginfo->icon.texture;
} else if (drawBackground) {
// No icon, but drawBackground is set. Let's show a plain icon depending on type.
imageIcon = (ginfo->fileType == IdentifiedFileType::PSP_ISO || ginfo->fileType == IdentifiedFileType::PSP_ISO_NP) ? ImageID("I_UMD") : ImageID("I_APP");
}
}
Bounds overlayBounds = bounds_;
u32 overlayColor = 0;
if (holdEnabled_ && holdStart_ != 0.0) {
@@ -325,15 +334,6 @@ void GameButton::Draw(UIContext &dc) {
}
}
if (ginfo->Ready(GameInfoFlags::ICON)) {
if (ginfo->icon.texture && drawBackground) {
texture = ginfo->icon.texture;
} else if (drawBackground) {
// No icon, but drawBackground is set. Let's show a plain icon.
imageIcon = ImageID("I_APP");
}
}
int x = bounds_.x;
int y = bounds_.y;
int w = gridStyle_ ? bounds_.w : 144;
@@ -397,6 +397,13 @@ void GameButton::Draw(UIContext &dc) {
dc.Draw()->Flush();
}
if (gridStyle_ && g_Config.bShowIDOnGameIcon && ginfo->fileType != IdentifiedFileType::PSP_ELF && !ginfo->id_version.empty()) {
dc.SetFontScale(0.5f * g_Config.fGameGridScale, 0.5f * g_Config.fGameGridScale);
dc.DrawText(ginfo->id_version, bounds_.x + 5, y + 1, 0xFF000000, ALIGN_TOPLEFT);
dc.DrawText(ginfo->id_version, bounds_.x + 4, y, dc.GetTheme().infoStyle.fgColor, ALIGN_TOPLEFT);
dc.SetFontScale(1.0f, 1.0f);
}
if (imageIcon.isValid()) {
Style style = dc.GetTheme().itemStyle;
@@ -509,13 +516,6 @@ void GameButton::Draw(UIContext &dc) {
}
}
if (gridStyle_ && g_Config.bShowIDOnGameIcon) {
dc.SetFontScale(0.5f*g_Config.fGameGridScale, 0.5f*g_Config.fGameGridScale);
dc.DrawText(ginfo->id_version, bounds_.x+5, y+1, 0xFF000000, ALIGN_TOPLEFT);
dc.DrawText(ginfo->id_version, bounds_.x+4, y, dc.GetTheme().infoStyle.fgColor, ALIGN_TOPLEFT);
dc.SetFontScale(1.0f, 1.0f);
}
if (overlayColor) {
dc.FillRect(Drawable(overlayColor), overlayBounds);
}