Commit Graph
272 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5 bb5d7d5b65 Debugger: report structured breakpoint hits, including log-only ones
A breakpoint hit reached a WebSocket client as two fields on cpu.stepping: a
reason string and one address. Everything else the hit site knew was formatted
into a log line and dropped.

What was missing per kind:

- exec: hit count, condition, symbol.
- memory: the address actually accessed, read vs write, size, and who did it.
  The address that reached the client was the *start of the watched range*, so a
  client watching 4KB learned only that something in it was touched.
- register: which register. Entirely - the event carried pc and nothing else.

There's now a BreakpointHit captured where the hit happens and carried through
Core_Break() on the stepping reason, rendered as a "hit" object on cpu.stepping.
It's absent rather than empty when the break wasn't a breakpoint (a pause, a
savestate load, an exception), so presence is the test. relatedAddress keeps
reporting the range start for compatibility; hit.address is the accurate one.
The formatter is shared with the new event below, so the two can't drift.

And a new cpu.breakpoint.hit broadcast fires on *every* hit whose condition
passes, whether or not it stops the CPU. That's the part that makes log-only
breakpoints usable for automation: until now their only trace was a line in the
log stream, so a client couldn't count hits, or react to one, without scraping
text. Same "hit" object, plus a sequence number.

Volume needed handling, since a log-only breakpoint in a hot loop produces
events far faster than a connection drains them - measured 13719 hits in three
seconds of one homebrew's draw function. The per-connection queue is capped and
drops rather than growing without bound, and the sequence number is what makes
that honest: a gap tells a client exactly how many it missed. Clients that don't
want the traffic at all can disallow the new "breakpoint" broadcast category.
Building the hit record is skipped entirely when no debugger is connected, which
is one relaxed atomic load on that path.

Verified against a running game, all three kinds. The memory case shows why the
address/range split matters - accessed address 200540160 against a watched range
starting at 200941120, with source "ThreadFillStack" identifying the HLE call
responsible.

libretro gets stubs: it builds Core.cpp and Breakpoints.cpp but not
Core/Debugger/WebSocket.cpp.

pspautotests 314/314, UnitTest 55/55.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-18 10:59:08 +02:00
Henrik Rydgård 0ac822d7f1 Libretro buildfix 2026-08-17 13:11:16 +02:00
Henrik Rydgård 6836a2bd4e Libretro buildfix, add a comment 2026-08-12 14:26:10 +02:00
Henrik Rydgård e9a3449ede More MIPSState * plumbing (manual) 2026-08-12 14:02:19 +02:00
Henrik Rydgård a44c2c0bde Replace System_SendDebugOutput with a registered callback
I normally try to avoid registrations when not needed, but in this case
only headless uses this, so it's motivated.
2026-08-11 22:36:47 +02:00
Henrik Rydgård 4160414b31 Vulkan: remove libretro's global function-pointer wrapper hack
libretro/libretro_vulkan.cpp got PPSSPP's libretro core working with
RetroArch's Vulkan integration by globally monkey-patching PPSSPP's Vulkan
loader function pointers (vkCreateInstance, vkCreateDevice,
vkCreateSwapchainKHR, vkAcquireNextImageKHR, vkQueuePresentKHR,
vkQueueSubmit, etc.) so the unmodified VulkanContext class would end up
wrapping RetroArch's already-existing VkInstance/VkDevice instead of
creating its own, and so a fake VkSwapchainKHR (a self-managed array of
images synced against RetroArch's retro_hw_render_interface_vulkan
callbacks) could stand in for the real swapchain that libretro's Vulkan
model doesn't have. Flagged in-code as "a wacky wrapper".

Replaces that with first-class support in VulkanContext for the two things
libretro actually needs:

- Adopting an externally-created instance/device instead of faking
  vkCreateInstance/vkCreateDevice: VulkanContext::CreateInstanceExternal()
  adopts RetroArch's VkInstance; CreateDevice() gained optional
  extraDeviceExtensions/extraRequiredFeatures params so RetroArch's
  requirements get merged into a real vkCreateDevice() call;
  ownsInstance_/ownsDevice_ flags (the latter set via
  SetDeviceExternallyOwned()) mean DestroyInstance()/DestroyDevice() skip
  the real vkDestroy* calls when something else owns the object, without
  needing to intercept anything. VulkanLoader gained
  VulkanLoadFromGetInstanceProcAddr() for bootstrapping from a
  host-supplied proc-addr getter instead of dlopen/dlsym-ing the loader
  ourselves - vkGetDeviceProcAddr is resolved via the real instance handle
  (not NULL), since per the Vulkan spec it's not one of the handful of
  commands queryable with a NULL instance.
- A pluggable presentation backend (Common/GPU/Vulkan/VulkanPresentation.h)
  for hosts with no real VK_KHR_swapchain, replacing the fake-swapchain-
  handle trick. VulkanContext::GetPresentation() is null by default, so
  every existing platform's real-swapchain code path is untouched;
  libretro/LibretroVulkanPresentation implements this interface directly
  against retro_hw_render_interface_vulkan, as real class state instead of
  file-scope globals. Several pieces of state that are normally only
  populated as a side effect of ReinitSurface()/InitSwapchain() - the
  graphics queue/queue family index (ChooseQueue() is entangled with
  real-surface presentation-support checks), the swapchain format, and
  the available present modes - needed presentation-aware fallbacks since
  libretro never calls that real-surface path at all.

libretro/LibretroVulkanContext.cpp now drives VulkanContext's real, public
API directly - no more hijacked function pointers, no more fake surface or
swapchain. libretro/libretro_vulkan.cpp is deleted.

Verified with a full build+run in RetroArch (not just compile-time
checks): the libretro Makefile doesn't track header dependencies
(cl.exe doesn't support -MMD/-MP, and Makefile.common never sets up an
equivalent), so a `make clean` full rebuild is required after any header
change to avoid linking stale object code from before the change - several
of the fixes above were initially masked by exactly that.
2026-08-06 17:07:05 +02:00
Henrik Rydgård c42a3f070a Implement the new shutdown path for libretro too 2026-08-04 17:45:03 +02:00
Henrik Rydgård be922eca62 Make OpenGL render thread shutdown more robust. 2026-08-04 16:44:55 +02:00
Henrik Rydgård 58d4759ceb Add bounds checking to savestate deserialization
PointerWrap tracked no end-of-buffer, so DoState() implementations could
read past the end of a crafted or truncated savestate via DoVoid's
unchecked memcpy, and DoVector could resize to an attacker-controlled
size before reading.

- PointerWrap now tracks a read end; DoVoid/ExpectVoid fail (MODE_NOOP)
  before reading out of bounds.
- String reads are bounds-checked for the whole string including NUL.
- DoVector rejects sizes that can't fit in the remaining buffer.
- LoadPtr takes the buffer size and sets the read end.
- Capping the decompression buffer allocation in LoadFile.
2026-08-01 11:57:24 +02:00
Henrik Rydgård afe4d5beaf Buildfixes, dependency shuffling to make things more logical 2026-07-24 14:43:34 +02:00
Henrik Rydgård 240a974e95 Remove direct dependency from Core to MacCameraHelper.mm 2026-07-24 12:06:15 +02:00
Henrik Rydgård 00a566514e Buildfixes 2026-07-21 14:00:02 +02:00
Henrik Rydgård ca8e54106b Remove libretro setting definition 2026-07-14 20:01:33 +02:00
Mark Pearce 00f5f4fc90 libretro: guard output_audio_buffer with a mutex
System_AudioPushSamples() runs on the emu thread when one is active
(GL/GLCore backends) and appends to / reallocs output_audio_buffer,
while retro_run() on the libretro thread reads .data/.size and resets
.size in upload_output_audio_buffer(), unsynchronized. A realloc on
the emu thread can free the pointer while audio_batch_cb() reads it.

Guard the four access sites with a mutex (<mutex> was already included
in this file, unused). The lock is held across audio_batch_cb() — no
second buffer; worst case the emu thread briefly backpressures while
the frontend syncs audio. Behavior is otherwise unchanged.
2026-07-07 11:02:00 +08:00
Henrik Rydgård 623545bd24 Delete the "Hardware tessellation" feature.
Very hard to maintain and debug, not worth it.
2026-06-16 16:17:14 +02:00
Henrik Rydgård 36bdde68f9 Delete the "Lazy texture cache" option 2026-06-09 23:49:54 +02:00
Henrik Rydgård 33ae88af6d Delete option "Disable range culling". No games are known to require it anymore. 2026-05-31 23:31:06 +02:00
sonninnos b7d4a54a45 Libretro: Fix serialization hang with opengl emuthread 2026-05-01 03:38:57 +03:00
celerizer 12cfe70df1 only opengl reset if something actually changed 2026-04-07 13:59:22 -05:00
celerizer 72bd0fa4d3 add null-checks on software render path 2026-04-07 11:05:50 -05:00
Henrik Rydgård 9936fcfee3 Libretro: Freeze fix
Broke in #21221, forgot to apply the refactoring with libretro
2026-02-10 08:25:52 +01:00
MMaZaHaKa 9bb01cc127 upd libretro 2026-01-18 23:51:08 +02:00
刘皓 18ac1ec937 Use the libretro VFS when reading/writing cheats 2026-01-02 17:07:22 -05:00
刘皓 5716cbd41d Use the libretro VFS interface in libretro builds 2026-01-01 00:24:01 -05:00
刘皓 a018cfc017 Update libretro-common and remove redundant libretro header files 2025-12-30 23:06:58 -05:00
Eric Warmenhoven a4a1752f61 libretro: fix mac build 2025-11-11 09:39:39 -05:00
Henrik Rydgård 67010ff2af Split the display layout config between landscape and portrait orientations 2025-11-05 12:49:51 +01:00
Henrik Rydgård 5aeab28e9b Remove the "Percentage of framerate" frameskip type 2025-10-20 11:49:41 +02:00
Henrik Rydgård 176c55da25 Remove unused "interval" concept from presentation mode 2025-10-19 18:18:06 +02:00
Henrik Rydgård b472eb8b8b Remove a lot of unnecessary string constructors 2025-08-31 15:49:29 +02:00
Henrik Rydgård 380fa19d3c Another std::string_view change, buildfix 2025-08-31 15:24:33 +02:00
Henrik Rydgård 9218fe9b59 Rework the shutdown logic in the OpenGL backend. Eliminated race conditions. 2025-08-31 10:57:06 +02:00
Henrik Rydgård a1d0f405b1 Remove quantization error thingy. Other cleanup 2025-08-22 21:21:19 +02:00
Bobby Smith b717de67e9 [Libretro] Display a warning message if assets are missing 2025-08-07 12:14:55 +02:00
helloimhana123 5986c0148c Fixed RetroArch auto save states not working 2025-06-21 20:56:20 +02:00
Henrik Rydgård a630790d69 libretro: Fix the combination of Force Real Clock Sync and fastforward 2025-06-07 01:28:22 +02:00
sonninnos 08a1c10525 Libretro: Fix reset hang 2025-05-22 00:58:44 +03:00
Henrik Rydgård d77725bc26 libretro: Fix GPU init. Had to revert to the old way for libretro, something is ordering-sensitive here.
Fixes #20350
2025-05-17 10:18:07 +02:00
Henrik Rydgård 80147f318e Remove PSP_CancelBoot, assorted cleanup 2025-05-13 13:58:28 +02:00
Henrik Rydgård 879ec7ed06 Various libretro fixes. 2025-04-09 10:32:53 +02:00
Henrik Rydgård 6b37c8895d libretro buildfix 2025-04-05 09:18:56 +02:00
Henrik Rydgård 24b30cc709 Mostly remove coreState management from System.cpp 2025-04-05 09:18:56 +02:00
Henrik Rydgård 940e2375aa Libretro: Correctly update the boot process
Made untested changes after #20183 - surprise, it didn't work.

Thanks @Duarte475 for reporting.

Fixes #20189
2025-03-31 14:16:17 +02:00
Henrik Rydgård a131fb6149 Libretro fixes 2025-03-30 15:34:01 +02:00
Henrik Rydgård d3600ca127 Libretro buildfix 2025-03-30 11:28:14 +02:00
Henrik Rydgård 8d9b3f28f2 Reintroduce "cache ISO in RAM" 2025-03-27 00:46:31 +01:00
Henrik Rydgård 4eaad7d5af Remove the "Cache full ISO in RAM" feature
It's been broken for years and nobody has even noticed enough to report
it.
2025-03-26 09:06:33 +01:00
Henrik Rydgård 5fcf0c6276 Swap the Cancel and No functions in the assert dialog. Plus a function rename and some safety checks. 2025-03-25 00:01:14 +01:00
Henrik Rydgård d6d1b5bbdc Add mechanism to run any closure on the main thread 2025-03-03 13:59:39 +01:00
Henrik Rydgård cf90b24431 Add UI volume setting (affecting navigation sounds and preview audio). Convert alt speed volume into a 100-step percentage. 2025-02-11 17:42:09 -06:00