- C++ 58.5%
- C 36.8%
- Rust 2%
- HLSL 0.7%
- GLSL 0.6%
- Other 1.2%
Patch 14 in the glslang-elimination series. Second slice of the
batch FS conversion: the textured + Nearest-filter path
(texture_mode != Disabled AND m_texture_filter == Nearest). The
runtime decision in GetBatchFragmentShader now routes both the
untextured slice (patch 13) and this slice through the embedded
blob set; only textured non-Nearest still goes through
shadergen + glslang.
Five SPIR-V-structural axes (48 blobs total = 3 x 2 x 2 x 2 x 2):
- Input interpolation qualifier (none / centroid / sample). 3.
- Color input perspective (standard / noperspective). 2.
- Dual-source output (1 vs 2 outputs). 2.
- PGXP depth output (writes gl_FragDepth or omits it). 2.
- UV limits (without / with v_uv_limits flat input). 2.
The UV_LIMITS axis is new vs the untextured slice - it controls
whether v_uv_limits is declared as a per-vertex flat input on the
FS, matching the per-session m_using_uv_limits choice that already
drives the matching batch VS structural pick. Without UV limits the
FS skips the per-sample clamp.
Three new per-call specialisation constants relative to the
untextured slice cover the textured texture_mode encoding:
id = 107 PALETTE_4_BIT (bool, actual_texture_mode == 0)
id = 108 PALETTE_8_BIT (bool, actual_texture_mode == 1)
id = 109 RAW_TEXTURE (bool, RawTextureBit set in texture_mode)
PALETTE = PALETTE_4_BIT || PALETTE_8_BIT is derived inside the
shader. The texture_mode bit layout is described in
src/core/gpu_types.h; the C++ side derives the three boolean spec
const values from the per-call texture_mode in GetBatchPipeline.
Untextured blobs do not declare 107-109; passing them is harmless
per the Vulkan spec (unrecognised spec const IDs in the supplied
VkSpecializationInfo are silently dropped).
The shader body covers the helpers the shadergen path inlines:
ApplyTextureWindow, ApplyUpscaledTextureWindow, FloatToIntegerCoords,
RGBA8ToRGBA5551, and SampleFromVRAM. SampleFromVRAM splits on the
derived PALETTE flag and, within the palette branch, on
PALETTE_4_BIT vs PALETTE_8_BIT to do the correct sub-texel address
arithmetic. fixYCoord on Vulkan is the identity function so we use
the coord directly. The Vulkan-only API_VULKAN-y-flip in the VS
already accounts for sample-space orientation.
Output and discard logic mirrors the shadergen TEXTURED branches:
the no-TRANSPARENCY case writes o_col0 (and o_col1 when DUAL_SOURCE)
unconditionally; the TRANSPARENCY case branches on the texel's
semitransparency bit and applies the TRANSPARENCY_ONLY_OPAQUE /
TRANSPARENCY_ONLY_TRANSPARENT per-texel discard the way the
shadergen does.
Helper-side index encoding for the 48-blob array, matching
GetBatchTexturedNearestFragmentShaderBlob in embedded_shaders.cpp:
interp = per_sample_shading ? 2 : (msaa ? 1 : 0) (0..2)
persp = noperspective_color ? 1 : 0 (0..1)
dual = dual_source ? 1 : 0 (0..1)
pgxp = pgxp_depth ? 1 : 0 (0..1)
uv = uv_limits ? 1 : 0 (0..1)
index = interp*16 + persp*8 + dual*4 + pgxp*2 + uv (0..47)
The use_dual_source derivation in GetBatchFragmentShader matches
the shadergen-side check exactly: supports_dual_source_blend &&
((render_mode is transparent) || filter != Nearest). For the two
embedded branches (untextured and textured Nearest) the filter-half
of the OR evaluates false, so both branches fall through to the
render_mode test.
Smoke tests:
- g++ -fsyntax-only on the touched common TU.
- spirv-val --target-env vulkan1.0 on all 48 blobs - 48/48 valid.
- Total .inc size: ~2.2 MiB across all 48 blobs (~46 KiB each in
text form, which is the 0xNNNNNNNNu, packed layout from the regen
tool; binary contribution to the linked output is roughly 1/4 of
that, so ~550 KiB. Acceptable for a renderer that previously
pulled in glslang at runtime).
- --target-env vulkan1.0 vs un-flagged glslangValidator: byte-
identical for every variant.
Test priority:
- Routine smoke under Enabled / Lazy / Disabled with Nearest
filter (the default). Any textured polygon in any game now
exercises the embedded path: dialogue portraits, sprite layers,
background textures - the vast majority of pixels in most
games.
- Toggle PGXP UV correction (drives m_using_uv_limits) to flip
the UV_LIMITS structural axis. Games that benefit most from
PGXP corrections - Final Fantasy series, Tekken 3, Soul Blade -
are good exercise targets.
- Antialiasing toggle round-trip under Disabled mode per the
patch-5-fix protocol (flips interpolation axis).
- Each texture mode is exercised by different draws: palette
textures dominate (most game art is 4-bit indexed), with
direct-16bpp showing up for render-to-texture effects. Raw
textures appear in framebuffer effects and some UI passes.
- Cross-check with shadergen path by switching texture filter to
Bilinear (still on the shadergen path) and back to Nearest -
rendering should remain consistent across the switch.
After this lands, the only remaining glslang consumers in the
Vulkan backend are the texture-filter slices (Bilinear /
BilinearBinAlpha, JINC2 / JINC2BinAlpha, xBR / xBRBinAlpha). Each
of those filter families has its own FilteredSampleFromVRAM body
and will get its own template in subsequent patches.
|
||
|---|---|---|
| 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.