The GPU thread ran the FIFO in 5 ms slices against the wall clock and
slept out each slice's rest, which held every retro_run near 4 ms. The
loop now runs until the CPU thread ends the field or a park or quit
interrupts it (InterruptGpuLoop), and an idle loop parks with no
timeout: no slices, no clock reads, no busy loop, and no GPUSleeper
event to let it sleep (kept registered, never scheduled, for the
savestates that have it queued). retro_run waits for the field as long
as it takes; FIELD_WEDGE_US, one second with nothing arriving, is the
only bound, for a wedged thread.
PERF_TEST=1 builds a core with the frontend's performance counters
around the field and the frame hand-over. AGENTS.md states the rules:
the frontend owns the pace, no timed waits but the wedge guard, stop by
request, park and never spin, no locks.
Each thread that compiles hands rslc one block as its arena, doubled
and compiled again where a shader needed more, so the parse, the IR and
the emit allocate nothing once the block has grown; only the blob the
shader keeps is allocated. The blocks go as the backend shuts down. C89.
Allocations after boot over the corpus fall from 1702 to 1356, and the
bytes allocated from about 28 MB to 2 MB.
Of it, the backends read the EFB scale, now passed as the backbuffer
scale; GLContext::Create tested for libretro, its only context; and
the controller interface kept a render window that is always null. The
video backends' Initialize, InitBackendInfo and PopulateBackendInfo,
Core::Init, EmuThread and StartEmuThread, BootCore and the controller
interface lose the parameter; PrepareWindow, ChangeWindow, the window
change refresh and the Vulkan instance's surface extensions go, as
nothing presents but the frontend.
Entries come from chunks kept for the core's life and go back to them
when their last handle goes, so a texture cached while the game runs
allocates no entry. Their handles count in the entry itself, with plain
increments on the video thread.
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.
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.
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.
Drop DolphinAnalytics and Common/Analytics along with every game-quirk,
game-start, performance-sample and GPU-bug-override report, the
Main.Analytics settings, and the Android opt-in dialog, settings
entries, JNI hooks and session-timestamp tracking that only fed it.
DriverDetails loses its to_string helpers and stored driver name,
which only built the bug-override report.
In LabelMap.cpp, the code is currently unused so I was unable to test it.
In WiiUtils.cpp, the magic value `1u` was replaced by the constant value `DiscIO::PARTITION_UPDATE`.
This reverts the revert commit bc67fc97c3,
except for the changes in BaseConfigLoader.cpp, which caused the bug
that made us revert 72cf2bdb87. PR 12917
contains an improved change to BaseConfigLoader.cpp, which can be merged
(or rejected) independently.
A few changes have also been made based on review comments.
Prevent potential issues when creating the Graphics window (and thus
calling PopulateBackendInfo) while the core state is Stopping, like we
already do while it's Starting or Running.
Remove the PopulateBackendInfoFromUI function, which had a single caller
(GraphicsWindow::OnBackendChanged) and checked that the core wasn't
running or starting before calling PopulateBackendInfo.
Move the core state check into PopulateBackendInfo and have
OnBackendChanged call that instead. This guarantees the check is
performed by all callers of PopulateBackendInfo, preventing
potential reintroduction of the crash fixed in 3d4ae63f if another call
to PopulateBackendInfo is added.
As of the previous commit the only other caller of PopulateBackendInfo
is Core::Init shortly before s_state is set to Starting, so it will
always pass the check and so maintain its current behavior.
Fix a crash when opening the Graphics window for the first time during
emulation startup when the backend is Vulkan, D3D11, or D3D12.
Don't call PopulateBackendInfo() from the Host thread when the core is
starting up. First, the function has already been called in Core::Init()
so we don't need to again. More importantly, PopulateBackendInfo() calls
g_video_backend->InitBackendInfo(), and the Vulkan and D3D
implementations of those functions load and then unload libraries (and
their associated function pointers) which are potentially in use by
other threads.
This crash was reliably reproducible with the following steps:
1) Select an affected backend.
2) Enable "Compile Shaders Before Starting"
3) Delete the cached shaders (but not the .uidcache file) for the game
you're testing.
4) Close and reopen Dolphin.
5) Start the game.
6) While the game is still booting or compiling shaders, open the
Graphics window for the first time in that Dolphin session.
Fixes https://bugs.dolphin-emu.org/issues/13634.
If texture dumping is enabled, notify the user on emulation startup
using an On Screen Display message.
Also notify the user when texture dumping is toggled.
Addresses https://bugs.dolphin-emu.org/issues/12445.
Given how many member functions make use of the system instance,
it's likely just better to pass the system instance in on construction.
Makes the interface a little less noisy to use.