96 Commits
Author SHA1 Message Date
LibretroAdmin 85b64dc7b0 VideoCommon: video globals and backend objects as plain pointers 2026-11-08 03:21:40 +01:00
LibretroAdmin eac19c3216 VideoCommon: textures, framebuffers and vertex formats as plain pointers 2026-11-08 03:21:36 +01:00
LibretroAdmin af730f1208 VideoCommon: drop the before-present event
Nothing listens to it, so the XFB copy names gathered for it each frame
are no longer gathered.
2026-11-08 01:17:29 +01:00
LibretroAdmin b10df251e4 Remove frame dumping and screenshots
The frontend takes screenshots and records video.
2026-11-07 20:34:48 +01:00
LibretroAdmin 4b604fbd32 Remove FFmpeg movie dumping
Frame dumps are written as PNG images.
2026-11-07 19:20:50 +01:00
LibretroAdmin 043c12979f Remove the Output Resampling setting
The output is handed on at the picture's own size, and the frontend
scales it. A picture drawn scaled is sampled bilinearly.
2026-11-07 19:07:22 +01:00
LibretroAdmin 03810f4a91 VideoCommon: an XFB copy lost from VRAM keeps the shown picture
XFB copies kept only in VRAM go with the texture cache when the video
backend is made again or a state is loaded. RAM then holds only the
uninitialized marker, so no picture is fetched from it and the frontend
keeps the one it shows until the game's next XFB copy.
2026-11-07 18:25:34 +01:00
LibretroAdmin c31327c410 GBA on the link cable as a controller type, its screen drawn zero-copy
A GameCube port can take a Game Boy Advance; its buttons are on the
port's RetroPad and it boots from gba_bios.bin in the system directory
when that is there. Its screen is drawn along the bottom right of the
picture (GBA Screens option): mGBA renders each frame straight into
upload memory the GPU thread lends it and keeps mapped, swapped in
through one atomic word, and a buffer goes back to the GBA only once
the GPU has copied from it. Without such memory the frames are uploaded
from plain buffers. The buffers are taken back, with the GBA's thread
letting go first, before the video backend goes.

Port devices change through the config, which the SI applies on the
CPU thread.
2026-11-07 16:38:22 +01:00
libretroadmin c878c0d818 remove LIBRETRO ifdefs 2026-11-07 14:23:51 +01:00
LibretroAdmin 58542ddb3a Vulkan, D3D12: the GPU loop on a thread of its own
On Vulkan and Direct3D 12, in dual core, the GPU loop runs on a thread
of its own, as the frontend interface for both lets another thread
submit: retro_run starts the field, waits for it no longer than two of
the frontend's frames (40 ms at most), hands over the newest picture
finished and returns. A shader compiled, or anything else slow on the
GPU side, holds up the GPU thread only. The loop runs in slices of 5 ms,
so a request to park or quit is seen that soon; a slice that ends a
field counts it for retro_run.

Pictures go from the GPU thread to the frontend's through a queue: the
newest published, the one being handed over and the one shown, any of
which the frontend may read. Each output draws into images of its own,
three of them: a picture published and not yet handed over is drawn
into again in place. EndFrame hands over with set_image, or
set_texture_fenced and set_texture, on the frontend's thread, and an
image is free again once the frontend's frame that read it is
submitted. An XFB copy handed on in place is kept alive by the
presenter while the output holds it, and the output puts it back in the
layout or state the frontend reads it in before every submission of
the core's, as the frontend submits on its own thread whenever its
frame is due.

Savestates, cheats and disc changes let the field in flight end on the
GPU thread and park it while the frontend's thread has the video state;
unloading and a context destroyed stop it, and the next retro_run starts
it again.

Direct3D 11 and OpenGL keep the GPU loop on the frontend's thread: the
immediate context is shared with the frontend through lock_context,
which a thread holding it through a slow compile would hold the
frontend's frame up on, and the OpenGL context is the frontend's
thread's.
2026-11-06 22:25:52 +01:00
LibretroAdmin 7f0328d960 libretro: retro_run never waits on a held-up CPU thread
retro_run runs the GPU until the CPU thread ends the field, and the
field ends only as fast as the CPU thread gets through it: a disc read
or anything else holding that thread up held the frontend's frame up
with it, and the frontend counted no frames.

The GPU loop now has a deadline on the wall clock, two of the
frontend's frames and never more than 40 ms: it is checked every 64
chunks of the fifo, and the loop's sleep waiting for work is bounded by
it. Past it the run reports a repeat and returns, the CPU thread goes on
with its field, and the next run takes the rest of the field's work.
A field's end that comes while the loop is out of time is kept for that
next run. Every run reports one frame, before the first picture too,
with the size the frontend was told.

A field swapped while a state is saved or loaded, outside retro_run,
is not presented: the frontend takes pictures only inside retro_run, so
the next field is presented instead.

Whatever pauses the CPU thread from the frontend's (savestates,
cheats, a disc change, unloading) first runs the GPU until the field in
flight ends, so the CPU thread is paused at a field's end as after a
full run, never waiting on GPU work only this thread runs.
2026-11-06 21:38:30 +01:00
LibretroAdmin 14e21584dd D3D11: the XFB texture handed to the frontend in place
With version 2 of the frontend interface, a picture whose draw would be
a plain copy is not drawn: the XFB texture itself is named with
set_texture and the frontend reads it where it is. That is the case
when the XFB fills the whole output from its top-left corner at the
same size, with one layer, no stereo, no colour correction and the
default resampling; with crop overscan on, a full-height XFB at the
internal resolution. Anything else is drawn into the output's targets
as before.

The immediate context orders the frontend's reads before anything later
drawn into the texture, so no sync index is waited on. Fields that
repeat the picture keep its XFB copy locked as the one being shown, and
fields that blank the screen lock it until another picture replaces it,
so the copy the frontend shows again is never written meanwhile.

The hook is FrameOutput::PresentTexture, reached through
AbstractGfx::PresentTexture: an output that only hands on its own
targets returns false and the picture is drawn.
2026-11-06 20:27:28 +01:00
LibretroAdmin 1329ca90c6 Video: a repeated picture reported as a repeat, with nothing drawn
Every retro_run hands the frontend exactly one frame. A field that only
repeats the picture before it is not drawn on any backend, OpenGL and
Direct3D on Xbox included: the frontend is told at the end of the run
that the last picture repeats (video_refresh with no data, at the last
picture's size), and shows again what it already has, the target it
reads in place or its own copy. A run that shows something new hands
it over as before, now always as a valid frame.

Loading a state no longer presents from inside retro_unserialize, where
the frontend takes no pictures. The next field presents the loaded
picture inside the next run and is never taken for a repeat of what was
shown before the load.
2026-11-06 20:15:08 +01:00
LibretroAdmin 53238c0a06 VideoCommon, backends, input, DiscIO: std::atomic -> retro_atomic
- CommandProcessor: the FIFO registers shared by the CPU and GPU
  threads are retro_atomic words, read and written through LoadReg and
  StoreReg; MMIO's LowPart/HighPart take those words.
- Fifo: the video buffer write and seen pointers, the sync ticks and
  the stop request.
- PerfQueryBase: the query count and results sit behind base-class
  helpers that every backend (Metal too) uses instead of touching the
  atomics.
- Custom assets: the loader's memory delta and an asset's last load
  time are 64-bit words; Present's swap flag is an int.
- D3D's input layout, Vulkan's waiting_for_submit.
- InputCommon: a NumericSetting's value and the Wiimote and Android
  rumble levels are kept as their bits in a 64-bit word; the
  ControllerInterface flags, counter and aspect ratio are int words.
- CachedBlob's fill position and stop flag.

UICommon/GameFileCache is deleted: only the Android app's game list
used it, and that is not part of the core.
2026-11-06 00:19:39 +01:00
LibretroAdmin a2404c6e43 Remove the on-screen messages and the ImGui overlay
Nothing is drawn over the game any more. The OSD message queue, the
ImGui overlay that drew it (with the shader-compile progress window and
the statistics, projection and scissor windows), and the imgui and implot
libraries are removed from the build.

Core::DisplayMessage now writes to the log, and the former OSD calls
go through it. Shader compilation no longer presents frames outside
retro_run while it waits.

Deleted with it: the "OSD enabled" core option, the OSD, FPS, speed,
graph, statistics and internal-resolution display settings, and the
ImGui shaders and texture conversion.
2026-11-05 23:34:25 +01:00
LibretroAdmin 1e2dbf6616 Remove all sleeping and wall-clock pacing from the core
retro_run runs one video frame and the frontend paces it, so the core no
longer paces itself:

- The speed limiter is gone: CoreTiming::Throttle and its host-time
  targets, VI skip, the presenter's presentation-time wait,
  PrecisionTimer, PerformanceMetrics/PerformanceTracker, and the
  emulation speed, precision timing, rush/smooth presentation and VI
  skip settings and core options. The Dolphin IOS device reports 100%
  and ignores speed limits a guest asks for.
- Common/FrameClock.c (C89) counts retro_run calls. Background threads
  that acted every so many milliseconds wait for a number of frames
  instead: real-Wiimote pool upkeep, scanning, write tests and
  reconnect retries, USB scanning, the USB Gecko and GBA link
  listeners, the BBA read thread, memory card flushing and the WC24
  scheduler. Shutdown wakes every waiter.
- Waits that polled or timed out now block until signalled: dual-core
  boot, PauseAndLock in the GPU loop, CPU thread jobs, shader
  compilation progress, BlockingLoop and ParallelFor setup and
  teardown.
- Bluetooth passthrough submits transfers straight to libusb; the
  output worker and its timed sleep are deleted, HCI command timeouts
  count emulated time, and blocking firmware commands wait for the
  adapter's events.
- Real Wiimote reports go out when produced; delayed ones carry a
  frame number.
- Common::Flag sits on retro_atomic.
- Deleted: SleepCurrentThread, YieldCPU, Common::SleepUntil,
  Event::WaitFor, BlockingLoop::WaitYield, timer resolution changes,
  the play-time tracker, Host_YieldToUI, FrameTiming::ThrottleFrame
  leftovers and the never-used DO_WAIT_FOR_WIIMOTES mode.
2026-11-05 22:05:03 +01:00
LibretroAdmin 407a632adc Core, VideoCommon: replace the per-frame locks with atomics
CPU: the state machine drops its two mutexes and two condition
variables.  The state is one atomic word, which the JIT still reads in
place; PowerDown sticks through a CAS.  The CPU thread marks itself
active and then rechecks for a pause or a state change, and a pausing
thread stores its request and then waits for the flag to drop, a
Dekker pair, so neither misses the other.  Waits park on eventcounts.
A step request and its Event travel as one exchanged pointer, pending
jobs are an MPSC stack run in order, and SetStepping and PauseAndLock
still run one at a time, through a claimed flag.

Core: the recursive core mutex goes.  Stop moves the state with a CAS,
and PauseAndLock pairs are already serialized by the CPU's claim.  Host
jobs are an MPSC stack the host thread moves, in order, into its own
queue, which keeps HostDispatchJobs re-entrant.  RunOnCPUThread waits
on a Common::Event instead of a binary semaphore, and OneShotEvent is
removed.

State: the transferable shared mutex that counted save tasks is a
counter and an eventcount; the slot readers and the flush hook wait for
it to reach zero.  TransferableSharedMutex is removed.  WaitableFlag
parks on an eventcount.

PixelEngine: the token, its interrupt flags and the raised-event flag
are one atomic word; the video thread merges into it and schedules the
event only on the edge, the CPU thread takes the flags with a CAS.
Savestates keep the old fields.

VertexLoaderManager: the loader map is a fixed set of buckets, each a
list pushed with a CAS and read without a lock by the main and the
preprocessing thread; two threads making the same loader keep one.

AsyncShaderCompiler: the pending queue is the video thread's own.  It
hands the most urgent items to two slots per worker, and finished items
come back on an MPSC stack, so neither side takes a lock.

OSD messages are posted to an MPSC stack and taken in by the video
thread when it draws; a screenshot request is one exchanged string.

Also removed, being unreachable: the surface change and resize requests
nothing sends (and the swap mutex guarding them), the ImGui keyboard
and mouse input nothing feeds (and the ImGui mutex, as only the video
thread touches the context now), ClearMessages, and the libretro Vulkan
WaitForPresentation with its mutex and condition variable.
2026-11-05 20:11:27 +01:00
LibretroAdmin 472dc5ae3f Remove user post-processing shaders and graphics-mod custom shaders
Both fed user-written GLSL to the backends at runtime, which the move to
bytecode emitted straight from the shader generators leaves no compiler
for. The frontend's own shader pipeline covers post-processing.

The presentation pass keeps a plain copy and the built-in correction
shader for output resampling, colour space and gamma correction and HDR
scaling, now compiled in rather than loaded from Sys/Shaders. The
graphics-mod system keeps its draw, EFB, projection and texture actions;
custom pipelines, materials, shader, mesh and sampler assets, the custom
constant buffers in every backend and the two mods built on them are
gone, along with the shader generators' custom-shader hooks.
2026-11-05 15:57:56 +01:00
WizzardSK 3d6c288145 libretro: Aspect Ratio: the frontend shows the picture at the mode's aspect ratio, Dolphin stretches it over the frame
Dolphin fitted its picture into the frame by the Aspect Ratio mode, bars
and all, and the frontend scaled the frame to 4:3 or 16:9 once more, so
every mode but Stretch came out squeezed or stretched (Custom, Custom
Stretch and Raw the most). Dolphin now always stretches over the frame,
and the core gives the frontend the aspect ratio Dolphin works out for the
chosen mode (Presenter::CalculateDrawAspectRatio for a given mode), again
whenever it changes. Stretch and VR are as before.

Vulkan hands the frontend the whole swapchain image Dolphin presented
into, as D3D11 and OpenGL do with their backbuffer, instead of the EFB's
size (640x528 against a 640x480 image), which squeezed the picture.
2026-10-28 19:26:30 +01:00
Craig Carnell d02c31a877 Merge in upstream/master and resolve compiler failures from update 2026-08-07 20:58:58 +01:00
JosJuice c958dbc46c VideoCommon: Use XFB for internal resolution stats
fb4ff3e added a statistics option to show the internal resolution, but
it just showed the total size of the EFB (which is always 640x528) times
the IR scale, so it didn't convey any useful information.

This commit instead makes the option use the size of the last XFB copy
(not multiplied by the IR scale), which changes based on the game's
rendering resolution.
2026-07-05 09:50:13 +02:00
JosJuice 5f372d6b1d VideoCommon: Reduce padding in PresentInfo
This makes the struct 8 bytes smaller.
2026-07-05 09:50:13 +02:00
Craig Carnell 3d070f498a libretro: update to 2606 2026-06-25 09:54:48 +01:00
Admiral H. Curtiss afd343ec9c Reimplement custom cropping by adjusting the source aspect ratio 2026-05-24 20:51:23 +02:00
Admiral H. Curtiss ba15ddd602 Revert the Presenter logic changes from #14506 2026-05-24 19:47:18 +02:00
Admiral H. Curtiss d3217f65c3 Merge pull request #14506 from adamscott/crop-that-screen
Add screen crop feature
2026-05-23 20:53:31 +02:00
Admiral H. Curtiss 17b4b8fc07 Address minor nits in new cropping logic 2026-05-23 19:47:28 +02:00
Dentomologist f67d80c7c1 VideoConfig: Rename StereoMode::TAB to StereoMode::TopAndBottom 2026-04-24 11:19:11 -07:00
Dentomologist 655ee270e7 VideoConfig: Rename StereoMode::SBS to StereoMode::SideBySide 2026-04-23 12:32:26 -07:00
Adam Scott a5059cbca8 Add screen crop feature 2026-04-18 13:08:41 -04:00
Craig Carnell 242e427832 libretro: fix uwp version 2026-03-14 15:03:48 +00:00
Craig Carnell 2425cf49ae libretro: remove frame skipping when ff 2026-02-23 16:32:45 +00:00
Craig Carnell 7743c7e1dd Merge in upstream dolphin/master into libretro 2026-02-22 09:07:47 +00:00
Sintendo 1e0473e44f Fix various typos and spelling mistakes 2026-01-17 20:11:38 +01:00
Craig Carnell 73d2b069bf Merge upstream/master into libretro 2025-12-22 11:48:26 +00:00
Jordan Woyak 44a766772f VideoCommon: Add a hidden setting to cap immediate XFB swaps to one per VI. 2025-11-25 00:15:32 -06:00
Craig Carnell ae98a5fa9e Small refactor for upstream changes, add single core mode 2025-11-16 16:25:15 +00:00
Craig Carnell f011bebbad Merge upstream/master into libretro 2025-11-16 16:22:40 +00:00
Jordan Woyak c2a1dce246 VideoCommon: Add "Smooth Early Presentation" setting to improve frame pacing with ImmediateXFB and/or RushFramePresentation. 2025-11-11 20:01:52 -06:00
Jordan Woyak cc331feb02 VideoCommon: Make Presenter aware of the next swap time to eliminate unsafe usage of GetTicks() with ImmediateXFB + DualCore. 2025-11-11 20:01:52 -06:00
Jordan Woyak 16260040e0 CoreTiming: Add "Rush Frame Presentation" setting to throttle only once after each presentation for lower input latency. 2025-11-11 20:01:52 -06:00
JMC47 f63796c480 Merge pull request #14071 from iwubcode/avoid_config_framebuffer_manager
VideoCommon: pass the EFB buffer scale into the FramebufferManager
2025-11-11 20:58:35 -05:00
Jordan Woyak da6c65bf3b Common: Remove the string parameters from the HookableEvent interface. 2025-11-06 22:34:40 -06:00
iwubcode 2f20c12d82 VideoCommon: pass the EFB buffer scale into the FramebufferManager instead of pulling it from config, in the future this will allow us to have multiple framebuffers 2025-11-05 21:52:54 -06:00
Jordan WoyakandDentomologist f289b06e0d Common: Make HookableEvent use non-static data.
Co-authored-by: Dentomologist <[email protected]>
2025-11-02 17:30:43 -06:00
Craig Carnell 7189a75497 Move to core options V2 style 2025-10-30 14:02:54 -04:00
Craig Carnell 71fd149aa6 Refactor base code for libretro usage 2025-10-10 09:23:54 +01:00
Jordan Woyak 48b2f7d200 VideoConfig: Eliminate frame dumping members. 2025-03-16 04:30:06 -05:00
Jordan Woyak 7222188cde Core/VideoCommon: Push presentation time calculated from CPU thread to GPU thread. 2025-03-10 16:40:46 -05:00
Jordan Woyak c18c039089 VideoCommon: Move backend_info out of VideoConfig struct. 2025-03-09 01:42:45 -06:00