- C++ 57.9%
- C 36.4%
- Rust 2.8%
- HLSL 0.7%
- GLSL 0.6%
- Other 1.5%
Two finds this round. Smaller than rounds 2-6 because the obvious
surface is increasingly exhausted, but both are real:
* A genuine dead pure-virtual interface method on HostDisplay,
RenderSoftwareCursor(), with four empty-stub overrides across
all subclasses. This is the first vtable-slot reduction of the
sweep series - actual codegen change from collapsing the vtable,
not just removed function bodies.
* A decl-only template helper in common/bitutils.h whose sibling
(CountLeadingZeros) is alive.
Build clean on Makefile.libretro platform=unix at each step.
swanstation_libretro.so size: 7,911,792 -> 7,911,560 bytes (-232).
25 retro_* exports preserved.
== common/bitutils ==
template<typename T>
ALWAYS_INLINE unsigned CountTrailingZeros(T value)
Inline template + #ifdef _WIN32 platform split (_BitScanForward
vs __builtin_ctz). Zero callers anywhere - the only bit-scan
helper actually used is CountLeadingZeros (3 callers, all in
the recompiler register allocator for choosing the next-free
host register from the available-register bitmap).
== core/host_display + 4 subclasses ==
virtual void HostDisplay::RenderSoftwareCursor() = 0
The pure-virtual no-arg variant. Zero direct call sites anywhere
in the tree - the actual cursor render path uses the 5-arg
sibling overload (RenderSoftwareCursor(int32_t left, int32_t top,
int32_t width, int32_t height, HostDisplayTexture* texture_handle)),
invoked from gpu_hw_d3d11.cpp:382, gpu_hw_vulkan.cpp:554, and
gpu_hw_opengl.cpp:541 inside each backend's display-render path.
Subclass overrides dropped:
LibretroHostDisplay::RenderSoftwareCursor() {}
libretro_host_display.h:25, libretro_host_display.cpp:91
LibretroD3D11HostDisplay::RenderSoftwareCursor() {}
gpu_hw_d3d11.h:55, gpu_hw_d3d11.cpp:300
LibretroVulkanHostDisplay::RenderSoftwareCursor() {}
gpu_hw_vulkan.h:56, gpu_hw_vulkan.cpp:438
LibretroOpenGLHostDisplay::RenderSoftwareCursor() {}
gpu_hw_opengl.h:62, gpu_hw_opengl.cpp:462
All four subclass overrides had empty function bodies '{}' - the
classic sign of a pure-virtual that was never wired up but had to
be implemented to satisfy the C++ requirement. There is no
LibretroD3D12HostDisplay subclass (D3D12 has GPU_HW_D3D12 only,
no host-display variant), so 4 overrides is the full count.
The .so size dropped by 232 bytes - removing the vtable slot
shrinks every subclass's vtable by one pointer entry (8 bytes per
class on x86-64 = 32 bytes across the 4 subclasses + 8 bytes for
the base + alignment) and elides 4 empty function bodies (each
4-12 bytes of prologue/epilogue depending on calling convention).
This is the first real vtable-slot reduction of the sweep series.
== Audited and kept ==
HostDisplay::GetRenderDevice() / GetRenderContext()
Initially LOOKED dead under platform=unix audit - all four
subclass overrides (Libretro, OpenGL, Vulkan) return nullptr,
and grep showed no caller in any *.cpp file built on unix.
REVERTED after spotting that gpu_hw_d3d11.cpp:461-462 actually
consumes them: LibretroD3D11HostDisplay::GetRenderDevice()
returns m_device.Get() (real ID3D11Device*), and GPU_HW_D3D11
upcasts the result to ID3D11Device* during initialization.
gpu_hw_d3d11.cpp is Windows-only (Makefile.libretro guards it
behind ifeq (IS_WINDOWS,1)), so the unix-build .so doesn't link
those call sites and the unix toolchain doesn't fail when the
interface is removed - but a Windows build would break.
This is the second methodology pitfall added this round (see
notes below).
== Methodology notes ==
Two additions to the running list:
* Pure virtuals with all-stub overrides are a high-value find.
They reduce *both* source lines AND vtable size in every
subclass. The pattern: 'virtual ... = 0;' declaration where
every override's body is '{}' and the only callers are inside
the base class (which never calls them). RenderSoftwareCursor()
had this exact shape and yielded the first real codegen change
from a dead-virtual drop in the series. Look for additional
candidates where the override count equals the subclass count
and every body is empty.
* Build-guarded subsystems hide real callers from the unix build.
Helpers like GetRenderDevice() looked dead under a unix-build
audit because their D3D11-side caller is in a file that
Makefile.libretro doesn't compile when IS_WINDOWS isn't set.
The unix .so wouldn't link the caller and the unix compiler
wouldn't complain when the interface is removed. The drop
silently compiles on unix and silently breaks Windows.
Rule: when an interface method exists on the HostDisplay base
class (or any other multi-backend abstraction), grep the FULL
source tree, not just the unix-build subset, before declaring
it dead. The Makefile.libretro guards for D3D11/D3D12 are at:
ifeq ($(IS_WINDOWS),1)
SOURCES_CXX += gpu_hw_d3d11.cpp
SOURCES_CXX += [d3d11 utility files]
endif
ifeq ($(IS_WINDOWS),1)
SOURCES_CXX += gpu_hw_d3d12.cpp
endif
Anything inside those guards is invisible to the unix build but
alive on Windows. Always grep --include='*.cpp' across the WHOLE
tree (no exclusions) on multi-backend interface candidates.
Build: Makefile.libretro platform=unix - clean.
swanstation_libretro.so size: 7,911,792 -> 7,911,560 bytes (-232).
retro_* exports: 25 (unchanged).
10 files changed, 31 deletions(-).
|
||
|---|---|---|
| CMakeModules | ||
| dep | ||
| src | ||
| .clang-format | ||
| .gitattributes | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| CMakeLists.txt | ||
| libretro.osx.def | ||
| LICENSE | ||
| link.T | ||
| Makefile.libretro | ||
| README.md | ||
| TODO | ||
SwanStation - PlayStation 1, aka. PSX Emulator
Features | System Requirements | Disclaimers
SwanStation is a hard fork and open-source Libretro core implementation of DuckStation, which is an emulator of the Sony PlayStation(TM) console, focusing on playability, speed, and long-term maintainability. The goal is to be as accurate as possible while maintaining performance suitable for low-end devices. "Hack" options are discouraged, the default configuration should support all playable games with only some of the enhancements having compatibility issues.
A "BIOS" ROM image can be used, but is not required. You can use an image from any hardware version or region, although mismatching game regions and BIOS regions may have compatibility issues. A ROM image is not provided with the emulator for legal reasons, you should dump this from your own console using Caetla or other means. If no ROM image is provided, OpenBIOS will be used instead.
Features
SwanStation features include:
- CPU Recompiler/JIT (x86-64, armv7/AArch32 and AArch64)
- Hardware (D3D11, OpenGL, Vulkan) and software rendering
- Upscaling, texture filtering, and true colour (24-bit) in hardware renderers
- PGXP for geometry precision, texture correction, and depth buffer emulation
- Adaptive downsampling filter
- Post processing shader chains
- "Fast boot" for skipping BIOS splash/intro
- Save state support
- Supports bin/cue images, raw bin/img files, MAME CHD, single-track ECM, MDS/MDF, and unencrypted PBP formats.
- Direct booting of homebrew executables
- Direct loading of Portable Sound Format (psf) files
- Digital and analog controllers for input (rumble is forwarded to host)
- Namco GunCon lightgun support (simulated with mouse)
- NeGcon support
- Emulated CPU overclocking
- Multitap controllers (up to 8 devices)
- RetroAchievements
- Automatic loading/applying of PPF patches
System Requirements
- A CPU faster than a potato. But it needs to be x86_64, AArch32/armv7, or AArch64/ARMv8, otherwise you won't get a recompiler and it'll be slow.
- For the hardware renderers, a GPU capable of OpenGL 3.1/OpenGL ES 3.0/Direct3D 11 Feature Level 10.0 (or Vulkan 1.0) and above. So, basically anything made in 2013 or later.
Region detection and BIOS images
By default, SwanStation will emulate the region check present in the CD-ROM controller of the console. This means that when the region of the console does not match the disc, it will refuse to boot, giving a "Please insert PlayStation CD-ROM" message. SwanStation supports automatic detection disc regions, and if you set the console region to auto-detect as well, this should never be a problem.
The region checking can be disabled in the console options tab. This is the only way to play unlicensed games or homebrew which does not supply a correct region string on the disc, aside from using fastboot which skips the check entirely.
Mismatching the disc and console regions with the check disabled is supported, but may break games if they are patching the BIOS and expecting specific content.
LibCrypt protection and SBI files
A number of PAL region games use LibCrypt protection, requiring additional CD subchannel information to run properly. libcrypt not functioning usually manifests as hanging or crashing, but can sometimes affect gameplay too, depending on how the game implemented it.
For these games, make sure that the CD image and its corresponding SBI (.sbi) file have the same name and are placed in the same directory. SwanStation will automatically load the SBI file when it is found next to the CD image.
For example, if your disc image was named Spyro3.cue, you would place the SBI file in the same directory, and name it Spyro3.sbi.
Tests
- Passes amidog's CPU and GTE tests in both interpreter and recompiler modes, partial passing of CPX tests
Disclaimers
"PlayStation" and "PSX" are registered trademarks of Sony Interactive Entertainment Europe Limited. This project is not affiliated in any way with Sony Interactive Entertainment.