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 3df285a10e core/d3d12: regenerate embedded DXBC with Microsoft fxc
Regenerates fullscreen_quad_vs.inc and copy_ps.inc from their
existing .hlsl sources using Microsoft's actual D3DCompile API
(via Wine + Microsoft's d3dcompiler_47.dll), not Wine's bundled
vkd3d-shader reimplementation. The .hlsl sources are unchanged
in this commit; only the compiled bytecode rotates.

Toolchain setup (contributor side, Linux):

* Microsoft's d3dcompiler_47.dll is dropped next to the
  fxc.exe-compatible front-end so Wine's loader (which always
  searches the application directory first) picks up Microsoft's
  compiler before falling back to its bundled vkd3d-shader
  implementation. The d3dcompiler_47.dll used here is a stock
  Microsoft binary (verified via the embedded "Microsoft (R)
  HLSL Shader Compiler 10.1" version string in the file's
  resource section); redistribution is covered by Microsoft's
  Windows SDK license. mozilla/fxc2 ships the same DLL on
  GitHub for the same reason.
* Wine remains 9.0; no other Wine config changes.

Output deltas vs the prior vkd3d-shader-compiled .inc files:

  fullscreen_quad_vs.inc  828B (vkd3d) -> 736B (Microsoft)
                          chunks ISGN/OSGN/RDEF/SHDR
                            ->   RDEF/ISGN/OSGN/SHEX/STAT

  copy_ps.inc             808B (vkd3d) -> 848B (Microsoft)
                          chunks ISGN/OSGN/RDEF/SHDR
                            ->   RDEF/ISGN/OSGN/SHEX/STAT

The chunk-set delta is the load-bearing piece. Microsoft's fxc
emits SHEX (the Shader Model 5.0+ extended bytecode chunk) and
STAT (compiler-stats metadata) in addition to RDEF / ISGN /
OSGN. Wine's vkd3d-shader 1.10 emits SHDR (the older SM 4.0
bytecode chunk) and omits STAT entirely. The Microsoft D3D12
runtime is happy with either for simple shaders - that's why
the original ca8c9b0 / dd54a73 / 443a2a1 pre-bakes with
vkd3d-shader-compiled blobs worked - but as commit cd971cd
demonstrated, the moment the shader uses features whose
validation paths in D3D12 require SHEX-format metadata
(SV_Depth output combined with conditional discard and a
non-trivial cbuffer, in that specific case), the vkd3d-shader
output is rejected by CreateGraphicsPipelineState with E_FAIL.
Regenerating with Microsoft's compiler removes the entire
class of failures.

Creator-string change visible in the .inc top-of-file comment:

  "vkd3d-shader 1.10 (Wine bundled)"
    -> "Microsoft (R) HLSL Shader Compiler 10.1"

The validator added in ebd2300 (check_microsoft_creator in
tools/regen_d3d12_dxbc.py) refused vkd3d-shader-stamped output
post-hoc; this commit produces the Microsoft-stamped equivalent
that passes that check. Future regens going forward will continue
to use Microsoft's compiler.

This commit deliberately changes only the .inc bytes. Validator
runs cleanly on both regenerated blobs; the runtime path is
unchanged (.inc files compile as plain C++ byte arrays, no
build-side fxc.exe invocation). The two pre-baked shaders that
already ship - fullscreen-quad VS (every non-batch pipeline)
and copy/blit PS (presentation copies, downscale) - are the
load-bearing test cases. If the regenerated blobs don't pass
PSO validation, D3D12 backend init fails the same way cd971cd
did, and the diff is small enough to bisect cleanly.

The vram_copy pre-bake that cd971cd / da20f5b chronicles can
now be re-attempted on this toolchain - that's a follow-up
commit. Same .hlsl source as before, but compiled with the
Microsoft path here; the resulting blob will have the SHEX/STAT
chunks that the cd971cd attempt was missing, and the PSO
validation that failed before should now pass.

Test:
  - Run the regen script under wine + Microsoft d3dcompiler_47.dll:
    python3 tools/regen_d3d12_dxbc.py --fxc fxc_lite.exe --wine wine
    Output: "regenerated 2 .inc file(s)" with no validator errors.
  - Parse the regenerated .inc files post-hoc to confirm the
    chunk set (RDEF, ISGN, OSGN, SHEX, STAT) and creator
    ("Microsoft (R) HLSL Shader Compiler 10.1").
  - Lib-side: rebuild swanstation, launch with D3D12, confirm
    the backend initializes without the cd971cd-style
    "CreateGraphicsPipelineState failed: 80004005" /
    "Failed to compile pipelines" error. The two pre-baked
    shaders are hit during precompile, so the failure mode
    would be obvious at launch.
2026-05-18 22:39:10 +02:00
CMakeModules Remove unused files 2023-03-25 17:43:35 +01:00
data/shaders tools/d3d12: refuse non-Microsoft fxc output in the regen script 2026-05-18 22:16:18 +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/d3d12: regenerate embedded DXBC with Microsoft fxc 2026-05-18 22:39:10 +02:00
tools tools/d3d12: refuse non-Microsoft fxc output in the regen script 2026-05-18 22:16:18 +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.