A Rust and egui based front-end for the SwanStation PS1 Libretro core
  • C++ 57.9%
  • C 36.4%
  • Rust 2.8%
  • HLSL 0.7%
  • GLSL 0.6%
  • Other 1.5%
Find a file
LibretroAdmin 9d2b49d226 core: route RESOLUTION_SCALE through vram_write_ps cbuffer
Same refactor as e56d4d4 applied to vram_write_ps. Adds
`uint u_resolution_scale, uint u_pad0` to its cbuffer, routes
RESOLUTION_SCALE / VRAM_SIZE / RCP_VRAM_SIZE through the cbuffer
via WriteCBufferResolutionScaleAliases, switches WriteCommonFunctions
to the cbuffer-aware path (true) instead of the legacy literal
emission (false default).

vram_write_ps body references both RESOLUTION_SCALE and VRAM_SIZE
directly:

  uint2 coords = uint2(uint(v_pos.x) / RESOLUTION_SCALE,
                       fixYCoord(uint(v_pos.y)) / RESOLUTION_SCALE);
  ...
  offset.x = (coords.x < u_base_coords.x)
    ? ((VRAM_SIZE.x / RESOLUTION_SCALE) - u_base_coords.x + coords.x)
    : (coords.x - u_base_coords.x);
  offset.y = (coords.y < u_base_coords.y)
    ? ((VRAM_SIZE.y / RESOLUTION_SCALE) - u_base_coords.y + coords.y)
    : (coords.y - u_base_coords.y);

The #define aliases route both names to u_resolution_scale-based
arithmetic, identical to what the literal-baked constants
expanded to for any given m_resolution_scale. The shader body is
unchanged.

Variant axis dropped: vram_write_ps previously had PGXP_DEPTH
(2) x use_ssbo (2) x m_resolution_scale (N) variants. After this
commit it's 4 variants (PGXP_DEPTH x use_ssbo) regardless of
the current resolution scale.

Files:

* gpu_hw_shadergen.cpp: GenerateVRAMWriteFragmentShader reordered
  so DeclareUniformBuffer runs before WriteCommonFunctions(ss,
  true). u_resolution_scale + u_pad0 appended to the cbuffer
  member list. WriteCBufferResolutionScaleAliases call inserted
  between the cbuffer and WriteCommonFunctions.
* gpu_hw.h: VRAMWriteUBOData grows by 8 bytes (u_resolution_scale
  + u_pad0). 36 -> 44 bytes total. The HLSL/GLSL compiler rounds
  the cbuffer up to a multiple of 16 internally (48 bytes
  visible to the shader), but we only upload sizeof(struct) =
  44 bytes via the runtime push - the shader never reads beyond
  u_resolution_scale at offset 36-39, so the trailing 4 bytes
  the GPU view sees but we don't push are never accessed.
* gpu_hw.cpp: GetVRAMWriteUBOData populates the two new fields.
  m_resolution_scale into u_resolution_scale; 0 into u_pad0.

Cross-backend compat: same as vram_copy_ps (e56d4d4). D3D11 /
OpenGL upload via runtime sizeof; D3D12 / Vulkan use root /
push constants and have MAX_PUSH_CONSTANTS_SIZE = 64 byte
ceiling (44 fits with headroom).

Shader-cache invalidation: vram_write_ps's source string changes
on every backend - first boot after this lands re-compiles all
4 (PGXP x use_ssbo) variants once, subsequent boots hit the
regenerated cache entries.

Test: VRAM writes (which run on every game's framebuffer
update path - so every frame in practice) render correctly at
every resolution scale. The coords / offset math in the body
is the heaviest user of RESOLUTION_SCALE / VRAM_SIZE across
the non-batch shader family, so this is the strongest validation
that the alias plumbing is correct. If u_resolution_scale
weren't populated, dst_x / dst_y / offset computations would be
wrong and games would render with VRAM offsets off by a factor
of m_resolution_scale - visible immediately as garbled
framebuffers.

Next: vram_read_ps (RESOLUTION_SCALE in the box-filter loop
bounds) and display_ps (RESOLUTION_SCALE for chroma sampling
coords + the box-filter downsampling on 24-bit modes). After
those, the only remaining non-batch shader using compile-time-
baked RESOLUTION_SCALE will be the adaptive_downsample family,
which is a separate concern.
2026-05-18 21:10:59 +02:00
CMakeModules Remove unused files 2023-03-25 17:43:35 +01:00
data/shaders core/d3d12: pre-bake the copy/blit pixel shader 2026-05-18 20:22:17 +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: route RESOLUTION_SCALE through vram_write_ps cbuffer 2026-05-18 21:10:59 +02:00
tools core/d3d12: scaffolding for pre-baked DXBC blobs 2026-05-18 09:14:52 +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 core/d3d12: scaffolding for pre-baked DXBC blobs 2026-05-18 09:14:52 +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.