Commit Graph
170 Commits
Author SHA1 Message Date
Henrik RydgårdandClaude Opus 5.5 a361dfc490 Drop unused Config.h and SmallDataConvert.h includes
Config.h is edited about 100 times a year and each edit recompiled 198
files; now 172. SmallDataConvert.h pulls in arm_neon.h and was included by
headers that don't use it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 12:13:42 +02:00
Henrik RydgårdandClaude Opus 5.5 d15e094ed6 Vulkan: Key delayed readbacks by position and aspect too
The OLD_DATA_OK readback cache was keyed by framebuffer and size only, so
two equal-size rects of one framebuffer shared a buffer and each read got
whichever was copied last. Add x, y and the aspect to the key.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-12 12:15:56 +02:00
Henrik RydgårdandClaude Opus 5.5 4202368b1e Vulkan: Look up multisampled framebuffers through a CLUT by their first sample
With MSAA, a framebuffer textured as CLUT indices was read resolved, so the
indices along edges were averages of the samples and looked up wrong colors.
Dragon Ball Z: Tenkaichi Tag Team draws its outlines from a CLUT32 lookup of
its framebuffer, and they came out noisy and miscolored. Copy each pixel's
first sample with texelFetch into a temporary buffer and look up that.

This needs the multisampled color images to be sampled, and transitioned
back to attachment layout before rendering to them again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 15:49:15 +02:00
Henrik RydgårdandClaude Opus 5.5 d0baab5614 Compute FIXA/FIXB blends like the GE
The GE's blend terms are floor((2c+1)(2f+1)/1024), which truncates, while the
hardware multiplies by f/255 and rounds, so every pass of a fixed color blend
chain came out up to a level brighter. God Eater Burst's bloom is many such
passes and ended up far too bright.

For additive FIXA/FIXB blends that aren't just 0 and 0xFFFFFF, the shader
now computes the src term exactly and lowers it by 0.5 - (2B+1)/1024, and the
blend constant is the GE's dst factor (2B+1)/512, so the hardware's rounding
of the sum lands on the GE's floor (except where the src term would go below
zero). Blend constants are passed as floats to make that possible.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-09 09:09:36 +02:00
Henrik RydgårdandClaude Opus 5 812d8f4c09 Android GL: Delete the JavaGL path, leaving only native EGL
The EGL path from the previous commit is now the only one, so GLSurfaceView
and everything that existed to serve it are gone:

- NativeRenderer.java and NativeGLSurfaceView.java, deleted.
- The javaGL branches in PpssppActivity. GL and Vulkan now share one
  lifecycle: a plain SurfaceView, startRenderLoopThread() when the surface
  arrives, joinRenderLoopThread() when it goes away.
- The "androidJavaGL" queryConfig, and the AndroidNativeEGL setting and its
  developer-tools checkbox.
- displayInit/displayRender, and with them the "Second time, joining the
  emuthread and starting it up again" dance - restarting the emu thread from
  inside a JNI callback because a lost context was only observable as a
  second onSurfaceCreated.
- GraphicsContext::NotifyContextLost, which existed solely because that join
  drained the render queue on a thread with no current context. The render
  thread now joins the emu thread with the context still current, so the
  drain is real work and nothing has to be skipped.
- g_emuThread, now that nothing starts an emu thread outside the render loop.

Three things displayInit/displayRender did that nothing else did, moved
rather than dropped:

- EnterVR and the per-frame StartVRRender/UpdateVRInput/FinishVRRender hooks
  now live in RenderLoopThread's GL branch. Java's GL thread could simply
  return early and wait for the next vsync when the VR session was inactive;
  this loop drives itself, so that case sleeps 16ms instead of spinning.
  Not tested - no headset here.
- RECREATE_VIEWS after the emu thread starts, as before. Vulkan never did
  this, so it's a candidate for removal when the two paths converge.
- The thin3d error callback, which surfaces GL errors as OSD messages. That
  one moved into AndroidEGLGraphicsContext::InitSurface, next to the rest of
  the context's own setup, matching WindowsGLContext.

Tested on a nubia Z2464N (Unisoc UMS9632, Mali-G57, Android 15): cold start,
UI, booting a homebrew, backgrounding and resuming both in the menu and
in-game, and a density change, which destroys and recreates the activity the
way a rotation does. Every cycle tears the EGL context down and builds a new
one, and the renderer comes back with FBOs and textures intact. The config
ladder's first choice, RGBA8888 D24S8, is what the Java chooser landed on
here too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01152igCdjTNhT29qvphPyPC
2026-10-08 15:22:25 +02:00
Henrik RydgårdandClaude Opus 5.5 a66e94c015 Vulkan: Don't merge an empty clear pass past a copy into the framebuffer
PreprocessSteps moved the clear of an empty clear pass into the next render
pass on the same framebuffer, stopping only at copies out of it. Resizing a
framebuffer clears the new one, copies the old contents in, then renders, so
the clear landed after the copy and wiped it. Stop at any copy, blit or
readback that touches the framebuffer.

Fixes black or missing layers in Asphalt Urban GT 2, FF Type-0, Street Riders,
Kurohyou, Split/Second and Super Stardust.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-08 10:36:18 +02:00
Henrik RydgårdandClaude Opus 5 0655fcc711 Vulkan: Guard the render pass cache against the render thread
GetRenderPass() looks up and inserts into renderPasses_ from the main thread
(EndCurRenderStep, CreateGraphicsPipeline) and from the render thread
(PerformBindFramebufferAsRenderTarget), unsynchronized. The render thread really
does insert rather than only hit: PreprocessSteps rewrites the load actions to
CLEAR when it merges a clear-only pass into a later one, after the main thread
already looked up the pre-merge key. DenseHashMap::Insert can Grow(), which
reallocates the buckets out from under a concurrent Get().

VKRRenderPass::Get() has the same problem one level down - it creates the passes
lazily and is called from both threads on the same object, so two threads hitting
an empty slot each create a pass and one gets overwritten and leaked, while the
sample-count branch can queue a pass for deletion that the other thread is about
to hand to vkCreateGraphicsPipelines.

A mutex each. Handing the VKRRenderPass pointer out from under the map lock is
fine, entries are only ever erased all at once in DestroyDeviceObjects.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Vd8ntC2brCUtCrDJMqLbs8
2026-08-29 11:42:47 +02:00
Henrik Rydgård abb57c620f Adjust some log levels 2026-08-09 22:10:54 +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 7b3405ab86 Fix a Vulkan lifetime issue causing invalid descriptors on shutdown
Also simplifies the code a little
2026-06-25 21:56:33 +02:00
Henrik Rydgård 9845a78a46 Vulkan: Correct handling of VK_ERROR_OUT_OF_DATE_KHR 2026-05-28 10:56:35 +02:00
Herman Semenoff eaae4dca82 Vulkan: duplicate fields move to separate const reference var 2026-05-27 12:23:47 +02:00
Henrik Rydgård 02a624075a Android: Make the "Auto" rotation mode override user rotation lock (SENSOR mode) 2026-03-31 10:43:27 -06:00
Henrik Rydgård 0c3f6afeef Vulkan: Fix MSAA crash due to silly typo 2026-02-05 11:03:33 +01:00
Henrik Rydgård 7bca84252e Vulkan: Add support for doing intra-buffer block copies with vkCmdCopyImage. 2026-01-22 13:47:41 +01:00
Henrik Rydgård 502da9315d Add a sanity check after acquiring swapchain images 2026-01-01 14:48:35 +01:00
Henrik Rydgård 80bd32325c Move the present mode from the CreateInfo to InitSwapchain 2025-10-20 16:33:34 +02:00
Henrik Rydgård 6338832015 Vulkan: Smoothly recreate the swapchain using oldSwapchain on "resize" on Windows 2025-10-20 15:42:34 +02:00
Henrik Rydgård c3dfddebd7 IR interpreter: Improve code gen for the main interpreter loop
Thanks to fp64 for the idea of using unreachable markers to avoid the
range check on the switch!

Additionally, use it in a few more places.
2025-10-15 21:15:30 +02:00
Henrik Rydgård 9137eedb7b Windows/Vulkan: Correctly handle minimizing and restoring the window
We can't create a swapchain in this case but we still want emulation to
keep running. So we ditch the last renderpass in VulkanQueueRunner but
run all the rest (if PauseWhenMinimized isn't set).

Now works without any validation errors or hangs.
2025-07-18 20:01:48 +02:00
Henrik Rydgård 536cb483d9 Move swapchain image data responsibility to RenderManager, part 1 2025-05-20 08:42:37 +02:00
Henrik Rydgård 7efd604c25 Improve the MGS Acid 2 hack to fix the oil spill crash
Not really proud of this, but takes care of #20306 for now.
2025-05-16 19:22:37 +02:00
Henrik Rydgård 73cdbe204e Fix Star Ocean with MSAA enabled: don't use the blit optimization, can't blit to multisampled images. 2025-04-10 21:33:05 +02:00
Luboš V. d1f8b78bbb OpenXR - Remove non-functional Vulkan implementation (#19766)
* OpenXR - Remove non-functional Vulkan implementation

* Forgotten to commit
2024-12-26 10:05:18 +01:00
Henrik Rydgård 99f7946471 Vulkan GraphicsPipeline: Fix an old and likely very rare race condition. 2024-10-22 11:02:26 +02:00
Henrik Rydgård 4d6905672e Bunch more linting 2024-10-10 11:57:10 +02:00
Henrik Rydgård c631fe355f Fix the MGS2 Acid renderpass merge optimization
Failed to merge the specified renderAreas, leading to AMD skipping
rendering of much of the screen.

Fixes #17680
2024-09-09 18:12:53 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård b592473416 Vulkan: Add a missing barrier that got lost in the refactor 2024-04-08 09:00:44 +02:00
Henrik Rydgård 036c386b35 More barrier optimizations 2024-04-07 22:20:37 +02:00
Henrik Rydgård 60f350056c Vulkan: Optimize away a barrier in case of no depth buffer 2024-04-07 21:43:06 +02:00
Henrik Rydgård 78c0be3d8a Delete now-unused code 2024-04-07 21:25:04 +02:00
Henrik Rydgård d949331f67 More use of the auto image layout transition functions 2024-04-07 21:24:25 +02:00
Henrik Rydgård 7769bf06f1 Add a simplified wrapper for Transition*ImageAuto that takes a VKRImage 2024-04-07 21:14:45 +02:00
Henrik Rydgård 3e91095313 Replace the "FromOptimal" layout transitions with auto. This fixes some rendering errors on NV. 2024-04-07 21:14:45 +02:00
Henrik Rydgård 9c4dd32db0 Replace the "ToOptimal" layout transitions with the auto ones 2024-04-07 21:14:45 +02:00
Henrik Rydgård 58fea04b8a Split the auto image layout transition function (color/depth-stencil) 2024-04-07 21:14:45 +02:00
Henrik Rydgård 6ac5a21846 Update the layout from within TransitionImageAuto 2024-04-07 21:14:45 +02:00
Henrik Rydgård 0bdbffd12f Revert minor optimization that needs some more work first 2024-04-07 21:14:45 +02:00
Henrik Rydgård a3d0cb1f12 Switch away from TransitionImageLayout2 2024-04-06 17:12:32 +02:00
Henrik Rydgård e00f1f10a3 More barrier code simplification 2024-04-06 17:03:44 +02:00
Henrik Rydgård 4a5eb4bdfb More cleanup 2024-04-06 17:03:40 +02:00
Henrik Rydgård d28e9dc006 Minor cleanup 2024-04-06 17:03:40 +02:00
Henrik Rydgård 4ea58b64d4 Merge our two different Vulkan barrier batch implementations 2024-04-04 15:32:48 +02:00
Henrik Rydgård 25a1e6aa14 Some renaming, add a bunch of sanity debug-asserts 2024-01-30 11:14:21 +01:00
Henrik Rydgård d260cd0498 Some sanity checks. 2024-01-24 00:23:08 +01:00
Henrik Rydgård ce2163eb93 Vulkan MSAA: Avoid creating backbuffer renderpasses with the wrong sample count, oops 2024-01-17 21:41:04 +01:00
Henrik Rydgård 6de05f13f1 More barrier batching 2023-12-30 10:41:59 +01:00
Henrik Rydgård 126d88ecfc Back out clearly inconsequential/useless .reserve() calls 2023-12-29 08:27:56 +01:00
Henrik Rydgård 28189dc738 Vulkan render queue runner: Count commands in debug builds, like the GL backend. 2023-12-20 15:26:41 +01:00