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 93e5db5239 core/d3d11: skip batch matrix rebuild on chroma_smoothing-only flip
D3D11 parity port of the chroma_smoothing partial-clear that
landed for D3D12 in 57ac62e. Same motivation: chroma_smoothing
is a DefineMacro inside GenerateDisplayFragmentShader only - it
never reaches the batch pixel shader matrix or the VRAM ops
pixel shaders. The previous D3D11 patches kept it in
shader_source_changed, so on D3D11 a chroma toggle still drove
the full DestroyShaders + DestroyStateObjects +
CreateStateObjects + CompileShaders round trip and walked the
144-cell batch pixel shader matrix synchronously when
shader_precompile_mode = Enabled.

Reuses the display_only_source_changed signal added by 57ac62e
(no API change). GPU_HW_D3D11::UpdateSettings checks it first
inside the shader_source_changed gate, before only_dim_changed
and the full-flush branch. The display-only branch calls a new
helper, RebuildDisplayPixelShaders, that recompiles the 2x3
m_display_pixel_shaders matrix against the new m_chroma_smoothing
value (which UpdateHWSettings has already written into the
member). The 144-cell batch pixel shader matrix, the VRAM ops
pixel shaders, the blend / depth-stencil / input layout state
objects, and the batch vertex shaders all stay valid because
none of them carry chroma_smoothing as ctor or compile-time
state.

CompileShaders is refactored to call the same helper for its
initial display-shader build, so the 6-cell compile loop only
lives in one place. Progress tracking is bumped six times
inline after the helper returns to match the pre-patch progress
bar units.

chroma_smoothing only takes effect on the depth_24bit paths (see
the '&& m_chroma_smoothing' guard in GenerateDisplayFragmentShader),
so technically only three of the six shaders actually depend on
it. Rebuilding all six anyway keeps the path simple - on a chroma
toggle the three depth_24bit=false shaders re-resolve to cache
hits on their existing HLSL hashes in m_shader_cache (instant
GetPixelShader return), and the three depth_24bit=true shaders
pick up the new SMOOTH_CHROMA value via a fresh D3DCompile.

UpdateSettings also handles the precompile_mode contract on the
rebuild side now that the partial-clear branch skips
CompileShaders:

  Enabled: RebuildDisplayPixelShaders is synchronous, so the
           next draw doesn't stutter on display shader fault-in.
  Lazy:    relaunch the background worker that
           StopShaderCompileThread joined at the top of
           UpdateSettings. The worker only walks the batch
           pixel shader matrix, so it doesn't care about
           chroma_smoothing - keeping it stopped after a chroma
           toggle would just starve mid-warmup sessions of
           further background fill.
  Disabled: no worker, no extra work - matches the standing
            'skip all compilation at init' contract for the
            batch matrix.

The other rebuild branches (only_dim_changed, full destroy) are
unchanged - they're hit only when something the batch matrix
genuinely depends on changed, and the dim cache / full-flush
paths from 00cf11f already do the right thing there.

Cost matrix after this patch (D3D11, default settings,
shader_precompile_mode = Enabled, 144 reachable batch shader
cells):

  Toggle                  Before (00cf11f)    After this patch
  chroma_smoothing        ~5-15 sec           ~600 ms
                          (full matrix walk)  (6 display shaders)
  texture_filter (warm)   instant             unchanged
  texture_filter (cold)   ~5-15 sec           unchanged
                          (new sub-cube)
  resolution_scale        zero                unchanged
  true_color              zero                unchanged
  scaled_dithering        zero                unchanged
  multisamples            ~5-15 sec           unchanged (necessary)
  per_sample_shading      ~5-15 sec           unchanged (necessary)
  uv_limits               ~5-15 sec           unchanged (necessary)
  pgxp_depth              ~5-15 sec           unchanged (necessary)
  disable_color_persp.    ~5-15 sec           unchanged (necessary)
  shader_precompile_mode  ~5-15 sec           unchanged (intentional)

Every remaining 'still pays' toggle in the matrix is one that
genuinely invalidates batch HLSL across the board; the D3D11
backend's UpdateSettings path is now structurally on par with
the D3D12 backend's post-57ac62e cost matrix.

Test:
  - D3D11, shader_precompile = Enabled. Toggle 24-bit chroma
    smoothing on / off: ~600 ms pause (6 display pixel shader
    rebuilds), no batch matrix progress OSD. Batch draw remains
    hot - no stutter on the next frame.
  - Same toggle under Lazy: ~600 ms pause for the display
    rebuild, worker is paused for the duration of UpdateSettings
    then relaunched, batch matrix continues warming.
  - Same toggle under Disabled: ~600 ms pause for the display
    rebuild, no worker, batch matrix stays as it was (mostly
    empty until faulted by draws).
  - Toggle chroma_smoothing AT THE SAME TIME as another setting
    (e.g. via batch settings reload): display_only_source_changed
    returns false (other_source_diff is true), the only_dim or
    full-flush branch fires as before.
2026-05-18 07:26:52 +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/d3d11: skip batch matrix rebuild on chroma_smoothing-only flip 2026-05-18 07:26:52 +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.