mirror of
https://github.com/libretro/RetroArch.git
synced 2026-11-22 10:50:15 -10:00
codex/android-native-streaming
451
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
0c228a1d0d |
core signatures: poll a parked load only while one waits
core_load_check_iterate() ran every frame, a call into another translation unit even in a build whose check is dormant (no signing key compiled in) or with nothing parked. A park now raises a frame_work bit, RUNLOOP_WORK_CORE_PARK, and its drop lowers it, so the frame loop skips the call as it does Discord, cheats and the camera when they are idle. Every way a park ends goes through core_load_park_drop(), so the bit can't outlive it. The core_load_check harness now polls only under the bit, as the frame loop does, and checks it rises with a park and falls once the park has run. |
||
|
|
cd0804d60f |
core signatures: refused loads ask on the Security Warning
A staged load whose core the check refuses ends as a failed load does and is parked with what it needs to run again, its subsystem state included. It keeps that snapshot after the preload stage's pass too, so a core that changes before the core stage opens it is parked, not failed silently. Load Core and the other user actions with no load after their probe park the core load; a parked Load Core whose core changed since its check parks again on its re-run. Probes stay quiet. Subsystem loads from a playlist or from netplay, whose subsystem a refused core can't name, are not parked: they say the core wasn't loaded and how to trust it. So does a netplay lobby join of a refused core, which then leaves netplay off. While the first run's seed hasn't checked the core's folder yet, they say RetroArch is still checking the installed cores. The companion UI's Load Core (Cocoa's menu bar) opens the core before it parks it, so a first Load Core of an untrusted core asks; answered, or trusted already, it starts a core that runs without content, as before. Of the running core, the open reads load_no_content from the running state, not the core; runloop_core_probe_live() says so, and that core keeps its flag and starts as before. Qt's Load Core shows no error box, and the Cocoa and Win32 companion windows clear their status line, for a load the check held back: the Security Warning says why, and Qt's modal box would hold the frame loop the warning needs. A parked Load Core run again by Load Once or Always Trust that then fails to open for another reason says "Failed to open libretro core", as the runloop does; one the check refuses again stays quiet. |
||
|
|
6944cbdb6e |
core signatures: a staged load's core is checked in its preload stage
With a trust store the preload stage is the core's check, with or without a worker. A core the quick check doesn't pass is hashed by a task; one the pending seed covers waits for it first. A worker then opens the core from the file that passed, or the core stage opens it from the slot. The core loaded last passes on its own record, as its reload does: no second hash and no second open file. The stage resolves the core path as load_dynamic_core() does, so on Windows it too leaves a \\?\ path ending in '.' as given. A pass whose file changed before the stage hands it over, or before the worker opens it, is checked again instead of ending the stage with neither a library nor a refusal. The first such re-check in a stage is logged. |
||
|
|
076661e80d |
core signatures: check every core where it is opened
runloop_core_dylib_load opens a core only once the load check passes it: a record, an exemption or the slot of a finished check; a refused probe starts the check quietly. The startup load, before the frame loop, hashes in place, an accepted startup wait now listed in CODING-GUIDELINES. Workers open through runloop_core_dylib_open, only where the main thread found no trust store. Until run-ahead checks its copy, it keeps one instance where there is a trust store. On Windows, with a trust store, load_dynamic_core() leaves a \\?\ core path ending in '.' as given, so the check refuses it instead of loading the file _wfullpath names without the dot. |
||
|
|
1656558977 |
video: add Skip Duplicate Frames
A repeat the core sends as a NULL frame is left unpresented, so the display receives the content's own frame rate and frame generation or interpolation tools see the real cadence. It stays out of the way where the presents are the effect (Black Frame Insertion, shader sub-frames, Threaded Video Frame Repeat, a headset) and with the menu open, fast-forward or a cached frame shown again. While repeats are being skipped, the runloop holds the loop to the content's period with its timer wherever only VSync or the threaded hold would have, since neither can block on a frame that is never presented, and the driver's release stands aside. Lanes in samples/runloop/pacing and samples/gfx/threaded_video pin both halves. Idea from beetle-psx-libretro#1013 by Razor221. |
||
|
|
d94f129883 |
android: only load cores from the app's own folders
A launch intent's LIBRETRO, DATADIR and CONFIGFILE extras are chosen by whoever sends it, so another app could have RetroArch dlopen any .so. Every core open now resolves the path and refuses it unless it lies under the app's dataDir or nativeLibraryDir, or in one of the package's own code folders in its install folder, all read from ApplicationInfo rather than from the extras. A Play core install moves the package to a new code folder while RetroArch runs, so a fixed nativeLibraryDir is not enough. |
||
|
|
a580d0f3de |
runloop: never count more play time than has passed
Closes #20019 |
||
|
|
23f465bf2d |
runloop: hold the content rate where Driver Pacing has no backend
With Driver Pacing on and nothing else holding the loop, the backend's release keeps the content's frame period. On a driver without a backend - gl, glcore, or a GPU without the extension - the setting did nothing, and with vsync and audio sync off the loop ran unthrottled. The frame limiter now holds the content's period in exactly the iterations a backend would have owned: a content frame at normal speed, focused, the menu down, and nothing else pacing. Driver Pacing off is unchanged. |
||
|
|
591237dc48 |
Clear what fast-forward queued when it ends
Leaving fast-forward drops what it left in the threaded pipeline's ring behind a jump fade, and the device's writer drops core audio until the device has played down to rate control's setpoint, so a blocking writer is no longer held for as long as the queue takes to play out. That held the core in device-period steps for seconds after every fast-forward, which a VRR display shows as judder until the menu is toggled (#19940), and cost every other configuration a hitch on exit. The five-frame non-blocking window Sync to Exact Content Framerate used for this is removed; it never drained the queue. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LBQPGeAnyXTjoifK18NSfm |
||
|
|
b394e0bdfa |
runloop: a playlist Load State Auto pick loads the auto state
Auto, picked from a playlist entry's Load State list, loads the auto state whatever Auto Load State is set to, through the same path as an automatic load, deferred for a core that must run first. The content_load harness's playlist lane picks Auto with Auto Load State off. |
||
|
|
f896928838 |
video_thread: Display Pacing keeps the vblank under Driver Pacing
With Threaded Video Display Pacing and Driver Pacing both in effect, the hold stood aside for every frame the driver released. The driver's minimum interval keeps the content's rate but not where the frame falls against the display's refresh, so with vsync off nothing placed the present any more: its phase was whatever the last hitch left - at start-up, the content load and a state load - and the tear stayed on screen. Toggling Display Pacing let the hold place frames again for a moment (the menu, the Driver Pacing re-negotiation) and the driver kept that phase, which is why the tearing went away after the toggle. Where the presenter has the display's own vblank (present timing from the display, DWM's vblank on Windows), the hold now still places a released frame on it; the driver's sleep after it, a period from the last release, has nothing left to wait, so the frame still sleeps once. Without a display vblank the hold stands aside as before. samples/gfx/threaded_video: the driver pacing lane gives the presenter a vblank grid and a release that never sleeps, adds a 30 ms hitch, and requires the released frames to keep the content's rate and one phase on the grid, at start-up and after Display Pacing is turned off and on, on the same phase both times. It fails on the old wrapper (30 frames in 6 ms, 5 of 30 on one phase). |
||
|
|
80398df3b1 |
runloop: Driver Pacing alone keeps the content's rate
With Driver Pacing in effect and nothing else holding the loop - vsync and audio sync off, no rate control, Threaded Video Display Pacing off - the minimum interval handed to the driver was 0, and the driver's release, which never sleeps for a rate it was not given, let the core run unthrottled. The interval is now the content's period there too, as it already was under Display Pacing; the timer's period still goes where the timer would hold, and nothing where vsync, audio or a scanline already hold the loop. Fast-forward never reaches the driver's release. The choice moves into runloop.h as runloop_pace_driver_interval(), and samples/runloop/pacing checks it against the whole pace decision (the "driver alone" row fails on the old expression). |
||
|
|
08d96aba04 |
video: Driver Pacing releases the frames Display Pacing would hold
Threaded video's Display Pacing and Driver Pacing each decide when the core's next frame starts, so with both on Driver Pacing stood down - its status read "off: menu, pause, fast-forward or unfocused" - and the presenter's hold, sleeping to its own estimate of core and render time, kept the release. The driver's sleep is now the hold's release: with both on and Driver Pacing in effect, the runloop sleeps on the driver as it does without Display Pacing, and the hold in the wrapper's frame handover stands aside for a frame the driver released (one whose frame info carries a release identity) instead of sleeping a second time. The cadence the hold kept - the content's period, which on a display faster than the content is not the display's - goes to the driver as the minimum interval it is to keep. A release the driver could not give leaves the frame to the hold as before, and where Driver Pacing stands aside (the menu, pause, fast-forward) the hold holds. Scanline Sync still keeps Driver Pacing out. Off by default with Driver Pacing; with Display Pacing alone nothing changes. The two settings' descriptions say how they combine. The pacing table's display-pacing row now has the driver beside the hold, and a new row keeps the menu to the hold alone. The threaded harness lane checks, under Display Pacing, that every frame is released by the driver, that the hold stood aside for them, that the content's period reached the driver with the frame, that a failed release leaves the hold to hold, and that turning Display Pacing off leaves the driver alone with its own interval. |
||
|
|
23aed644e1 |
video: Driver Pacing under threaded video, and through BFI, sub-frames and swap intervals
The presenter now owns the backend's frame side and the frame loop only waits: each content frame carries its identity and the minimum present interval in video_frame_info_t, the presenter marks, presents and issues the one sleep after the frame's own present, and the frame loop waits on the timeline semaphore for the identity it last handed over before it samples the next frame's input. That is the same shape on the direct path and under the threaded wrapper, which forwards the three pokes to the driver unchanged, so Driver Pacing is no longer turned off by Threaded Video; only Threaded Video Display Pacing, the presenter's own hold, keeps the release to itself. Any present after a frame's own - a repeat, a dark frame, a shader sub-frame, a swap interval the driver emulates by presenting again - is marked out of band on the same identity, which is what the extension's attribution rules provide for, so Black Frame Insertion, Shader Sub-frames and swap intervals above one no longer keep the mode off; Scanline Sync, which paces the present itself, still does. The Direct3D backends mark their presents the same way through a helper around every Present, and take the interval from the frame on the presenter's thread. What crosses between the two threads in the Vulkan backend is lock-free: the mode request and the presenter's answer are atomics (a request the presenter has not seen reads as pending, never as in effect); the swapchain the frame loop's input and simulation markers may name is published under a generation, rewritten only while that thread is seen outside a marker call, and a replaced swapchain is kept until it is, so a marker never names a destroyed one. A wait the driver does not satisfy four times running takes the mode off and reports failure; asking again tries anew. The fake-backend sample covers the sleep-after-present cadence, the out-of-band markers, the cross-thread request and the kept swapchain; the harness lane adds the threaded path through the wrapper on the null driver and on Vulkan, and the pacing table pins the wrapper row. |
||
|
|
d08a156604 |
video: Driver Pacing, the graphics driver's release of each frame, on Vulkan
A new Driver Pacing setting (video_driver_pacing: Off, On, On + Boost; Off by default, so nothing changes until it is asked for) lets the graphics driver say when each core frame should start, through NVIDIA Reflex's VK_NV_low_latency2 on the Vulkan driver. The runloop holds on the driver's own timeline semaphore where Frame Delay used to sleep, before the frame's input is sampled, and reports the input, simulation, render and present markers on the frame's identity so the driver can place the release. Where the gap limiter or the content-rate timer would hold, its period goes to the driver as the minimum present interval rather than being slept a second time; vsync and audio keep holding where they do, since the release schedules the start of a frame and not its presentation. The mode is a property of one swapchain: a replaced one starts over, and nothing names one the mode was not set on. A backend error, or a sleep the driver never signals within the bound the runloop allows, falls back to the existing pacing for good. The release is owned only for a content frame the core made, on the unthreaded path, at normal speed, focused, with the menu down; pause, the menu and fast-forward keep their pacing, and Black Frame Insertion, Shader Sub-frames, Scanline Sync and a swap interval above one keep the mode off until their present schedule is mapped onto the extension's one sleep between presents. The driver pokes (driver_pacing_set, _wait, _mark) are vendor-neutral so other backends can sit behind them; the requested mode and the reason it is or is not in effect show on the statistics overlay and in System Information. The runloop's decision is pinned in samples/runloop/pacing, the Vulkan backend's state machine runs on fake entry points in samples/gfx/vulkan_driver_pacing (a new CI job), and the runloop's side runs against a fake backend as a lane of the threaded-video harness, on the null driver and on Vulkan. |
||
|
|
be9f97d2cf |
MCP: review fixes, checkpoints, queued STEPS (#19861)
* MCP: cold paused, held input, stacks, arg types * MCP: checkpoints, prompt, completions, records * MCP: completion errors, sized prompt, CI shaders * MCP: rollback via loader, STOP n, completion fixes * MCP: ask input_driver whether a replay records * mcp: Clarify steps, and ensure MCP standards * MCP: queued STEPS, checkpoint step, 32 steps * MCP: queued STEPS say how long they sat idle * MCP: queue ends on load/reset; simplify * MCP docs: queue stops, idle, list caching * MCP: shorter STEPS wording * MCP: notice when port taken, --command, taps * MCP: drop the play_game prompt and completions * MCP: queue, tap and reset fixes from a review * MCP: queue outcomes, hex values, field fixes * command: --command takes an empty host or port as the default "CMD;;PORT" and "CMD;HOST;" fill in the default host or port, so an empty segment after a ";" counts as a host or port field again. A STEPS list still keeps its own ";" steps, which carry a space, a "|" or are "checkpoint". --------- Co-authored-by: LibretroAdmin <[email protected]> |
||
|
|
631c443892 |
core options, runahead: one allocation for value hashes, flat input list
Option value hashes live in one pool per manager, indexed by value, and every value and label append is checked, so a failed append ends the parse without writing outside a list. The legacy parser reads the description and values in place from the variable string. Runahead's input logging keeps the tuples the dense cache has no slot for in one flat array; each tuple's ids are sized on first write. samples/core_options drives the manager with each append failing in turn; samples/runahead covers the input list, including each realloc failing in turn. |
||
|
|
0a4aff89ef |
command: RUN_FRAMES
RUN_FRAMES pauses the content and runs it a given number of frames through frame advance, answering once the last has run, so a client can step the game and look between steps. While it runs a frame-work bit makes each iteration a frame advance; after each core_run the command counts the frame off, and closing the content answers it with an error. With the bit clear the run loop does nothing new. |
||
|
|
5103a232df |
OpenXR: one core for the desktop and Quest headsets, with head tracking, controllers, settings and desktop OpenGL (#19811)
* menu: the cursor stays on Headset Output when Stereo Mode comes and goes Stereo 3D & Screens lists Stereo Mode above Headset Output only while the headset is off. Turning it on moved Headset Output up a row and left the cursor on the row below it, Headset Refresh Rate, so a second OK meant to turn the headset off opened the rate list instead. The cursor follows the row, as it does for Mapped Port when Device Type comes and goes. samples/menu/stereo_headset checks it for OK, right and Start. Co-authored-by: Craig <[email protected]> * openxr: a session without focus is not logged as controllers not read xrSyncActions answers XR_SESSION_NOT_FOCUSED, a success code, while the runtime's dashboard or another application has focus. It was logged as a warning each time focus went; only a failure is now. The test layer answers a sync with a scripted result (sync <n>), and the headset suite gains input-sync-unfocused. Co-authored-by: Craig <[email protected]> * libretro: a TRACKED view map, and HMD is how a core finds a headset A map's shape could not tell a head-tracked eye pair from a stereoscopic screen sent alone. The new flag says which. HMD now means tracking works, and a core learns of a headset from it only. REQUEST_FLAT is a map without the flag, and OpenXR always gives real eye poses, so the flag and the IPD hint go; nothing read either. Co-authored-by: Craig <[email protected]> * openxr: the runtime, session, swapchains and frame loop are shared units The desktop Vulkan host's instance and headset, its session state machine, its swapchain slots and its frame loop with pacing move into gfx/common/openxr_*, which name no graphics API, so every headset host can use them. vulkan_openxr keeps only what is Vulkan's. Co-authored-by: Craig <[email protected]> * video: the headset's host says how it is, and answers the pose calls One host interface reports the headset's state on the desktop and the Quest alike. HMD comes with PRESENTS and STEREO, and only while the session runs. The pose calls go to the host, and a view map sent again unchanged is not applied again. Co-authored-by: Craig <[email protected]> * openxr: a TRACKED map's eyes are the desktop headset's projection Tracked content gets a space of its own, LOCAL or STAGE as the core asks, and the poses sampled in it. The eyes the core draws are submitted as a projection layer with the poses it was given, and the screens a headset leaves to that projection are hidden. A recenter moves a seated world with the screens; a standing one stays where the room puts it, and the core is told RECENTERED. A paused core's tracked world comes back after a driver reinit. The views test core can draw a world-locked grid, for checks made in a headset. Co-authored-by: Craig <[email protected]> * vulkan: the Quest's headset runs on the shared OpenXR core The runtime starts Android's loader and tells the instance of it. A headset frame can be begun and ended inside the video frame, so vulkan_openxr runs in-line for a headset's own context, which says so in its flags. The units that name no graphics API build without Vulkan, and a GLES binding is ready for the GL host. A space a core asks for again is kept, so a cached context keeps its paused world. Co-authored-by: Craig <[email protected]> * gl: the Quest's headset runs on the shared OpenXR core The Quest's ES3 context is its own in-line host: gl2 draws into a window the context owns, shown as a screen in the room, and copies a tracked map's eyes into the headset's projection. The window shows until the first projection. The kept view pair lives in openxr_host, so the GL host keeps a paused world across a reinit as Vulkan does. The quest flavour builds with GLES=3. A stand-in runtime test runs the in-line host. Co-authored-by: Craig <[email protected]> * input: one headset controller module for the desktop and the Quest The headset input's hooks belong to the frame, so any host attaches the module, and the Quest's own controller module goes. Touch's menu button is Start from its press, and opens the RetroArch menu when let go after a second. The menu's laser can point at a window shown whole, mapped through the area the core is drawn in. The stand-in test runs the shared module. Co-authored-by: Craig <[email protected]> * video: headset settings for every headset driver, and Screen Placement The headset's rows show for every driver with a headset path. Recenter works in the menu and reaches the Quest's GL host, and a seated recenter moves a paused world with the screens in the same headset frame. Screens are placed from an anchor of their own: Fixed in Room, Follow Head or Lazy Follow. The Quest asks for a refresh rate that fits the content and repeats each core frame for whole headset frames. Co-authored-by: Craig <[email protected]> * input: the headset's controllers are a controller They take joypad slots with built-in profiles, so hotkeys, port binds, remaps and rumble use the normal input path on the desktop and the Quest. They take the next free slot like any pad, and keep their port when a gamepad is plugged in, without saving that exchange. A saved "Meta Quest Touch Plus Controller" profile and its remaps no longer apply. Co-authored-by: Craig <[email protected]> * gl: headset output for the desktop OpenGL drivers glcore and gl show a headset on Linux. The XR thread holds a context in the window's share group, made by the X11, X11 EGL and Wayland context drivers, and the session binds it through XR_KHR_opengl_enable or XR_MNDX_egl_enable. The video thread draws each image into shared textures and hands it over with a fence through a triple buffer; the XR thread copies the newest into the swapchain and shows it with the quads or the eye poses it was drawn with. glcore draws the screens and the menu through chains of its own and a tracked map's eyes as the projection, as Vulkan does. gl shows its window, whole or cut into an untracked map's screens, as the Quest does, and tracked eyes as the projection. Both follow the headset's pacing: the XR thread wakes the core for its next frame after taking the last, so none is shown a headset frame early. OpenXR configures with OpenGL alone, without Vulkan. The test layer captures OpenGL swapchain images, and the headset end-to-end runner has lanes for both drivers on GLX and EGL. Co-authored-by: Craig <[email protected]> * docs: OpenXR headset output, and how a headset or graphics API is added What the headset path does and how to build and turn it on, what a core sees, which units are shared and what each of the three hosts adds, and the steps for another headset, graphics API or platform. Co-authored-by: Craig <[email protected]> * audio: pass the reinit flag to MMDevice watchers XAudio2 and DirectSound must give mmdevice_thread the frontend atomic flag. Passing the driver object overwrites its watcher handle when an endpoint changes. Exercise both thread backends against the extracted production spawn functions. * test: reject video backend fallback in the threaded harness Fail early when HARNESS_VIDEO_DRIVER differs from the initialized backend so a missing driver cannot qualify another backend's lanes. * Animated previews: keep high-bitrate audio fed across loops Size the audio lookahead from the preview bitrate, prime it before playback, and refill the full window on rewind. The audio demuxer walks interleaved video packets too; a fixed 2 MiB window stalled on large H.264 packets and left high-bitrate previews silent or delayed after looping. Add a real feeder/mixer regression using generated oversized video packets. Verify that audio continues through three complete loops; the previous feeder fails this test. Validate both reported 4K clips locally on Windows and Linux. * wdmks: bound threaded writes by the device fragment A small write can exhaust its request-sized wait budget before a healthy WaveRT pin's next notification. Size the threaded ring waits from rt_ahead instead, and cover writable waits and blocking writes against a 64 ms fragment. * CI: views end to end on glcore and Vulkan under Xvfb run.py gains RA_E2E_XVFB (Xvfb in place of gamescope, llvmpipe and lavapipe) and RA_E2E_ONLY (a case filter). The validation job runs a subset of the cases. * Views: one compositor for gl3 and Vulkan gfx/video_views_draw.h holds the chain pick, the placement loop with the interlaced row shift, and the canvas and UI target lifetime. Each driver includes it with its own calls bound in by macros, so nothing goes through a function pointer. The UI layer's predicate, per-eye test and dims swap move to video_views.h. Output is unchanged. * Threaded video harness: the frame on screen is the core's newest A frame lag lane checks, end to end, that what the driver draws is the frame the core pushed last: the harness core stamps each frame with its number in eight full-height bands that survive scaling and filtering, and the lane reads back the driver's own upload (the cached frame dropped first) and decodes it. Copied, lent and lent as a cropped window, with threaded video off and on: with nothing in flight it must be the newest pushed frame, and with frames still in the wrapper's ring at most one behind. A zero-copy path that draws a buffer the core has since rewritten, or skips an upload, or a wrapper that holds frames back, fails it. It runs on vulkan, gl and glcore, desktop and GLES 3, in the existing harness jobs (release, ASan+UBSan, TSan, the validation layer). * Fix MSVC preprocessing of video views UI checks Move widget conditionals outside VIDEO_VIEWS_UI_WANTED calls in the GL3 and Vulkan drivers. The traditional MSVC preprocessor treats directives inside macro arguments as tokens, breaking the Windows build. * Provide audio state in the DirectSound pump harness The device notification thread now uses the audio state reinit request. Supply a persistent harness-owned state through audio_state_get_ptr so the standalone MinGW test links. * Preserve RetroArch when building the threaded video harness Request the link command with make -W instead of deleting the frontend executables. The later video views end-to-end tests need the existing RetroArch binary to launch. * ATRAC3plus: accept implicit master code-table indices Master channel code-table mode 3 has no payload and uses zero indices. Return before consuming the optional value count bit, rather than rejecting valid frames and losing bit alignment. Add a synthetic regression covering float, s16 and reset decoding. * Expose hardware H.264 decoding with CPU planes to cores Provide an experimental versioned frontend decoder interface with Vulkan and D3D11 I420 readback. Reserve private video queues through Vulkan device negotiation v2, and retain the decoder backend with cached devices across video driver reinitialization. Keep software fallback for unavailable or disabled hardware decoding and cover readback in decoder and GPU tests. * ATRAC3plus: distinguish coded and declared subband flags Use coded subbands for stereo swap and negation flags and declared subbands for window shapes. Add a synthetic audible stereo regression to detect parser misalignment when fewer subbands carry spectra. * D3D11: views The driver draws a core's views through video_views_draw.h, straight from the frame as the stock chain draws it: placed in each eye's area, blended through a canvas for anaglyph and interlaced, with the UI drawn once into a layer composited into each eye. With a preset or HDR output the frame is drawn whole. Windows-wine-views.yml runs the views end to end on it: run.py gains RA_E2E_WINE, for retroarch.exe under Wine with vkd3d's shader compiler, and the test core builds as a DLL. * D3D12: stock pipes made for the swap chain's format The pipes were made before the swap chain, whose formats were still unset, so every stock draw had an UNKNOWN target format: Windows drivers draw it anyway, vkd3d (Wine) draws nothing. They are made after it now. * D3D12: views The driver draws a core's views through video_views_draw.h as the D3D11 driver does: straight from the frame, through a canvas for anaglyph and interlaced, with the UI drawn once into a layer composited into each eye. Its SDR pipes keep coverage in alpha, which the layer is composited by. With a preset or HDR output the frame is drawn whole. Windows-wine-views.yml runs the views end to end on it as well, on Wine's vkd3d over lavapipe. * openxr: apply unified headset support to current master Apply PR #19811 at |
||
|
|
64fcce996d |
Defer auto state load for cores requiring initialization (#19487)
* Defer auto state load for cores requiring initialization * runloop: wait for deferred auto-state initialization Keep the request pending until the primary core has run and reports a nonzero serialization size. Preserve one-shot loading without repeated state reads, reset execution tracking on lifecycle changes, and skip settings queries when no load is pending. * tests: cover deferred auto-state readiness and cancellation Drive the shipping runloop and command handler with a core that initializes over multiple frames. Check one-shot loading, idle overhead, cancellation, core reset, missing retro_run, paused frames, hardcore mode, and the unchanged non-quirk path. Add Linux sanitizer coverage and a Windows cross-build. * runloop: avoid auto-state conflicts with master Move deferred auto-state fields away from the lifecycle fields extended by master, and reset them after joining autosave workers. Keep the reset before core unloading so both the auto-state and audio teardown changes merge cleanly. Supply the new audio publication and between-frame polling dependencies in the regression harness. --------- Co-authored-by: keycross <[email protected]> Co-authored-by: Codex <[email protected]> |
||
|
|
ce5c333180 |
MCP: Options instead of toggles, correct error handling (#19731)
* tests: cover MCP option state and speed changes Exercise the shipping option handlers and runloop setters with counted driver events. Cover recorder conflicts, hardcore activity, rejected speed changes and repeated requests without extra work. Run the harness under Linux sanitizers and on Windows in the network CI workflow. * mcp: SET_OPTION/GET_OPTION, real errors * mcp: apply option changes to runtime state Reject recording and streaming conflicts before initializing a recorder. Read hardcore activity rather than its configured preference. Apply speed targets synchronously through runloop setters, sharing the fast-forward side effects with hotkey handling and respecting runtime restrictions. --------- Co-authored-by: Codex <[email protected]> |
||
|
|
b921899df3 |
quit: a quit from the frame loop waits for its save without freezing
retroarch_main_quit() pushed the auto save-state and then waited for it inside the call, so the window sat on one frame for as long as a large state took to compress and write. It now has two halves around that wait. CMD_EVENT_QUIT - the menu, the quit hotkey, the window's close button - runs the first and, while a state task is still in flight, returns to the frame loop: runloop_iterate() presents the last frame and the "Saving state" notice, runs neither the core nor the menu, and finishes the quit once the task is through. Where the loop cannot carry the wait it blocks as before: with no window to present into, on the Switch and 3DS whose frame pumps the system's own messages, and in the quits the operating system forces, which call retroarch_main_quit() directly. Both forms wait for a load state task as well as a save: a save over an existing file first loads it into the undo buffer, and the save is only pushed from that load's callback, so a quit asking for the save alone could finish before the save had started and exit without it. content_load_test gains a lane that quits while a save over an existing state is in flight: the command returns with the task still running and shutdown not begun, frames are presented and retro_run is not entered while it writes, and the loop ends only once it is through. It runs last, as the session ends with it. |
||
|
|
b655a205b1 |
runloop: fast-forward's frameskip decides before the core runs, and a core that asks need not render a dropped frame
The frameskip picks the frames it presents at the top of the iteration instead of in video_driver_frame, with the same accumulator, target and forced render after a dupe; video_driver_frame consumes the decision, or makes it itself for a frame no decision waits for. GET_AUDIO_VIDEO_ENABLE then leaves video out for a frame that will be dropped, so a core that honours it skips the render instead of spending the GPU on a frame nobody sees. Under threaded video a hardware core rendering at a high internal resolution could queue so far ahead of the presenter that presents stalled for seconds in fast-forward. When a render turn lands on a dupe, the core is asked for video until a real frame arrives, as the forced render presented it before. samples/runloop/pacing pins the accumulator step and the owed-frame rule. |
||
|
|
b9544ea208 |
OpenXR headset output for Vulkan on desktop Linux, (stacked on #19728) (#19729)
* gfx/video_views: check, lay out and map touch for a core's views The rules behind a view map live in one module with no driver or settings state: which maps are valid, how a frame is fitted to them, where each view goes in every stereo mode and screen layout, which part of a placement is drawn, and how a window point maps back into the core's packed frame or into the coordinates a per-eye UI is laid out in. Drivers and input share them, and a harness tests them without a GPU, under the sanitizers in CI. * menu: Stereo 3D & Screens settings Stereo Mode (2D, side by side half and full, top-bottom, anaglyph, interlaced), Swap Eyes and Screen Layout, under Settings > Video. They apply only to cores that send a view map. * video: accept a core's view map and hand drivers a layout The map is checked when the core sends it. Each frame the main thread lays it out for the current settings and passes the layout to the driver in video_frame_info_t, so drivers never read settings, threaded or not. A driver that can present views says so with GFX_CTX_FLAGS_VIDEO_VIEWS; otherwise, or when a frame doesn't fit the map, the packed frame is shown as before. A driver that draws a frame with a map whole anyway reports it, and the menu, overlays and touch follow the packed frame from the next frame. Under threaded video, a cached frame larger than the core's declared maximum, redrawn for a screenshot or a Win32 window drag, is now cropped as it was shown, so it makes the same views decision at the same viewport. The drag's redraw runs on the video thread beside the main one, so it lays out what was last presented and writes none of the views state. A hardware frame is no longer cropped: nothing is copied out of the core's image, and a cropped size dropped its views. View chains are built only through a new set_view_count poke, called when the accepted map or the driver's answer changes. Under threaded video the main thread waits while the video thread runs it, so preset parsing, which reads settings and replaces the file-watch list, never runs beside the main thread. A single frame that doesn't fit keeps the chains. Touch maps back through the layout into the core's packed frame, and a CPU filter's output scales the map without changing each view's shape. In side by side and top-bottom the menu and widgets are laid out at one eye's size. The menu maps its mouse and touch position through the layout, so either eye's copy is hit where it is drawn, and RGUI converts against the viewport its texture is fitted to rather than the whole window the driver reports while views are presented; the on-screen keyboard is hit-tested at the UI's size. A paused core asks for the views status only when it runs, so while the menu is open a change of the status (Stereo Mode, a headset) asks the core to update which of its options show, as an option change does. * input: overlays follow views Side by side and top-bottom hide the overlay, so its hit test is skipped there, while touches still reach the core, including through pointer passthrough. Elsewhere a non-fullscreen overlay is drawn over the whole window while views are presented, so it is hit-tested in window coordinates. * vulkan: draw a core's views Each view is copied out of the frame, shaded by its own chain with its own OriginalAspect, and drawn in its placement. A view's chain starts its passes and history small and follows the view's size, not the frame's declared maximum, which for a core like Azahar is 8192x8192 per buffer. A view shown in both eyes draws its final pass again with the first draw's source, so its feedback swaps once. Anaglyph and interlaced draw both eyes into an offscreen canvas and blend its halves into the window. A placement larger than its eye's area, as a custom viewport can make it, is cut there by a scissor on the chain's final pass. In side by side and top-bottom the UI is drawn once into a layer at one eye's size and blended into both halves, at screen depth, and only while there is UI to draw. The layer is FP16, drawn with the SDR pipelines HDR output already builds; with HDR off their alpha accumulates as coverage, so the layer composites as the UI drawn directly would. Views are off with HDR output or an HDR10 source. The driver publishes that answer for the main thread rather than reading its context flags, which the video thread rewrites each frame. A view that can't be copied or given a target falls back to the packed frame, and reports it. * glcore: draw a core's views Each view is blitted out of the frame's texture, keeping its orientation and swizzle, shaded by its own chain and drawn in its placement, following the same rules as Vulkan. Anaglyph and interlaced blend the halves of a canvas twice the window's width. GL counts rows from the bottom, so for interlaced with an even height the eyes take the other halves, keeping the left eye on the window's even rows. The blend programs are compiled on first use; without them the left eye is drawn alone. The UI is drawn per eye as in Vulkan, RGUI keeping its aspect inside each eye. Views need the slang chain, and are off with HDR output or an HDR10 source; get_flags reads published state only. * samples: a test core and end-to-end check for video views The core draws solid-colour views in the 3DS, DS and Virtual Boy shapes, in software, through a GL core context with either origin, or into Vulkan images of its own handed over with set_image, plus a frame larger than its declared maximum, which threaded video crops unless it is a hardware frame. It logs the views status, also when asked to update its options' display, and the touches it receives. run.py drives it in headless gamescope on vulkan and glcore through every stereo mode and screen layout, and checks screenshot colours and the logged status. One case runs a history preset over a core that declares a large maximum and checks the GPU memory it holds. One case runs on gl, which doesn't present views. The pointer cases move the pointer of gamescope's own X server from a helper inside the session and check that the menu's cursor, ozone's and RGUI's, is drawn under it in each eye's copy. It refuses to run on the desktop display. * vulkan, input: headset output through OpenXR PC headsets through the OpenXR runtime: a session on the Vulkan instance and device the runtime asks for, per-eye quad layers composed from the core's view map, flat-screen stereo modes, laser and menu pointer input, and the Monado end-to-end test infrastructure. The runtime is reached through the loader built into the tree, not a libopenxr_loader.so.1 opened at run time, so the same path works wherever the loader does, and the OpenXR headers come from the vendored SDK. The Vulkan instance and device wrappers route either owner of the context, this session or the Android projection context, with no cost where neither is built. OpenXR is on by default on Linux with Vulkan and threads, and its C is in the C89 lane like the rest of the tree. * vulkan: one swapchain per eye for the headset's stereo screens SteamVR on the Steam Frame ignores a quad layer's imageArrayIndex and shows array layer 0, so a stereo screen showed the left eye's image in both eyes and Swap Eyes changed nothing. Each layer of a slot now has a swapchain of its own, and each eye's quad shows layer 0 of its own. A slot's swapchains are acquired and released together, and its quads show once every one of them has released an image. The test layer can show layer 0 of every quad as the Frame does, and the e2e suite runs the stereo and Swap Eyes cases that way too. Revert this once SteamVR honours imageArrayIndex (ValveSoftware/SteamVR-for-Linux#975), to go back to one array swapchain per stereo screen. * openxr: the desktop headset path is built and checked in CI A job builds RetroArch on Linux with OpenXR on - the loader is in the tree, so nothing is installed for it - and runs the Stereo 3D & Screens menu harness, the API layer the Monado end-to-end check records through, and the video_views core, all with the vendored headers. The test layer no longer looks for installed OpenXR headers. * vulkan: the PC headset session is not opened beside the Android projection context * qb: OpenXR stays out of the C89 lane like the Vulkan it needs The vendored Khronos headers are not C89; the tree's own OpenXR C is. * video thread: the poke table keeps its place for the present wait * vulkan: the headset session's handoffs are lock-free What the XR thread tracks for the video thread (the predicted time, the anchor, pixels per radian) and the quads the video thread publishes for the XR thread and the pointer are each a seqlock over their words, the way video_driver.c publishes its viewport parameters, and the frame tick the video thread paces on is an eventcount. Nothing waits on a lock on either side; slot creation and destruction already happen under the queue lock. --------- Co-authored-by: libretroadmin <[email protected]> |
||
|
|
ebfc5c7652 |
VR support - Quest to begin with (#19726)
* deps: add openxr-sdk * openxr: initial implementation * openxr: build the vendored loader from the tree, drop the CMake step The OpenXR loader is compiled like every other vendored dependency instead of through a cmake invocation run from a $(shell) at Android.mk parse time against one hardcoded NDK path: griffin_cpp pulls in the loader, jsoncpp and (on Android) the jnipp/android-jni-wrappers broker sources, griffin.c picks up the generated C dispatch table, and the loader links statically into retroarch-activity, so the prebuilt libopenxr_loader.so module and its packaging disappear. The loader is C++17, so the quest build appends -std=gnu++17 after the global gnu++11. Makefile.common gains an equivalent HAVE_OPENXR block (platform-neutral sources only) and qb grows a disabled-by-default HAVE_OPENXR switch, so a future desktop OpenXR backend builds the same loader through configure rather than growing a second build path. * openxr: move the vendored loader onto libretro-common threading The loader's C++11 threading (std::mutex, std::shared_timed_mutex, and jnipp's std::atomic_bool) is replaced with rthreads slocks and retro_atomic. Cold paths - the global loader lock, the property overrides, the debug-messenger map - keep plain mutual exclusion as lazily-created slocks published with a CAS. The two read-mostly structures become lock-free: the runtime dispatch table is a single acquire/release-published slot, since the loader only ever has one live runtime instance, and the logger's recorder list is an immutable snapshot that the LogMessage paths walk wait-free while writers rebuild and republish it under a cold slock, retiring superseded snapshots and removed recorders until teardown so a reader never touches freed memory. One behavioural delta, noted in loader_logger.hpp: a removal no longer waits for in-flight readers, so a log call racing it can reach the removed recorder once more before it drops out of view. The per-frame xr* dispatch (the generated trampolines through the cached dispatch table) was already lock-free and is unchanged; this puts the whole tree on one threading layer and drops the libstdc++ thread machinery from the loader. Verified with per-TU and griffin-shape amalgamated C++17 builds of every touched TU, plus a TSan and ASan/UBSan/LeakSan harness driving concurrent LogMessage readers against recorder add/remove churn and concurrent first-use slock creation. * openxr: route Vulkan instance/device creation by context, not build On a HAVE_OPENXR build every VkInstance and VkDevice went through xrCreateVulkanInstanceKHR/xrCreateVulkanDeviceKHR unconditionally, so the flat vk_android fallback the driver takes when a session is unavailable could never create a working context, and the queue-family probe still queried surface support with a null surface after computing the headless answer. Creation now routes through OpenXR only when the live context is android_vk_openxr - everything else keeps vkCreateInstance/vkCreateDevice - and vulkan_common reaches the XR instance and system id through accessors on the context driver instead of another TU's static, which only linked because of griffin include order. The headless surface check is a single call that never passes VK_NULL_HANDLE. In vulkan.c the swap-interval emulation and BFI frame-duping recursion are skipped under an XR session: the compositor owns pacing, and re-entering vulkan_frame would issue a second xrBeginFrame before xrEndFrame (the context's begin_frame also guards against re-entry now). The HW fence wait keeps one shared condition with XR added inside a single #ifdef so the non-XR build preprocesses exactly as before, the dangling HAVE_OPENXR_2D probe is gone, and the eye loop and vulkan_frame_eye declarations are C89. * openxr: fix quest input regressions, make shared state cross-thread safe android_joypad_state's axis-to-button path required port 0 under HAVE_OPENXR, so physical pads on ports 1+ lost all analog input on the quest build; it now goes through android_joypad_axis, which merges the XR sticks for port 0 and falls through to the plain Android state for every other port. Window motion events are only suppressed while an OpenXR session is actually live instead of being compiled out (the unreachable duplicate source check is gone), the never-defined HAVE_XR gates are removed so the file matches the behaviour the quest build has actually been tested with, and the INIT_WINDOW reinit check is braced with its declaration at block top for the C89 lanes. The shared OpenXR input state (buttons, axes, attach flag, menu long press) is written by openxr_input_sync on the frame loop's thread - the video thread under threaded video - and read by the input drivers on the main thread, so it moves onto retro_atomic with a swap-consumed long-press flag. The shared readers also lose their android_vk_ prefix (they serve the GL path too) and live in openxr_input.h; the long-press hotkey check in input_driver.c gains the ANDROID guard its definition has always had. * openxr: report VR availability honestly, decouple GL path from Vulkan gl2's set_vr_content_info returned true unconditionally, so a core asking for VR on the flat fallback context was told a session existed and got a 0x0 recommended eye size; it now reports unavailable unless the OpenXR context owns a live session, video_driver refuses and unwinds a request when no eye target size is available, and the Vulkan driver treats a NULL info as the documented disable instead of a probe, clearing its stereo state. The unused RUNLOOP_FLAG_CORE_VR_CONTENT is dropped: it sat on the deliberately retired bit 31 (1 << 31 in a signed enum besides), and the bool the code actually uses stays, with its comment naming the real environment calls. griffin no longer nests the GL OpenXR context, the shared OpenXR input TU and the loader dispatch table under HAVE_VULKAN, so a GLES-only HAVE_OPENXR build links instead of failing on prototypes. The GL context's end_frame declarations move to block top for the C89 lanes, the stray C++ comment is gone, and the magenta debug clear on the eye buffer is black. * android: keep quest manifest entries out of the shared manifest The Oculus app id meta-data and the installLocation flip to auto landed in the manifest every Android build ships. The app id moves to the quest flavor's overlay manifest where it belongs, and installLocation returns to internalOnly, which is set deliberately: external-storage installs have broken content paths and services before. If the quest build needs auto, it can set it in its own overlay. * deps/openxr: trim the vendored SDK to what the tree builds The full SDK checkout came with its own CI configs, CMake build system, gradle/prefab/vcxproj packaging, jsoncpp's test suites, examples, docs and devtools, jnipp's project files, and the unused non-core dispatch table. All of it goes: what stays is the OpenXR headers, the loader and common sources the tree compiles, the lib_json sources and headers, jnipp and the android-jni-wrappers, the generated core dispatch table, and every license file (LICENSE, COPYING.adoc, the LICENSES directory and REUSE sidecars of kept files, jsoncpp's and jnipp's licenses). README.md stays as provenance for the vendored version. * ci/android: carry the quest flavor's debug apk as an artifact assembleDebug already builds every flavor, so the quest build compiles on each CI run now that the loader builds through ndk-build with no host cmake step; uploading its apk makes a quest regression visible in the artifact list and gives testers a build to sideload. openxr_input also includes verbosity.h itself instead of leaning on griffin include order for RARCH_ERR. * openxr: parse manifests with libretro-common rjson, drop jsoncpp The loader's JSON use is three manifest/broker walks over a small value tree, so a ~250-line Json::Value subset backed by rjson (loader_json) replaces the vendored jsoncpp - a megabyte of C++ the binary already duplicated, since rjson is compiled into every RetroArch build. The shim keeps jsoncpp's names and the exact semantics the loader relies on: missing members read as a shared null, mutable indexing creates members, extension_version accepts both its string and integer spellings, and the parser takes comments, trailing data and a UTF-8 BOM like the CharReaderBuilder defaults did, so nothing previously loadable becomes unloadable. Verified against the old implementation as an oracle: a harness driving RuntimeManifestFile and ApiLayerManifestFile over valid, relative-path, malformed, wrong-version, field-missing, trailing-data and commented manifests produces byte-identical results on both, runs clean under ASan/UBSan/LeakSan, and the quest, GLES-only and OpenXR-off NDK builds all still link. * android: declare the OpenXR runtime brokers and their permissions The vendored loader discovers the active runtime by querying the ContentProviders at org.khronos.openxr.runtime_broker and org.khronos.openxr.system_runtime_broker (android_utilities.cpp). The quest flavor targets API 34, where package-visibility filtering hides any provider authority the app does not declare, and the manifest carried no queries element at all, so broker resolution was working only at the OS vendor's grace. Declare the two authorities the loader actually queries, together with the Khronos broker permissions - both normal protection level, granted silently at install with no user prompt - so the generic installable broker also serves the app, not just Meta's unenforcing one. Everything lives in the quest overlay, where the loader ships: the headtracking uses-feature in particular must never migrate to the shared manifest, since required=true there would delist the app for every non-VR device on the Play store; a comment now says so. * jni: cleanroom rjni layer in libretro-common, used tree-wide All JNI plumbing moves behind one cleanroom libretro-common layer: rjni registers the process JavaVM once (CAS, first wins), caches each thread's JNIEnv in destructor-capable TLS - GetEnv tells threads the VM already owns, which are left alone, from threads rjni attaches, which are detached again when they exit - and provides lock-free once-caches for class global references, method IDs and field IDs, the VM crossings that make JNI call sites expensive. The exception guard switches to ExceptionCheck, which creates no local reference. The call wrapper macros move here verbatim from platform_unix.h, so every JNI user in the tree shares one header. platform_unix keeps jni_thread_getenv as the entry-point name but it is rjni_env now, with the local key machinery deleted, and the KeyCharacterMap path resolves through process-lifetime rjni caches, so a driver restart re-resolves nothing. Verified with a fake-VM harness under TSan and ASan/UBSan/LeakSan (8 threads, attach/detach balance asserted), a real OpenJDK 21 VM exercising the caches from four native threads, the C89 lane, NDK arm64 at -Werror, and MinGW. * openxr: drop jnipp and android-jni-wrappers, query the broker through rjni The loader's two remaining vendored C++ dependencies existed only to make JNI calls, which the tree now does through libretro-common's rjni, so android_utilities is rewritten on raw JNI with an rjni once-cache for every broker class, method and field - same URIs, same log lines, same installable-then-system fallback - and loader_init_data reads the asset manager and nativeLibraryDir the same way (a dead getApplicationContext call did not survive the rewrite). With jnipp gone this also deletes the only exception-throwing code in the loader, so the Android path is safe under -fno-exceptions unconditionally, and the last C++11 threading construct, jnipp's thread_local, leaves the tree with it. jnipp and android-jni-wrappers are removed from deps, griffin and the Android include paths. Both rewritten files pass standalone NDK arm64 syntax checks, the quest ndk-build links, the GLES-only and plain shapes still build, and the Windows-shape loader amalgam still compiles under MinGW. * openxr: filesystem code on libretro-common file_path/retro_dirent filesystem_utils keeps its interface but its three implementation branches - C++17 <filesystem>, experimental, and the per-platform fallbacks - are replaced by one body over libretro-common's file_path, path_stat and retro_dirent, matching the std::filesystem semantics this build shipped (parent/trailing-slash decomposition, absolute-child replacement in CombinePaths, the Windows canonical no-op). stdfs_conditions.h goes with the branches. Three behavioural deltas, each for the better: FindFilesInPath and GetCanonicalPath return false on a missing path where directory_iterator and std::filesystem::canonical threw (the loader builds -fno-exceptions elsewhere), and ParsePathList no longer corrupts the middle entries of XR_API_LAYER_PATH lists with three or more paths, an upstream substr count bug present in every branch. Verified by a function-level oracle, old implementation against new over a fixture tree (files, subdirs, symlinks, dangling links, path lists): byte-identical except the two corrupted-list lines, now correct; ASan/UBSan/LeakSan clean; and the manifest-file oracle from the rjson conversion rerun on the new filesystem, byte-identical including relative library_path resolution. Quest ndk-build links and the Windows-shape loader amalgam compiles under MinGW. * openxr: remove the loader's exception handling Nothing in the loader throws any more - jsoncpp, jnipp and the std::filesystem calls went in earlier changes - so the exception machinery guarding the C ABI goes too: exception_handling.hpp and the 71 XRLOADER_ABI_TRY/CATCH wrappers around the entry points in loader_core and xr_generated_loader, the empty catch blocks in the ApiLayerInterface and RuntimeInterface destructors, and the dead jsoncpp exception-mode guard in manifest_file. The whole loader now compiles under -fno-exceptions, which the compiler itself enforces as proof that no try, catch or throw remains; griffin keeps building it with exceptions enabled only because glslang shares the TU. The one reachable delta is allocation failure inside an entry point, which terminates instead of unwinding to XR_ERROR_OUT_OF_MEMORY - the loader is statically linked into the frontend, where that is already the outcome everywhere else in the process. Verified with -fno-exceptions compiles of the full loader in Linux, MinGW and NDK arm64 shapes, the manifest-file oracle byte-identical under ASan/UBSan/LeakSan, and quest plus plain ndk-builds linking on the PR's rebased head. * openxr: filesystem_utils on direct libretro-common calls where one fits Every function here is now a direct libretro-common call where one with std::filesystem's semantics exists: PathExists is path_is_valid, CombinePaths joins through fill_pathname_join_special, and the hand-rolled separator macros give way to PATH_CHAR_IS_SLASH and PATH_DEFAULT_SLASH_C; only the env path-list separator keeps a local define, since libretro-common has no such constant. What stays hand-written is documented in place as a deliberate semantic difference from libretro-common's contracts: GetParentPath (fill_pathname_basedir fabricates "./" for a bare filename and keeps trailing slashes), GetAbsolutePath (path_resolve_realpath without symlink resolution would normalise dots, which std::filesystem::absolute does not), ParsePathList (string_split's strtok collapses empty entries), and FindFilesInPath wants bare names where dir_list_new returns full paths, so the retro_dirent primitives are the fit. FileSysUtilsGetCurrentPath had no caller anywhere in the loader and leaves the interface, surviving only as the static getcwd helper behind GetAbsolutePath. The last two <stdexcept> references go too: manifest_file's include was dead since the exception removal, and vulkan_debug_object_namer.hpp was referenced by nothing in the tree. Both oracles rerun byte-identical - the function-level one over the fixture tree and the manifest-file one under ASan/UBSan/LeakSan - and the loader still compiles -fno-exceptions in Linux, MinGW and NDK shapes, with quest and plain ndk-builds linking. * openxr: guard the context drivers' XR platform defines The Android build also passes XR_USE_PLATFORM_ANDROID on the command line, so the bare defines the two OpenXR context drivers carry for standalone compilation redefine it - and the graphics-API macros alongside it are one -D away from the same collision. Wrap all of them in #ifndef so either source of the define wins quietly, whichever compiles the file first in the griffin TU. --------- Co-authored-by: libretroadmin <[email protected]> |
||
|
|
d2d2fb21b9 |
runloop: fast-forward ratio stays out of the menu, high ratios reach their rate, vsync and Scanline Sync apply live
Scanline Sync holds the focused menu as vsync does, so the frame limit the menu leaves standing - the fast-forward period - no longer runs a timer there; between locks the gap limiter bridges at the display rate. Closing the menu over running content restores the fast-forward limit. The sleep margin may follow the OS timer up to 2 ms, and at most a whole period, so a fast-forward period shorter than the timer can sleep is spun to its deadline and every ratio reaches its rate. Video, Scanline Sync and Adaptive VSync toggles reapply the driver's blocking state, and every caller derives it from runloop_vsync_blocks(): vsync blocks only without Scanline Sync, a forced nonblock or fast-forward. Switching Scanline Sync on reads the output lines afresh. The menu stick-to-D-pad mapping computes its bit unsigned. samples/runloop/pacing pins the menu row, fast-forward at 15x/30x/60x over a 0.25-2 ms timer, and the blocking predicate. |
||
|
|
c4049b4716 | Run-Ahead: Fix intrusive guard by making it optional and improving metrics (#19716) | ||
|
|
2a9892606a |
input: the replay code and the Android drivers ask by name
The replay code took the run loop's state for two things, and the settings twice a frame: - whether the run loop is paused is runloop_get_flags(); - whether the keyboard callback in place is the frontend's own, which is where a replay sends its recorded keys, is runloop_key_event_is_frontend(); - the checkpoint interval and whether a checkpoint is loaded are handed to bsv_movie_next_frame() by the run loop, which has the settings in hand. With a replay on, that is two calls for the settings a frame that are no longer made. It still takes the input state, and stays that way: its state is kept there, so it is the frontend's own code reaching its own data. The check says so (OWN_STATE): that file may take the input state and nothing else. The Android input and joypad drivers read nine settings; each is a named call now, the Android-only ones under ANDROID - sensors, the stylus's four, the disconnect workaround, the physical keyboard, the block timeout, device vibration. One read is left in the Android input driver: it saves the configuration when Android takes the application away. That is frontend work sitting in an input driver, and belongs out of it. Left in tools/input_state_grab_check.py: 16 in 10 files - that one, Apple, the consoles, udev's touch options, webOS, and the SDL2 input driver taking the video driver's window. Built for Linux and Android; the four replay tests and the frontend harness pass. input/bsv/bsvmovie.c fails the syntax gate before this change as after it, on a type the gate's C89 lane does not define. |
||
|
|
2bd0428eea |
input: drivers ask the frontend, the menu and the run loop by name
An input driver that needed to know whether the menu was up, or had to say that the platform's keyboard was showing, took the whole state it lived in and picked the field out: if (menu_state_get_ptr()->flags & MENU_ST_FLAG_ALIVE) input_state_get_ptr()->flags |= INP_FLAG_NATIVE_KB_SHOWN; runloop_state_get_ptr()->flags |= RUNLOOP_FLAG_PAUSED | RUNLOOP_FLAG_IDLE; That ties every driver to the layout of four structures and leaves nothing to say what a driver may read or change. Forty of these are replaced, in eleven files, with a named call on the side that owns the state: - the input frontend: the platform's keyboard is available, is shown; a line of text is being typed, is handed over, is done; pointer input is blocked; game focus; the mouse grab; the input driver's data for a joypad driver that is part of it - the menu: menu_driver_alive(), and the label of the open text entry - the run loop: paused by the platform, content loaded (and runloop_get_flags(), which was there) Each call does what the line it replaces did. No driver under input/ takes the input, menu or run loop state any more, but for the replay code in input/bsv. What is left is listed in tools/input_state_grab_check.py, file by file: 63 in 24 files, of which 52 are a driver reading the settings, 10 the replay code, and one the SDL2 input driver taking the video driver's window. The check runs in CI; a count can go down and not up. Built for Linux, Windows (four raw input tests under Wine) and Android, with the frontend harness. The PSP, PS3, QNX, web and webOS files are not built here. |
||
|
|
2a0c7c1ae6 |
content load: the core's library is opened on the task worker
A staged load opens the new core's library on the task worker once the old core is closed, while the frame loop goes on, and the core stage takes the handle instead of opening it itself. Only the open moves; retro_init, the content read and retro_load_game stay on the thread that runs the core. The open waits for the old handle's release, so a same-core reload still comes up on its own statics, and a generation counter drops a handle whose load was superseded. Without a task worker the core stage opens the library itself, as before. The content_load harness checks the library is opened on a worker, not the frame-loop thread, and that a same-core reload comes up fresh. |
||
|
|
e998d8f31b |
runahead: key events reach the second instance too
The second instance's keyboard callback is kept in a slot of its own, and a key event bound for the core goes to both instances, so a key that arrives while the second instance polls takes effect in the frames it runs ahead. The slot is emptied before the copy is closed. The content_load harness checks a key event reaches both instances and that closing the second instance drops its callback. |
||
|
|
0f6ba6828b |
runloop: a core is opened to describe itself once per file
libretro_get_system_info() keeps what it asks of a core - its system info, no-game support and content info overrides - keyed by the core file's size and modification time, in core_probe.cache next to the core info cache. A core already asked is answered from the record, so a load no longer opens the new core at push just to read these; a new or changed file is opened as before, and a core that declares subsystems always is. The menu's read-ahead of content decides by the core being loaded, from those same declarations, instead of the override list of the core still running. The content_load harness checks a known core is not reopened at push, a changed file is, the record is read back from disk, and the read-ahead follows the new core's overrides in both directions. |
||
|
|
4c6d8311b9 |
runloop, video thread: the menu at Content Rate under display pacing has one clock
With Threaded Video Display Pacing on, the menu at Menu Frame Rate 'Content Rate' over a stopped core is held to the content's period by the display pacing hold alone. The hold keeps the content's period there rather than the display's, and the frame limiter's timer stands aside for it, as it already does at 'Display Rate'. The two, at nearly the same period and never an exact multiple of each other, beat, and a frame landed a vblank early or late every so often. The menu pacing table's Content Rate + Display row reads Display alone, and the threaded-video harness measures the menu over a paused core at both rates. |
||
|
|
74935dc166 |
menu: Menu Frame Rate replaces Throttle Menu Framerate
Menu Frame Rate sets the rate the menu runs at while content is loaded, in every sync mode: 'Display Rate', the default, runs it at the refresh rate of the monitor the window is on, and 'Content Rate' at the content's frame rate. At 'Display Rate' the silence the menu feeds is written without blocking and measured out by the clock, so audio no longer holds the menu to the content's rate; a core left running behind the menu keeps its own clock, running when its next frame is due while the menu re-presents its last frame in between; and behind the threaded video wrapper without the display pacing hold, the timer holds the menu to the display's period. A configuration with Sync to Exact Content Framerate and Throttle Menu Framerate on keeps the content rate it had, and the old key is dropped on save. Display servers gain get_window_refresh_rate, the refresh rate of the output the window is on, for Win32, X11 and SDL, and Wayland reports it from surface enter and leave; the frontend keeps the reading until the window moves, its output changes mode or the menu opens. The pace decision, the menu pacing table, the threaded video harness and the X11 live sample cover both rates. |
||
|
|
2db2e86ba7 |
content: load content as a staged job the frame loop advances
The menu load ran the whole close-core/init-core/init-drivers cycle inside one runloop_iterate, so the window went dark - or dropped to the compositor on webOS - for the length of the read. content_load is now a job of three stages the frame loop steps through one per frame: the old core closes with the drivers kept up, the new core comes up behind them, then one driver reinit follows. Between stages the loop presents the cached frame under the menu, so the window keeps drawing. retroarch_main_init splits into a core phase and a driver phase for this: the drivers are found in the driver phase, after the previous session's are freed, so both sessions never hold a driver at once. Core deinit keeps the drivers while switching, a reinit the core asks for mid-load defers to the driver stage, and the pending menu actions (config replace, close, core reload) wait for the frame after. Startup and the CLI still load in one go, before any frame runs. |
||
|
|
d1a30ecab1 |
runloop: cheevos on a frame_work bit, presence on the 10 Hz cadence, setter contract
Three follow-ups on the product mask. Cheevos was the product left on a settings bool: both rcheevos_test() sites in the iterate read settings->bools.cheevos_enable and called into cheevos.c every frame, whether or not anything was attached. Put it on RUNLOOP_WORK_CHEEVOS with an honest lifetime: rcheevos_load() raises it once it has passed the enable / core-support / account gates and committed to loading content, rcheevos_unload() drops it. Between those the tick runs exactly as before (the bg-thread mailbox, then rc_client_do_frame or rc_client_idle). One visible change: flipping cheevos_enable off mid-content no longer silently stops the tick, which previously left a game attached but untested until the next load; the attach/detach now follows content, as rcheevos already assumes. presence_update(PRESENCE_GAME) ran every frame while the bit was on. "In a game" is a state, not a per-frame event, and its sinks are Discord (whose pump is already 10 Hz) and Steam. Add presence_poll(presence, now_us), a 100 ms throttle on the frame's existing clock, and call that from the iterate. No edge is lost: each sink compares against its own last status, so a change between polls is written at the next one. Document the threading contract on runloop_frame_work_set(): frame_work is a plain word the iterate reads without an acquire, so every setter must be on the main thread. All current callers are (init/deinit, commands, setting handlers); a worker must post a command instead. |
||
|
|
e39e641802 |
runloop: put cheats, presence, camera and BSV behind frame_work bits
The post-core_run product block called into four translation units
every frame to find out nothing needed doing: cheat_manager_apply_
retro_cheats() loads a cold global to see there is no cheat list,
presence_update() calls discord_update() and steam_update_presence()
which each compare a status word and return, the camera poll reads
settings_t for camera_allow before the caps check, and
bsv_movie_next_frame() pulled two settings through config_get_ptr()
before checking whether a movie handle exists at all.
Give each an up/down owner and a bit on runloop_state_t::frame_work,
raised and dropped by the product itself through
runloop_frame_work_set():
RUNLOOP_WORK_CHEATS - cheat_manager_new/realloc raise it when a
list is allocated, cheat_manager_free drops it
RUNLOOP_WORK_PRESENCE - raised with Discord init and with Steam
(mist) init; dropped with whichever of the
two is the last compiled-in sink
RUNLOOP_WORK_CAMERA - driver_camera_start raises it when the core's
start succeeds, driver_camera_stop and the
driver teardown drop it. The remaining
camera_allow/caps/driver checks stay behind
the bit; a camera the core registered but
never started is no longer polled.
BSV needs no bit: the movie handles live on input_st, which the frame
already has in cache, so the iterate tests the pointers directly and
bsv_movie_next_frame() checks its handle before touching settings.
|
||
|
|
3df357f12f |
runloop: gate the Discord pump on a frame-work bit, not a call into discord.c
Even throttled, the iterate reached the Discord pump by calling into discord.c and loading a cold global to learn that Discord was not in use. A product that is compiled in but idle should cost the frame one bit test on a word the loop already has in cache, not a cross-TU call. Add runloop_state_t::frame_work, an unsigned in the hot front of the struct next to pace, with one bit per optional product that hooks the iterate. Discord is the first: retroarch_main_init() raises RUNLOOP_WORK_DISCORD when CMD_EVENT_DISCORD_INIT succeeds (which it does not when discord_enable is off) and retroarch_main_quit() drops it with inited. The iterate tests the bit and only then calls discord_poll(). The other per-frame products (presence, cheats, BSV, camera) can move behind the same word one at a time. |
||
|
|
10c3cc5c58 |
runahead: clamp the frame count to what the measured step cost fits in the frame
Runahead is N + 1 core steps per visible frame plus a serialize and a deserialize, and the serialize cost is the core's state size, not something the frontend controls. For a 1-4 MB state that is nothing; for a core whose state is tens of MB, or one that runs near the frame budget on its own, N frames of runahead no longer fit and the result is dropped frames and stretched audio - worse latency than not running ahead at all. There was no gate: the requested count ran every frame regardless of what it cost. Measure the cost of one core step every frame (the whole of runahead_run() divided by the steps it made, so the save and load are folded in), IIR-average it (1/8), and clamp the frame count to what fits in 70% of the core's frame period. The count climbs back only once the request fits within 60%, so a core sitting on the boundary does not flip between N and N - 1 every frame. Samples above 250 ms (a JIT warm-up, a page-in) are dropped rather than dragging the average. Both instance paths cost N + 1 steps, so one bound covers both. A clamp is logged and, unless run_ahead_hide_warnings is set, shown once on the OSD when it changes; recovery is logged only. The measurement and the clamped count live in runloop_state_t next to the other runahead state and reset with it in runahead_clear_variables(). |
||
|
|
75599abff9 |
runloop: back off and eventually give up when the GPU device keeps being lost
A driver that lost its GPU device set VIDEO_FLAG_GPU_DEVICE_LOST and the runloop rebuilt the video driver at once, every time. That is the right answer to a device lost once - a TDR, a driver update - which comes back on the first rebuild. A device that is lost again straight after being rebuilt is a failing driver or GPU, and rebuilding on it every frame was a busy loop of full driver reinitialisations, each of which failed the same way. The first loss is still rebuilt immediately. A loss following it is retried with a doubling delay, from one second up to sixteen, and after six in a row the rebuild is abandoned with an on-screen message until a minute has passed. A loss a minute or more clear of the previous one is a fresh incident and starts the count again. Falling back to a different video driver is left as a policy choice: this only bounds the retry loop. |
||
|
|
2d075314fb |
Sync to Exact Content Framerate: keep vsync within the skew tolerance
A content rate slightly past what the display presents at the chosen interval - a 60.0988 Hz core at swap interval 2 on a 120 Hz panel, or 60 Hz content on a 59.94 Hz VRR ceiling - is paced by vsync with audio skewed as it is without VRR, rather than forcing the loop nonblocking. Only a content rate beyond audio_max_timing_skew keeps its own rate with vsync off. The decision is runloop_sync_plan_for() in runloop.h, pinned by a table and an invariant sweep in samples/runloop/pacing. Fixes #19600. |
||
|
|
e57668d229 |
Derive swap intervals above four, bounded by what the driver presents
'Auto' derives the swap interval as the whole multiple the display rate is of the content rate, up to MAXIMUM_SWAP_INTERVAL, which the manual setting's range reads too so the two cannot drift apart. A 480 Hz panel running 60 fps content holds each frame for eight display frames; driver_adjust_system_rates() then divides the target by that interval and the audio rate follows the display. The multiple has to be one the driver can present: the D3D APIs carry the interval as a present parameter that stops at four, so those drivers report that bound through the new get_swap_interval_cap poke and the ceiling comes down to it. A multiple past the cap falls back to 1 rather than clamping short, since a short multiple paces the loop fast. The decision itself moves to runloop_video_swap_interval_for() in runloop.h, next to the other pure pacing decisions, and samples/runloop/pacing covers the multiples, the driver cap, the ratios that are not whole multiples, and the degenerate rates. |
||
|
|
6d416e7a41 |
Remove empty preprocessor conditionals
Sixteen #if/#endif pairs across twelve files enclose nothing, so they select no code in any configuration. Removing them leaves preprocessor output identical. |
||
|
|
4419220efa |
Save core options before core teardown and on Android pause
Core options were only written automatically at the very end of core teardown, in runloop_deinit_core_options(): after the auto save-state, retro_unload_game(), retro_deinit() and dylib_close(). A crash anywhere in that sequence, or the process being killed before it, silently lost every option change made during the session. Per-game "Save Game Options" was unaffected because it writes immediately. - Split the write logic out of core_options_flush() into a quiet helper, runloop_core_options_save(), which writes to whichever options file is active without freeing anything or showing a notification. - Call it at the start of CMD_EVENT_UNLOAD_CORE (Close Content) and CMD_EVENT_CORE_DEINIT (Quit), before anything calls back into the core. The late save in runloop_deinit_core_options() is kept; it is a no-op unless the core changed an option during teardown, since config_file_write() only writes a modified config and clears the flag afterwards. - Call it from android_input_flush_pending_state(), next to the SRAM and config flush, so option changes survive Android killing the process in the background (e.g. swiped away from Recents). Not gated on config_save_on_exit, matching the unload-time save. Verified with a test core that crashes in retro_unload_game(): an option change made at runtime is lost before this change and saved after it. Normal (non-crashing) shutdown behaviour is unchanged. Fixes #19215 |
||
|
|
09ee89dbe0 |
runloop: the message queue needs no lock, because nothing contends it
RUNLOOP_MSG_QUEUE_LOCK is gone. The queue, core_status_msg and their decay were already main-thread-only in every path but one: off-main runloop_msg_queue_push callers ride the mpsc deferral, the task system's progress pushes run at gather and retirement on the main thread, and video_driver_frame's pulls, extraction and status decay run there too. The one remaining producer that could arrive on another thread was a rogue core calling SET_MESSAGE_EXT(STATUS) off retro_run's thread - the libretro API forbids it, cores do it anyway - and that case now rides the same deferral: the update is captured whole into a node flagged core_status, and the drain at the top of the next iterate applies it under the direct path's own overwrite rule, mirrored exactly - including that path's quirk of never storing a priority, kept deliberately so this change is threading only. With every toucher on the main thread by construction, the lock serialized nothing, and the seven lock sites, the field and the lifecycle go; the macro block in runloop.h becomes the invariant statement, and the stale claims in the win32 companion, gfx_widgets.h and the widgets race sample - all written against the world where any thread pushed under this lock - are brought up to date. The widget ring's own msg_queue_lock is untouched: it never depended on the runloop's. The deferral struct and its off-main test move above the environment callback, their new first user - defined before use, the lesson the mailbox gate taught positionally last week. samples/runloop/core_status_defer reproduces the STATUS deferral and holds three claims across 4000 posted updates from a worker, scripted clears included: applied exactly once, whole and in order; the drained final status agrees byte for byte with an oracle running the direct path's rule over the same script; every node freed exactly once. Clean under ASan/UBSan and Clang ThreadSanitizer. A clean C89_BUILD=1 rebuild passes, all five atomic backends compile runloop.c and the gfx lane, threads-off builds hold, the 74-lane matrix and all four hot-function budgets pass, the runloop pacing and content-closing suites pass, and the thread-read audit stays at zero. |
||
|
|
c1cc95493b |
runloop: the deferred messages ride a lock-free stack
The deferred-message list took the message queue lock to push and, worse, probed its head with a plain read every iterate - a data race against the workers' locked writes, benign in effect and illegal in form. The list is now queues/mpsc_stack.h, a many-producer single-consumer intrusive stack in libretro-common: a worker's push is a compare-exchange loop that never touches the message queue lock, the iterate's emptiness probe is an acquire load, and the drain takes the whole chain in one exchange. No ABA arises in this shape - nodes are only pushed and the consumer takes everything - and message frequency never made the lock slow; what the stack buys is a legal probe and workers that cannot contend with the main thread's own message work. The primitive carries its own lane, mpsc_stack_test in the libretro-common samples: four producers against a draining consumer, every push drained exactly once with per-producer order and payload held, clean under TSan and ASan - and a push weakened to a blind store fails it under TSan on both the race report and the count. The samples binary ignore no longer swallows new *_test directories, so the lane is trackable. |
||
|
|
0119f1991d |
runloop: a worker's message crosses to the main thread once
runloop_msg_queue_push() renders widgets, measures text, speaks the accessibility line and reads the settings - the main thread's work, and six of the threaded task handlers were doing it on the worker. An off-main caller now queues the message, whole, under the message queue lock, and the iterate's drain replays it on the main thread a frame late at most - the cadence messages show at anyway. The threaded task worker also stops pushing progress after a handler: the gather pushes for every running task each check and retirement pushes the final state, both on the main thread, so the worker-side push was a duplicate doing widget work from the wrong thread through the queue's message callback - a function pointer the audit cannot see, which is worth remembering. The audit learns what this fix is: a boundary - a function that defers off-main callers before touching anything - declared as @boundary in tools/thread_read_allow.list and held by review, where the walk stops. runloop_msg_queue_push is the first. tools/thread_read_audit.py --binary retroarch: 23 findings become 11, across every handler that showed messages; the remaining 11 are direct reads. All twenty-one task sample suites pass. |
||
|
|
137d495ab1 |
Remove eleven write-only state fields
Each of these is assigned and never read anywhere in the tree, so the work that feeds them is spent for nothing: content_label_len on the thumbnail path data, sink_discarded on the audio state, runahead_save_state_size, task_count and msg_queue_regular_padding_x on the widgets, pipeline_active on the display draw struct, resolution_hd_enable on the D3D8 and D3D9 states, memory_search_initialized on the cheat manager, window_title_len and video_frame_delay_auto_t::frame_time_avg on the video state, and input_dialog_kb_type on the menu state. Where a write captured a strlcpy() or fill_pathname() result the call stays and only the assignment goes. Two of them were holding up more than themselves. gfx_widgets_update_icon_layout() branched on whether icons are loaded solely to pick a padding value, so that conditional computed nothing and is gone with the field. memory_search_initialized sat beside memory_initialized, which is read, leaving two near-identical names for the next reader to tell apart. |
||
|
|
af165889ef |
Drop write-only frame limit field and read the clock once per cheat pass
runloop_state_t::frame_limit_last_time is written on content load, on the quit path and once per iteration inside the timer pacing block, and is read nowhere - the nanosecond anchor carries the schedule on its own. The field goes, and with it the divide the pacing path did to feed it. cheat_manager_apply_rumble() takes the timestamp from cheat_manager_apply_retro_cheats() rather than reading the clock itself. It runs once per cheat per frame and returns immediately for every entry whose rumble type is disabled, so one reading now serves the whole pass and every cheat in a frame is applied at the same instant. The function is file-local and is marked static. |
||
|
|
673053f171 |
runloop: drop RUNLOOP_PACE_EXTERNAL, unset since the Win32 pump left
The flag let a host clock driving runloop_iterate() from a modal loop skip the frame limiter's sleep, the frame delay and the no-window wait. Its only setter was the Win32 size/move pump from |