Commit Graph
3070 Commits
Author SHA1 Message Date
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 551e4cd0ab Headless: Make all GPU backends work correctly on Windows 2026-08-05 00:15:56 +02:00
Henrik Rydgård 25cf52176f Misc headless work 2026-08-05 00:15:56 +02:00
Henrik Rydgård 5eb4772644 Minor EmuThread refactor 2026-08-05 00:15:56 +02:00
Henrik Rydgård be922eca62 Make OpenGL render thread shutdown more robust. 2026-08-04 16:44:55 +02:00
Henrik Rydgård 971b5eca13 WASAPI: Use device's suggested format when available
When IsFormatSupported returns S_FALSE with a closestMatch format,
evaluate it and use it if it's acceptable (stereo float). This can
improve compatibility with devices that don't support our exact
requested format but have a similar one.

Previously we just discarded closestMatch and forced manual conversion,
which was wasteful when the device provided a perfectly usable
alternative format.
2026-08-04 00:37:55 +02:00
Henrik Rydgård 32f3fbd65a WASAPI: Fix channel mapping for 5.1 audi
CRITICAL BUG FIX: The previous code assumed incorrect channel ordering
for multichannel audio, breaking 5.1 (6-channel) configurations.

Problem:
- Code assumed channel order: FL, FR, RL, RR, C, LFE
o systems- Actual 5.1 standard order: FL, FR, C, LFE, RL, RR
- This caused center/LFE to receive rear audio and vice versa
- Users had to force stereo mode to get working audio

Solution:
- Parse dwChannelMask from WAVEFORMATEXTENSIBLE to determine actual
  channel positions
- Map stereo input to correct output channels based on the mask
- Properly handles 5.1, 7.1, and other multichannel configurations
- Safely handles non-standard channel layouts

The channel mapping now works correctly for all standard speaker
configurations by querying the device's actual channel layout instead
of assuming a fixed order.
2026-08-04 00:37:55 +02:00
Henrik Rydgård 11d4107230 WASAPI: Replace magic numbers with named constants
Define constants for channel upmixing attenuation factors to improve
code readability and maintainability:
- SURROUND_ATTENUATION (0.7f) for rear/side channels
- CENTER_MIX_ATTENUATION (0.7f) for center channel
- LFE_MIX_ATTENUATION (0.5f) for LFE channel
2026-08-04 00:37:55 +02:00
Henrik Rydgård fd1e48ecc5 WASAPI: Add error check for RegisterEndpointNotificationCallback
Log a warning if registering for device change notifications fails.
This is non-fatal but means automatic device switching won't work.
2026-08-04 00:37:55 +02:00
Henrik Rydgård 95e09324a7 WASAPI: Fix ClampFloatToS16 to use full s16 range
Changed minimum clamp from -32767 to -32768 to match the full
range of signed 16-bit integers.
2026-08-04 00:37:55 +02:00
Henrik Rydgård d97f42c225 WASAPI: Cache channel count to avoid unsafe pointer access from audio thread
Store format_->nChannels in atomic curChannels_ member to avoid
unsynchronized access to format_ pointer from the audio thread.
The format_ pointer can be freed/reallocated during Stop() while
the audio thread might still be reading it.
2026-08-04 00:37:55 +02:00
Henrik Rydgård 456cfb0f5a RAIntegration crashfix 2026-07-27 18:37:28 +02:00
Henrik Rydgård 5ef736f6a7 More command line improvements 2026-07-27 18:37:28 +02:00
Henrik Rydgård ccff34b431 Reuse the AndroidJavaGLContext as the new generic OpenGLGraphicsContext 2026-07-26 20:07:14 +02:00
Henrik Rydgård cb623f725c Get rid of the SDL-specific Vulkan graphics context 2026-07-26 19:10:46 +02:00
Henrik Rydgård 3784bbe0e6 Delete the AndroidVulkanContext, replace with the generic VulkanGraphicsContext 2026-07-26 19:10:46 +02:00
Henrik Rydgård e3d36e2741 Move the VulkanGraphicsContext to its correct location in Common/GPU/Vulkan 2026-07-26 14:15:15 +02:00
Henrik Rydgård 12cbe2143a Rename WindowsVulkanContext to VulkanGraphicsContext, preparing for moving it 2026-07-26 14:01:05 +02:00
Henrik Rydgård 3eb056ad86 Move Common/GraphicsContext.h to Common/GPU/GraphicsContext.h 2026-07-26 13:58:17 +02:00
Henrik Rydgård 4a95d8eeaa Fix exit crash on Windows, oops 2026-07-26 13:37:33 +02:00
Henrik Rydgård 7f218acc53 Change the GraphicsContext interface to be more consistent 2026-07-26 10:22:00 +02:00
Henrik Rydgård c2c0fa3634 Remove the AndroidGraphicsContext middle-level class 2026-07-26 10:21:59 +02:00
Henrik Rydgård 85f8715660 Break the circular dependency caused by putting EmuThread in core using an interface 2026-07-24 15:31:42 +02:00
Henrik Rydgård af7977267e Add NeedsRenderThread property to GraphicsContext 2026-07-24 15:31:41 +02:00
Henrik Rydgård 86c98c2d23 Prepare EmuThread for other users 2026-07-24 15:31:41 +02:00
Henrik Rydgård cb18929f3a Make EmuThread.cpp/h compile outside of Windows. 2026-07-21 13:25:31 +02:00
Henrik Rydgård 32f975ef85 Windows: Move the graphics context creation to main.cpp 2026-07-21 13:13:01 +02:00
Henrik Rydgård cc69070f19 Remove MainThread_Start/Stop to increase visibility 2026-07-21 12:58:45 +02:00
Henrik Rydgård 221aba92da Move EmuThread.cpp/h to Core, in preparation for sharing logic 2026-07-21 12:50:22 +02:00
Henrik Rydgård 16c7ec390f Headless: Start taking logic out of the "HeadlessHost"
Also update some agent files
2026-07-21 11:01:48 +02:00
Henrik Rydgård bd25962cbe Convert more options to the new command line parser 2026-07-20 16:33:03 +02:00
Henrik Rydgård e6875fa339 More cmdline work. 2026-07-20 16:33:03 +02:00
Henrik Rydgård a59637975a Call the new command line parser from all backends 2026-07-20 12:02:07 +02:00
Henrik Rydgård acc0a19786 wip 2026-07-20 12:02:07 +02:00
Henrik Rydgård a73fcc7b4b Windows: Call NativeInit/NativeShutdown outside the EmuThread. 2026-07-20 12:02:07 +02:00
Henrik Rydgård f022328521 Remove the "restart emuthread" facility that isn't really working (and won't be compatible with the next refactorings) 2026-07-20 12:02:07 +02:00
Henrik Rydgård 29836ea74e Move the new incomplete command line parser to Core 2026-07-20 12:02:07 +02:00
Henrik Rydgård a886cfb5ab First step of centralizing command line parsing 2026-07-20 12:02:07 +02:00
Henrik Rydgård f5a8ad172e Fix various issues with the headless build (for running frame dumps) 2026-07-19 00:09:06 +02:00
Henrik Rydgård b469e57735 Some refactoring in Windows/EmuThread.cpp/h 2026-07-18 23:54:32 +02:00
Henrik Rydgård 986eee7ef3 Remove the global variable "useEmuThread", add some VK error checking for compute shader compiles 2026-07-18 23:45:27 +02:00
Henrik Rydgård fdf186e43b Windows: Refactor console positioning, moving the code out of EmuThread.cpp 2026-07-18 20:58:29 +02:00
Henrik Rydgård 993c3a9c67 Avoid accurately computing disk space on iOS and Android (where it can be slow). Add a setting. 2026-07-14 22:22:29 +02:00
Henrik Rydgård 61e1ef8f7a Remove the "Software skinning" option. Now always on. 2026-07-14 17:02:57 +02:00
Henrik Rydgård 1b2f87bf1a Rename GPUgstate to GEState 2026-07-02 20:34:09 +02:00
Henrik Rydgård 5d609598ce Add some extreme paranoia-level error checking 2026-06-24 20:15:35 +02:00
Henrik Rydgård 0070ec2155 Improve audio logging, fix the fallback with some errors 2026-06-24 19:32:24 +02:00
Henrik Rydgård 1e62cb7fc1 Finish the SDL3 port on Mac, update CI to 26.04 2026-06-16 11:39:57 +02:00
jasaaved 95006cf1d3 Changed bFullScreenExclusive to bAllowFullScreenExclusive
There's no guarantee VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT will enter Fullscreen exclusive (FSE). Under the right conditions, the driver and/or DWM can grant FSE. Adding "allow" to the FSE setting should make this a bit clearer.
2026-06-04 12:54:52 -07:00
jasaaved 0c23cdaf3d Windows Vulkan: default to borderless fullscreen, add exclusive option
Vulkan swapchain now explicitly sets VK_FULL_SCREEN_EXCLUSIVE_DISALLOWED_EXT by default, enabling proper borderless fullscreen behavior with benefits including better Alt+Tab, VRR/G-Sync/FreeSync, and Auto HDR support.
2026-06-03 17:15:13 -07:00