From e9d5e451fbce563b3336be9a90fb8305c82fc41d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 May 2026 22:29:03 +0200 Subject: [PATCH 1/4] Avoid some unnecessary error reporting while loading ISOs for the file browser --- Core/FileSystems/BlockDevices.cpp | 5 +++++ Core/FileSystems/ISOFileSystem.cpp | 16 ++++++++++------ Core/FileSystems/ISOFileSystem.h | 11 +++++++---- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Core/FileSystems/BlockDevices.cpp b/Core/FileSystems/BlockDevices.cpp index ed3083f6ad..8d16bb57d3 100644 --- a/Core/FileSystems/BlockDevices.cpp +++ b/Core/FileSystems/BlockDevices.cpp @@ -411,6 +411,11 @@ ISOContainerFileBlockDevice::ISOContainerFileBlockDevice(FileLoader *fileLoader) SequentialHandleAllocator alloc; ISOFileSystem iso(&alloc, outerBlockDevice_); + if (!iso.Error().empty()) { + errorString_ = iso.Error(); + outerBlockDevice_.reset(); + return; + } PSPFileInfo layer0Info = iso.GetFileInfo("/USER_L0.IMG"); if (!layer0Info.exists) { diff --git a/Core/FileSystems/ISOFileSystem.cpp b/Core/FileSystems/ISOFileSystem.cpp index e051503664..cb77c57076 100644 --- a/Core/FileSystems/ISOFileSystem.cpp +++ b/Core/FileSystems/ISOFileSystem.cpp @@ -154,8 +154,17 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, std::shared_ptrReadBlock(16, (u8*)&desc)) + if (!blockDevice->ReadBlock(16, (u8*)&desc)) { + // TODO: This is kinda wacky. blockDevice->NotifyReadError(); + errorString_ = "ISO: error reading volume descriptor"; + return; + } + + if (memcmp(desc.cd001, "CD001", 5)) { + errorString_ = "ISO: missing CD001 signature"; + return; + } entireISO.name.clear(); entireISO.isDirectory = false; @@ -172,11 +181,6 @@ ISOFileSystem::ISOFileSystem(IHandleAllocator *_hAlloc, std::shared_ptrparent = NULL; treeroot->valid = false; - if (memcmp(desc.cd001, "CD001", 5)) { - ERROR_LOG(Log::FileSystem, "ISO looks bogus, expected CD001 signature not present? Giving up..."); - return; - } - treeroot->startsector = desc.root.firstDataSector; treeroot->dirsize = desc.root.dataLength; } diff --git a/Core/FileSystems/ISOFileSystem.h b/Core/FileSystems/ISOFileSystem.h index f94746ebc2..c59c6d884a 100644 --- a/Core/FileSystems/ISOFileSystem.h +++ b/Core/FileSystems/ISOFileSystem.h @@ -58,6 +58,8 @@ public: void Describe(char *buf, size_t size) const override { snprintf(buf, size, "ISO"); } // TODO: Ask the fileLoader about the origins std::shared_ptr GetBlockDevice() override { return blockDevice; } + + const std::string &Error() const { return errorString_; } private: struct TreeEntry { ~TreeEntry(); @@ -91,12 +93,13 @@ private: typedef std::map EntryMap; EntryMap entries; - IHandleAllocator *hAlloc; - TreeEntry *treeroot; + IHandleAllocator *hAlloc = nullptr; + TreeEntry *treeroot = nullptr; std::shared_ptr blockDevice; - mutable u32 lastReadBlock_; + mutable u32 lastReadBlock_ = 0; - TreeEntry entireISO; + TreeEntry entireISO{}; + std::string errorString_; void ReadDirectory(TreeEntry *root) const; const TreeEntry *GetFromPath(std::string_view path, bool catchError = true); From 33ae88af6d08b7367c0c08ceed6743a532993136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 31 May 2026 23:30:42 +0200 Subject: [PATCH 2/4] Delete option "Disable range culling". No games are known to require it anymore. --- Core/Config.cpp | 1 - Core/Config.h | 1 - UI/GameSettingsScreen.cpp | 3 --- libretro/libretro.cpp | 9 --------- libretro/libretro_core_options.h | 10 ---------- 5 files changed, 24 deletions(-) diff --git a/Core/Config.cpp b/Core/Config.cpp index c87af6bcc3..cecb2ba988 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -718,7 +718,6 @@ static const ConfigSetting graphicsSettings[] = { ConfigSetting("VendorBugChecksEnabled", SETTING(g_Config, bVendorBugChecksEnabled), true, CfgFlag::DONT_SAVE), ConfigSetting("UseGeometryShader", SETTING(g_Config, bUseGeometryShader), false, CfgFlag::PER_GAME), ConfigSetting("SkipBufferEffects", SETTING(g_Config, bSkipBufferEffects), false, CfgFlag::PER_GAME | CfgFlag::REPORT), - ConfigSetting("DisableRangeCulling", SETTING(g_Config, bDisableRangeCulling), false, CfgFlag::PER_GAME | CfgFlag::REPORT), ConfigSetting("DepthRasterMode", SETTING(g_Config, iDepthRasterMode), &DefaultDepthRaster, CfgFlag::PER_GAME | CfgFlag::REPORT), ConfigSetting("SoftwareRenderer", SETTING(g_Config, bSoftwareRendering), false, CfgFlag::PER_GAME), ConfigSetting("SoftwareRendererJit", SETTING(g_Config, bSoftwareRenderingJit), true, CfgFlag::PER_GAME), diff --git a/Core/Config.h b/Core/Config.h index 100bcbd37d..0ab8353c9f 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -291,7 +291,6 @@ public: // Speedhacks (more will be moved here): bool bSkipBufferEffects; - bool bDisableRangeCulling; int iDepthRasterMode; int iTexFiltering; // 1 = auto , 2 = nearest , 3 = linear , 4 = auto max quality diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 2309f1812f..bfae4e00dd 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -492,9 +492,6 @@ void GameSettingsScreen::CreateGraphicsSettings(UI::ViewGroup *graphicsSettings) }); skipBufferEffects->SetDisabledPtr(&g_Config.bSoftwareRendering); - CheckBox *disableCulling = graphicsSettings->Add(new CheckBox(&g_Config.bDisableRangeCulling, gr->T("Disable culling"))); - disableCulling->SetDisabledPtr(&g_Config.bSoftwareRendering); - static const char *skipGpuReadbackModes[] = { "No", "Skip", "Copy to texture" }; PopupMultiChoice *skipGPUReadbacks = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iSkipGPUReadbackMode, gr->T("Skip GPU Readbacks"), skipGpuReadbackModes, 0, ARRAY_SIZE(skipGpuReadbackModes), I18NCat::GRAPHICS, screenManager())); diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp index 3b2f10317e..89957af048 100644 --- a/libretro/libretro.cpp +++ b/libretro/libretro.cpp @@ -780,15 +780,6 @@ static void check_variables(CoreParameter &coreParam) g_Config.bSkipBufferEffects = true; } - var.key = "ppsspp_disable_range_culling"; - if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) - { - if (!strcmp(var.value, "disabled")) - g_Config.bDisableRangeCulling = false; - else - g_Config.bDisableRangeCulling = true; - } - var.key = "ppsspp_skip_gpu_readbacks"; if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { diff --git a/libretro/libretro_core_options.h b/libretro/libretro_core_options.h index a8a1bd3707..800860ddae 100644 --- a/libretro/libretro_core_options.h +++ b/libretro/libretro_core_options.h @@ -517,16 +517,6 @@ struct retro_core_option_v2_definition option_defs_us[] = { BOOL_OPTIONS, "disabled" }, - { - "ppsspp_disable_range_culling", - "Disable Culling", - NULL, - "", - NULL, - "hacks", - BOOL_OPTIONS, - "disabled" - }, { "ppsspp_skip_gpu_readbacks", "Skip GPU Readbacks", From b164621606b77dd8ef455aafb445f2a1ff37f715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 1 Jun 2026 10:49:45 +0200 Subject: [PATCH 3/4] Add lock to RingbufferLog --- Common/Log/LogManager.cpp | 1 + Common/Log/LogManager.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Common/Log/LogManager.cpp b/Common/Log/LogManager.cpp index dff5ecba86..09c1d89be1 100644 --- a/Common/Log/LogManager.cpp +++ b/Common/Log/LogManager.cpp @@ -355,6 +355,7 @@ void LogManager::LogLine(LogLevel level, Log type, const char *file, int line, c } void RingbufferLog::Log(const LogMessage &message) { + std::lock_guard lock(ringLock_); messages_[curMessage_] = message; curMessage_++; if (curMessage_ >= MAX_LOGS) diff --git a/Common/Log/LogManager.h b/Common/Log/LogManager.h index 59bb1b5cdc..da371efcb3 100644 --- a/Common/Log/LogManager.h +++ b/Common/Log/LogManager.h @@ -57,10 +57,17 @@ class RingbufferLog { public: void Log(const LogMessage &msg); int GetCount() const { return count_ < MAX_LOGS ? count_ : MAX_LOGS; } - std::string_view TextAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].msg; } - LogLevel LevelAt(int i) const { return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].level; } + std::string TextAt(int i) const { + std::lock_guard lock(ringLock_); + return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].msg; + } + LogLevel LevelAt(int i) const { + std::lock_guard lock(ringLock_); + return messages_[(curMessage_ - i - 1) & (MAX_LOGS - 1)].level; + } void Clear() { + std::lock_guard lock(ringLock_); curMessage_ = 0; count_ = 0; } @@ -70,6 +77,7 @@ private: LogMessage messages_[MAX_LOGS]; int curMessage_ = 0; int count_ = 0; + mutable std::mutex ringLock_; }; class Section; From 054a10d46bbae6a5f405696650a2f5c38e467a07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 1 Jun 2026 10:53:41 +0200 Subject: [PATCH 4/4] Fix imgui being upside down on some backends. Fixes #21761 --- Common/System/Display.cpp | 18 ++++-------------- Common/System/Display.h | 2 +- UI/NativeApp.cpp | 4 ++-- ext/imgui/imgui_impl_thin3d.cpp | 2 +- 4 files changed, 8 insertions(+), 18 deletions(-) diff --git a/Common/System/Display.cpp b/Common/System/Display.cpp index 31e911f333..096595e360 100644 --- a/Common/System/Display.cpp +++ b/Common/System/Display.cpp @@ -116,28 +116,18 @@ void DisplayProperties::Print() { rot_matrix.print(); } -Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention, bool compensateYFlip) { +// Y-flip compensation is done elsewhere now. +Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention) { using namespace Lin; - // TODO: Should be able to share the y-flip logic here with the one in postprocessing/presentation, for example. Matrix4x4 ortho; switch (coordConvention) { case CoordConvention::Vulkan: - ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); - break; case CoordConvention::Direct3D11: - if (compensateYFlip) { - ortho.setOrthoD3D(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); - } else { - ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); - } + ortho.setOrthoD3D(0.0f, xres, 0, yres, -1.0f, 1.0f); break; case CoordConvention::OpenGL: default: - if (compensateYFlip) { - ortho.setOrthoGL(0.0f, xres, 0, yres, -1.0f, 1.0f); - } else { - ortho.setOrthoGL(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); - } + ortho.setOrthoGL(0.0f, xres, yres, 0.0f, -1.0f, 1.0f); break; } // Compensate for rotated display if needed. diff --git a/Common/System/Display.h b/Common/System/Display.h index 096a378186..edf15c6320 100644 --- a/Common/System/Display.h +++ b/Common/System/Display.h @@ -61,7 +61,7 @@ struct DisplayRect { void RotateRectToDisplay(DisplayRect &rect, float rtWidth, float rtHeight); void RotateRectToDisplay(DisplayRect &rect, int rtWidth, int rtHeight); -Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention, bool compensateYFlip); +Lin::Matrix4x4 ComputeOrthoMatrix(float xres, float yres, CoordConvention coordConvention); // Take this and run through translation. Returns "Portrait", "Landscape" or later "Square" (the latter being the square shape you get when you open a foldable phone). std::string_view DeviceOrientationToString(DeviceOrientation orientation); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index ab3b410d3d..25e77246d2 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -1072,8 +1072,8 @@ void NativeFrame(GraphicsContext *graphicsContext) { g_breakpoints.Frame(); // Apply the UIContext bounds as a 2D transformation matrix. - // NOTE: We compensate for the Y convention in the shaders, so we can use the same matrices in all backends. - Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, g_draw->GetDeviceCaps().coordConvention, false); + // NOTE: We compensate for the Y and Z conventions in the shaders, so we can use the same matrices in all backends. + Matrix4x4 ortho = ComputeOrthoMatrix(g_display.dp_xres, g_display.dp_yres, g_draw->GetDeviceCaps().coordConvention); // Can be overridden by sceDisplay which may pass true for the second argument. g_frameTiming.ComputePresentMode(g_draw, false); diff --git a/ext/imgui/imgui_impl_thin3d.cpp b/ext/imgui/imgui_impl_thin3d.cpp index 757f0ef494..4bef970ed8 100644 --- a/ext/imgui/imgui_impl_thin3d.cpp +++ b/ext/imgui/imgui_impl_thin3d.cpp @@ -73,7 +73,7 @@ void ImGui_ImplThin3d_RenderDrawData(ImDrawData* draw_data, Draw::DrawContext *d viewport.MaxDepth = 1.0f; draw->SetViewport(viewport); - Lin::Matrix4x4 mtx = ComputeOrthoMatrix(draw_data->DisplaySize.x, draw_data->DisplaySize.y, draw->GetDeviceCaps().coordConvention, true); + Lin::Matrix4x4 mtx = ComputeOrthoMatrix(draw_data->DisplaySize.x, draw_data->DisplaySize.y, draw->GetDeviceCaps().coordConvention); Draw::VsTexColUB ub{}; memcpy(ub.WorldViewProj, mtx.getReadPtr(), sizeof(Lin::Matrix4x4));