- C++ 58.4%
- C 36.7%
- Rust 2.2%
- HLSL 0.7%
- GLSL 0.6%
- Other 1.2%
Wires the existing D3D12 hardware renderer (src/core/gpu_hw_d3d12.cpp,
src/common/d3d12/*) into the libretro frontend, behind a USE_D3D12=1
gate. The opt-in is because:
1. retro_hw_render_interface_d3d12 is supported by recent RetroArch
builds but not all of them - the SET_HW_RENDER environment call
will fail at runtime where unsupported.
2. Not every Windows target ships d3d12.lib in its toolchain; the
gate keeps the existing default Windows build path working.
When USE_D3D12=1 is set on the make command line, the libretro
Makefile pulls in the seven common/d3d12 TUs, gpu_hw_d3d12.cpp, the
new LibretroD3D12HostDisplay class, links against d3d12.lib, and
exposes "D3D12" in the renderer dropdown next to D3D11.
== src/common/d3d12 ==
D3D12::Context grew a CreateForLibretro(device, command_queue)
static factory next to its existing Create(dxgi_factory, ...). The
libretro path adopts the frontend's device + command queue (the
frontend retains ownership; we just AddRef them via ComPtr) and
then creates only the resources we own: fence, descriptor heaps,
command lists, texture upload stream buffer. Feature level is
pinned at FL11_0; the gpu_hw_d3d12 shader/PSO setup targets that
baseline. CreateForLibretro still loads d3d12.dll because
PFN_D3D12_SERIALIZE_ROOT_SIGNATURE is needed by
Context::SerializeRootSignature, which gpu_hw_d3d12.cpp uses on
initial root-signature creation.
Destroy() is unchanged; the borrowed device/queue ComPtrs simply
release their AddRef in the Context destructor and the frontend
keeps the underlying objects alive.
== src/core/gpu_hw_d3d12.h, .cpp ==
Added LibretroD3D12HostDisplay (declaration in the header above
GPU_HW_D3D12, implementation appended ahead of GPU_HW_D3D12's
constructor body in the .cpp). The class mirrors
LibretroD3D11HostDisplay's surface and behaves identically on
the libretro-API side, with two differences driven by the D3D12
libretro interface contract:
1. There is no analogue to ID3D11DeviceContext in D3D12 - work
is recorded on command lists owned by D3D12::Context. The
class therefore does not store m_device / m_context members;
callers that need the device go through
g_d3d12_context->GetDevice() as the rest of gpu_hw_d3d12.cpp
already does. GetRenderDevice() returns
g_d3d12_context->GetDevice() for HostDisplay-API callers;
GetRenderContext() returns nullptr.
2. Present is the retro_hw_render_interface_d3d12::set_texture
callback rather than a swapchain blit. LibretroD3D12HostDisplay
::Render() transitions the GPU_HW_D3D12-produced display
texture into the frontend's required_state, flushes our
pending command list via ExecuteCommandList(false), calls
set_texture(frontend_handle, ID3D12Resource*, format), then
signals the frontend a HW frame is ready via
g_retro_video_refresh_callback(RETRO_HW_FRAME_BUFFER_VALID,
width, height, 0). The frame-dupe (NULL) path for runahead /
fast-forward video skip is identical to the D3D11 and SW
renderer paths.
The CreateTexture / BeginSetDisplayPixels / EndSetDisplayPixels
paths return nullptr / false the same way LibretroHostDisplay
does. They are not exercised on the libretro D3D12 path - GPU_HW
_D3D12 owns its own D3D12::Texture instances directly, and the
SW renderer (which is the only path that would BeginSetDisplay
Pixels) uses LibretroHostDisplay rather than going through D3D12.
An m_framebuffer member is reserved on the class for future
software-cursor / lightgun-crosshair overlay work (which would
composite over the display texture in an owned RTV before
set_texture, the way gpu_hw_d3d11.cpp does it). For the initial
wire-up the present path forwards the GPU_HW_D3D12 display
texture directly.
HAVE_D3D12 is #define'd before the libretro_d3d.h include to
pull in the retro_hw_render_interface_d3d12 struct definition,
matching the equivalent pattern in gpu_hw_d3d11.cpp.
== src/libretro/libretro_host_interface.cpp ==
Four switch cases extended, all under #ifdef WIN32 + #ifdef USE
_D3D12:
- RetroHwContextToRenderer: maps RETRO_HW_CONTEXT_D3D12 = 9 to
GPURenderer::HardwareD3D12 so the Auto-renderer path picks D3D12
when the frontend advertises it via GET_PREFERRED_HW_RENDER.
- RenderAPIToRenderer: maps HostDisplay::RenderAPI::D3D12 to
GPURenderer::HardwareD3D12 so reusing an existing hardware
display across SwitchToHardwareRenderer rebinds correctly.
- RequestHardwareRendererContext: calls
LibretroD3D12HostDisplay::RequestHardwareRendererContext
(sets context_type=RETRO_HW_CONTEXT_D3D12, version_major=12,
version_minor=0).
- SwitchToHardwareRenderer: instantiates LibretroD3D12HostDisplay
when m_hw_render_callback.context_type indicates D3D12.
Include line added for gpu_hw_d3d12.h alongside the existing
gpu_hw_d3d11.h include.
== src/libretro/libretro_core_options.h ==
Renderer dropdown gains {"D3D12", "Hardware (D3D12)"} entry,
gated USE_D3D12 inside the existing WIN32 block. Settings
::ParseRendererName already had D3D12 in its s_gpu_renderer
_names array (pre-existing), and Settings::GetRendererName
reads from the same array, so the dropdown selection round-trips
to/from GPURenderer::HardwareD3D12 correctly.
== Makefile.libretro ==
Under the existing IS_WINDOWS guard, added a USE_D3D12=1 branch
that:
- Adds -DUSE_D3D12=1 to CXXFLAGS so the wiring under #ifdef USE
_D3D12 in libretro_host_interface.cpp, libretro_core_options.h,
gpu_hw_d3d12.cpp, and gpu_hw_d3d12.h gets compiled in.
- Adds -ld3d12 to LDFLAGS so PFN_D3D12_SERIALIZE_ROOT_SIGNATURE
resolves at link time (Context::SerializeRootSignature uses it).
- Adds the seven common/d3d12 TUs (context, descriptor_heap_
manager, shader_cache, staging_texture, stream_buffer, texture,
util) to SOURCES_CXX.
- Adds src/core/gpu_hw_d3d12.cpp to SOURCES_CXX in the core
section.
Default (no USE_D3D12=1) keeps the existing Windows build
unchanged. system.cpp's renderer dispatch already had the case
GPURenderer::HardwareD3D12 case behind #ifdef USE_D3D12 and the
forward declaration of GPU::CreateHardwareD3D12Renderer() was
already in gpu.h, so no changes were needed there.
== Build verification ==
Linux libretro build: clean, .so unchanged at 7,905,720 bytes (all
new D3D12 code is gated under WIN32 + USE_D3D12 - no compiled-in
effect on non-Windows targets), 25 retro_ exports preserved.
Windows build with USE_D3D12=1 has not been verified in this
environment - mingw cross-compile tools and the d3d12 SDK headers
aren't available on the build host. Manual test on Windows
required before pushing.
7 files changed, 414 insertions(+).
|
||
|---|---|---|
| CMakeModules | ||
| dep | ||
| src | ||
| .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.