A Rust and egui based front-end for the SwanStation PS1 Libretro core
  • C++ 58.4%
  • C 36.7%
  • Rust 2.2%
  • HLSL 0.7%
  • GLSL 0.6%
  • Other 1.2%
Find a file
LibretroAdmin 418eb1430e core, common: skip pipeline rebuild on cbuffer-only setting changes
Post 7b575a3 (cbuffer refactor), HLSL/GLSL batch shader source is
invariant under resolution_scale / true_color / scaled_dithering -
those three settings ride the per-batch UBO and are picked up by
the next FlushRender at no shader-compile cost on D3D11 / D3D12 /
OpenGL. The backends were still treating every toggle of any of
the three as a full shader rebuild though, because their
UpdateSettings handlers checked shaders_changed and that signal
still fired on cbuffer-only diffs - shaders_changed was defined as
'dim_diff || non_dim_diff', which includes both filter (real source
change) AND true_color/scaled_dithering (now cbuffer-only) AND
resolution_scale (now cbuffer-only).

With shader_precompile_mode = Enabled and a populated batch matrix
(~1164 reachable PSO cells in the default-user configuration), the
DestroyPipelines + CompilePipelines round trip walks every cell
synchronously through D3DCompile / glCompileShader before
UpdateSettings returns. On the user's system that's the full
'changing options can take up to a minute' pause they kept hitting
after every res-scale or true-color toggle, even though by
construction the patch that landed before this one made those
toggles trivially cheap at the shader level.

Add a new narrower out-parameter to GPU_HW::UpdateHWSettings:

  shader_source_changed (default nullptr, opt-in for callers)

It is true only when a setting that the shader generator bakes
into the emitted HLSL / GLSL string has flipped: texture filter,
multisamples, per-sample shading, UV limits, chroma smoothing,
PGXP depth, disable-color-perspective, and shader precompile mode.
resolution_scale, true_color, and scaled_dithering are explicitly
excluded - they are pure batch UBO cbuffer fields now. Both
chroma_smoothing and shader_precompile_mode stay in because they
do change shader-side work (chroma_smoothing is baked into the
display FS at GenerateDisplayFragmentShader call sites on the
D3D11 / D3D12 / OpenGL paths, and a Disabled -> Enabled precompile
flip is a request to compile the matrix synchronously now even
though no source has actually changed).

The existing shaders_changed signal is preserved verbatim. Vulkan
relies on it together with only_dim_changed to drive its
spec-const-aware dim-cache path, which still has to fire on
true_color / scaled_dithering flips because those spec constants
bake into VkPipeline at create time and demand a new pipeline per
sub-cube even though the SPIR-V text is identical. Vulkan keeps
calling UpdateHWSettings with the old four-argument form (no
shader_source_changed) and behaves exactly as before.

GPU_HW_D3D11::UpdateSettings, GPU_HW_D3D12::UpdateSettings, and
GPU_HW_OpenGL::UpdateSettings switch their compile-rebuild check
from shaders_changed to shader_source_changed. State-object
recreation in the D3D11 path is gated on the same signal: state
descriptions key on MSAA / dual-source / depth-test / blend mode,
all of which sit in the source-changed set, so existing state
objects stay correct through cbuffer-only toggles. framebuffer
rebuild is unchanged - it still fires on resolution_scale via the
framebuffer_changed signal, just without dragging the pipeline
rebuild along with it.

Concrete cost matrix after this patch (D3D12, default settings,
shader_precompile_mode = Enabled, populated matrix of ~1164 PSOs):

  Toggle                       Before     After
  resolution_scale             ~1 minute  framebuffer resize only
  true_color                   ~1 minute  zero
  scaled_dithering             ~1 minute  zero
  texture_filter               ~1 minute  ~1 minute (necessary)
  multisamples                 ~1 minute  ~1 minute (necessary)
  per_sample_shading           ~1 minute  ~1 minute (necessary)
  uv_limits                    ~1 minute  ~1 minute (necessary)
  chroma_smoothing             ~1 minute  ~1 minute (display FS;
                                          could be split later)
  pgxp_depth                   ~1 minute  ~1 minute (necessary)
  disable_color_perspective    ~1 minute  ~1 minute (necessary)
  shader_precompile_mode       ~1 minute  ~1 minute (intentional)
  downsample_mode (non-adapt.) currently no-op on D3D12, unchanged

Same shape on D3D11 and OpenGL.

Test:
  - D3D12, shader_precompile = Enabled, populated cache. Toggle
    resolution scale 4x -> 1x -> 4x: each transition is
    framebuffer-resize fast, no 'Compiling Pipelines N/1164' OSD.
  - Toggle true_color on / off: instant, no OSD.
  - Toggle scaled_dithering on / off: instant.
  - Toggle texture filter Nearest -> Bilinear: still pays the
    precompile (necessary - filter changes batch FS source).
  - Toggle MSAA / per-sample / UV limits / PGXP depth / colour
    perspective: still pays (necessary).
  - chroma_smoothing toggle: still pays (suboptimal - the batch
    matrix doesn't actually depend on it, only the display FS
    does, but splitting batch / non-batch rebuild is a separate
    change; leaving it at the conservative correct behaviour for
    now).
  - Same battery on D3D11 and OpenGL.
  - Vulkan: behaviour unchanged. Still uses dim-cache for filter /
    true_color / scaled_dithering and full rebuild for everything
    else.
2026-05-18 06:14:16 +02:00
CMakeModules Remove unused files 2023-03-25 17:43:35 +01:00
data/shaders/vulkan common/vulkan, core: pre-bake remaining batch FS texture filters (Bilinear / JINC2 / xBR families, 72 blobs total) 2026-05-18 02:04:30 +02:00
dep dep, common/vulkan, core, build: remove dep/glslang and the Vulkan ShaderCompiler infrastructure 2026-05-18 02:21:53 +02:00
src core, common: skip pipeline rebuild on cbuffer-only setting changes 2026-05-18 06:14:16 +02:00
tools common/vulkan, core: pre-bake remaining batch FS texture filters (Bilinear / JINC2 / xBR families, 72 blobs total) 2026-05-18 02:04:30 +02:00
.clang-format clang-format: Enable brace wrapping after case label 2020-01-24 14:49:43 +10:00
.gitattributes Initial commit 2019-09-11 14:00:42 +10:00
.gitignore Sync Android strings 2021-07-17 20:14:40 +10:00
.gitlab-ci.yml Merge pull request #167 from cscd98/webos-ci 2026-04-10 05:12:17 +02:00
CMakeLists.txt build: add MSB_FIRST opt-in flag for big-endian hosts 2026-05-08 00:32:03 +02:00
libretro.osx.def libretro: add static Makefile.libretro build 2026-05-07 21:32:02 +02:00
LICENSE Initial commit 2019-09-11 14:00:42 +10:00
link.T libretro: add static Makefile.libretro build 2026-05-07 21:32:02 +02:00
Makefile.libretro dep, common/vulkan, core, build: remove dep/glslang and the Vulkan ShaderCompiler infrastructure 2026-05-18 02:21:53 +02:00
README.md Documentation OpenBIOS usage in the README. 2026-04-02 10:46:10 +01:00
TODO Update TODO (#132) 2025-01-17 16:28:45 +01:00

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.