- C++ 58.4%
- C 36.7%
- Rust 2.2%
- HLSL 0.7%
- GLSL 0.6%
- Other 1.2%
Option B added texture filter as the outermost dimension of
m_batch_pipelines, making filter swaps instant on revisit. The same
problem still bit the user on toggling 'scaled dithering' and 'true
colour' in the core options menu: both are pure per-session spec
constants (DITHERING_SCALED = id 105, TRUE_COLOR = id 106) applied
at vkCreateGraphicsPipelines time, so the driver bakes them into
each cached PSO. With no cache dimension over them, the existing
non_filter_diff comparison in UpdateHWSettings would set
*only_filter_changed = false on a toggle, routing UpdateSettings
into the full DestroyPipelines + CompilePipelines path - the same
5-10 second pause Option B got rid of for filter.
Extend the same trick to both:
m_batch_pipelines: 7D -> 9D
was [filter][depth_test][render_mode][texture_mode]
[transparency_mode][dithering][interlacing]
now [filter][true_color][scaled_dithering][depth_test]
[render_mode][texture_mode][transparency_mode]
[dithering][interlacing]
m_batch_fragment_shaders stays 5D - true_color and scaled_dithering
do NOT affect SPIR-V blob choice, only the spec const value at PSO
bake time, so the same VkShaderModule backs both values. The PSO
cache doubles for each new dimension (atomic slots only - driver-
side memory grows only when a slot is populated).
API changes:
- GPU_HW::UpdateHWSettings out-parameter renamed
only_filter_changed -> only_dim_changed, with the semantics
broadened: the flag is true iff the only shader-affecting
changes are in dimensioned settings (filter, true_color,
scaled_dithering). Default-nullptr param so the D3D11 / D3D12
callers stay untouched - they continue doing a full destroy +
recompile on any shaders_changed event because their batch
caches are not yet dimensioned over anything.
- GetBatchPipeline gains two leading parameters:
GetBatchPipeline(filter, true_color, scaled_dithering, ...)
The internal m_true_color / m_scaled_dithering reads (slot
indexing context and the AddBool(105/106, ...) lines in the
spec const setup) are replaced with the passed parameters.
The same param-snapshot pattern Option C introduced for
filter now covers all three dimensioned settings, so the
helper has no implicit dependency on class-member state for
any of its cache axes.
Call site updates:
- DrawBatchVertices: passes (m_texture_filtering, m_true_color,
m_scaled_dithering).
- precompile_sync PSO loop in CompilePipelines: same.
- ShaderCompileThreadEntryPoint: snapshots m_true_color and
m_scaled_dithering at worker entry alongside the existing
filter loop. The worker is responsible only for the CURRENT
(true_color, scaled_dithering) combo's seven filter sub-
cubes - walking all 7 x 2 x 2 = 28 sub-cubes in the
background would balloon cold-cache warm-up to several
minutes, well past 'useful' into 'annoying'.
Behaviour after this patch:
- Cycling back to a previously-visited (filter, true_color,
scaled_dithering) tuple: instant. The slot is already filled,
GetBatchPipeline returns it from a single atomic load.
- First time toggling true_color or scaled_dithering in a
session: 5-10s sync compile in Enabled mode for the current
filter's sub-cube under the new value, then the worker warms
the other six filter sub-cubes in the background. Lazy mode
fault-ins on first draws as before.
- Toggling filter under the new (true_color, scaled_dithering):
same as Option C - instant on revisit, sync compile + back-
ground warm-up on first visit.
After enough cycling through the three settings (typically a few
back-and-forth toggles of each), all reachable combinations end up
cached and every toggle becomes instant for the rest of the
session.
Memory cost during warm-up:
- PSO cache atomic-slot count grows by 4x relative to pre-B,
7x already happened in Option B for filter, this patch makes
it 14x (true_color) and 28x (scaled_dithering). Slot array
size: ~480 KiB total. Driver-side PSO storage only grows when
slots are populated; a typical session touches maybe 10-20%
of one (filter, true_color, scaled_dithering) combo's
reachable cells.
- On hardware lacking dual-source blend the *BinAlpha and other
non-Nearest filters are clamped to Nearest by UpdateHWSettings
and the worker skips them via TextureFilterRequiresDualSource-
Blend, so the actual populated count is lower.
Smoke tests:
- Tree-wide grep for m_true_color / m_scaled_dithering /
only_filter_changed inside the helpers and their callers:
every remaining hit is either a comment, a callsite that
correctly snapshots the class member to pass downward, or
elsewhere in the file outside the batch pipeline path
(m_true_color / m_scaled_dithering still drive other Vulkan
structural choices like resolution scale).
- The two GetBatchPipeline helper signatures match in header
and impl; no stale 7D declaration of m_batch_pipelines
survives in the header.
Test priority:
- With shader cache nuked, in Enabled mode, toggle the
'scaled dithering' core option on then off then on. First
toggle pays the usual 5-10s pause for the current filter
sub-cube under the new dithering value. Second toggle back
to the original should be INSTANT - the slot is already
filled.
- Same test with 'true colour'. Same behaviour expected.
- Toggle both: scaled dithering off, true colour off, then
scaled dithering on, true colour off, ... cycle through all
four (true_color, scaled_dithering) combos. After one cycle,
every transition is instant for the rest of the session.
- Confirm non-dimensioned changes (resolution scale, MSAA,
PGXP depth, etc.) still trigger the full
DestroyPipelines + CompilePipelines pause - that path is
unchanged and required for those settings to be applied
correctly.
- On hardware without dual-source blend: confirm the worker
still walks only Nearest's sub-cube across the current
(true_color, scaled_dithering) snapshot.
- Long session (10+ minutes) of toggling the three dimensioned
settings: no driver-side OOM. Watch GPU memory in nvidia-smi
or Task Manager.
The set of dimensioned settings could be extended further to
pgxp_depth_buffer or other 2-value spec consts, but those toggle
much less frequently in practice and would only add another 2x
slot cost each. Defer until requested.
After this lands the Vulkan filter / dithering / true-colour
trio is functionally complete: every common user-toggled batch
shader setting is dimensioned, with current-combo background
warm-up keeping cold-cache cost bounded.
|
||
|---|---|---|
| CMakeModules | ||
| data/shaders/vulkan | ||
| dep | ||
| src | ||
| tools | ||
| .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.