Skip to content

Commit 399ff31

Browse files
committed
duckstation-unofficial: init at 0.1-9384
This is a revitalization of the now defunct `duckstation` package that preceded this one which tracked the earlier GPL3 licensed version of Duckstation before it's removal in NixOS#430501 (revision: f5cb574)
1 parent c6c6d0b commit 399ff31

File tree

4 files changed

+356
-0
lines changed

4 files changed

+356
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 19e094e5c7aaaf375a13424044521701e85c8313 Mon Sep 17 00:00:00 2001
2+
From: OPNA2608 <[email protected]>
3+
Date: Thu, 9 Jan 2025 17:46:25 +0100
4+
Subject: [PATCH] Fix usage of NEON intrinsics
5+
6+
---
7+
src/common/gsvector_neon.h | 12 ++++++------
8+
1 file changed, 6 insertions(+), 6 deletions(-)
9+
10+
diff --git a/src/common/gsvector_neon.h b/src/common/gsvector_neon.h
11+
index e4991af5e..61b8dc09b 100644
12+
--- a/src/common/gsvector_neon.h
13+
+++ b/src/common/gsvector_neon.h
14+
@@ -867,7 +867,7 @@ public:
15+
16+
ALWAYS_INLINE int mask() const
17+
{
18+
- const uint32x2_t masks = vshr_n_u32(vreinterpret_u32_s32(v2s), 31);
19+
+ const uint32x2_t masks = vshr_n_u32(vreinterpret_u32_f32(v2s), 31);
20+
return (vget_lane_u32(masks, 0) | (vget_lane_u32(masks, 1) << 1));
21+
}
22+
23+
@@ -2882,7 +2882,7 @@ public:
24+
ALWAYS_INLINE GSVector4 gt64(const GSVector4& v) const
25+
{
26+
#ifdef CPU_ARCH_ARM64
27+
- return GSVector4(vreinterpretq_f32_f64(vcgtq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
28+
+ return GSVector4(vreinterpretq_f32_u64(vcgtq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
29+
#else
30+
GSVector4 ret;
31+
ret.U64[0] = (F64[0] > v.F64[0]) ? 0xFFFFFFFFFFFFFFFFULL : 0;
32+
@@ -2894,7 +2894,7 @@ public:
33+
ALWAYS_INLINE GSVector4 eq64(const GSVector4& v) const
34+
{
35+
#ifdef CPU_ARCH_ARM64
36+
- return GSVector4(vreinterpretq_f32_f64(vceqq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
37+
+ return GSVector4(vreinterpretq_f32_u64(vceqq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
38+
#else
39+
GSVector4 ret;
40+
ret.U64[0] = (F64[0] == v.F64[0]) ? 0xFFFFFFFFFFFFFFFFULL : 0;
41+
@@ -2906,7 +2906,7 @@ public:
42+
ALWAYS_INLINE GSVector4 lt64(const GSVector4& v) const
43+
{
44+
#ifdef CPU_ARCH_ARM64
45+
- return GSVector4(vreinterpretq_f32_f64(vcgtq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
46+
+ return GSVector4(vreinterpretq_f32_u64(vcgtq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
47+
#else
48+
GSVector4 ret;
49+
ret.U64[0] = (F64[0] < v.F64[0]) ? 0xFFFFFFFFFFFFFFFFULL : 0;
50+
@@ -2918,7 +2918,7 @@ public:
51+
ALWAYS_INLINE GSVector4 ge64(const GSVector4& v) const
52+
{
53+
#ifdef CPU_ARCH_ARM64
54+
- return GSVector4(vreinterpretq_f32_f64(vcgeq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
55+
+ return GSVector4(vreinterpretq_f32_u64(vcgeq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
56+
#else
57+
GSVector4 ret;
58+
ret.U64[0] = (F64[0] >= v.F64[0]) ? 0xFFFFFFFFFFFFFFFFULL : 0;
59+
@@ -2930,7 +2930,7 @@ public:
60+
ALWAYS_INLINE GSVector4 le64(const GSVector4& v) const
61+
{
62+
#ifdef CPU_ARCH_ARM64
63+
- return GSVector4(vreinterpretq_f32_f64(vcleq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
64+
+ return GSVector4(vreinterpretq_f32_u64(vcleq_f64(vreinterpretq_f64_f32(v4s), vreinterpretq_f64_f32(v.v4s))));
65+
#else
66+
GSVector4 ret;
67+
ret.U64[0] = (F64[0] <= v.F64[0]) ? 0xFFFFFFFFFFFFFFFFULL : 0;
68+
--
69+
2.47.0
70+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/src/scmversion/gen_scmversion.sh b/src/scmversion/gen_scmversion.sh
2+
index 9122cd8..50ed8f9 100755
3+
--- a/src/scmversion/gen_scmversion.sh
4+
+++ b/src/scmversion/gen_scmversion.sh
5+
@@ -10,10 +10,10 @@ else
6+
fi
7+
8+
9+
-HASH=$(git rev-parse HEAD)
10+
-BRANCH=$(git rev-parse --abbrev-ref HEAD | tr -d '\r\n')
11+
-TAG=$(git describe --dirty | tr -d '\r\n')
12+
-DATE=$(git log -1 --date=iso8601-strict --format=%cd)
13+
+HASH="@gitHash@"
14+
+BRANCH="@gitBranch@"
15+
+TAG="@gitTag@"
16+
+DATE="@gitDate@"
17+
18+
cd $CURDIR
19+
Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,233 @@
1+
{
2+
lib,
3+
llvmPackages,
4+
fetchFromGitHub,
5+
cmake,
6+
pkg-config,
7+
ninja,
8+
extra-cmake-modules,
9+
wayland-scanner,
10+
makeBinaryWrapper,
11+
qt6,
12+
sdl3,
13+
zstd,
14+
libwebp,
15+
zlib,
16+
libpng,
17+
libjpeg,
18+
freetype,
19+
plutosvg,
20+
cpuinfo,
21+
discord-rpc,
22+
soundtouch,
23+
cubeb,
24+
libzip,
25+
curl,
26+
libX11,
27+
wayland,
28+
shaderc,
29+
spirv-cross,
30+
udev,
31+
libbacktrace,
32+
ffmpeg-headless,
33+
nix-update-script,
34+
}:
35+
36+
llvmPackages.stdenv.mkDerivation (finalAttrs: {
37+
pname = "duckstation-unofficial";
38+
version = "0.1-9384";
39+
40+
src = fetchFromGitHub {
41+
owner = "stenzek";
42+
repo = "duckstation";
43+
rev = "v${finalAttrs.version}";
44+
hash = "sha256-Iwj+essyjgd5fo9lnNwaBc2N6UVfVlx3zHWlFS8MYqQ=";
45+
deepClone = true;
46+
47+
postFetch = ''
48+
cd $out
49+
mkdir -p .nixpkgs-auxfiles/
50+
git rev-parse HEAD > .nixpkgs-auxfiles/git_hash
51+
git rev-parse --abbrev-ref HEAD | tr -d '\r\n' > .nixpkgs-auxfiles/git_branch
52+
git describe --dirty | tr -d '\r\n' > .nixpkgs-auxfiles/git_tag
53+
git log -1 --date=iso8601-strict --format=%cd > .nixpkgs-auxfiles/git_date
54+
find $out -name .git -print0 | xargs -0 rm -fr
55+
'';
56+
};
57+
58+
patches = [
59+
# Patching yet another script that fills data based on git commands . . .
60+
./hardcode-vars.patch
61+
# Fix NEON intrinsics usage
62+
./fix-NEON-intrinsics.patch
63+
# un-vendor cubeb
64+
./remove-cubeb-vendor.patch
65+
];
66+
67+
postPatch = ''
68+
gitHash=$(cat .nixpkgs-auxfiles/git_hash) \
69+
gitBranch=$(cat .nixpkgs-auxfiles/git_branch) \
70+
gitTag=$(cat .nixpkgs-auxfiles/git_tag) \
71+
gitDate=$(cat .nixpkgs-auxfiles/git_date) \
72+
substituteAllInPlace src/scmversion/gen_scmversion.sh
73+
'';
74+
75+
vendorDiscordRPC = discord-rpc.overrideAttrs (oldAttrs: {
76+
pname = "discord-rpc-duckstation";
77+
version = "3.4.0-unstable-2025-03-30";
78+
src = fetchFromGitHub {
79+
owner = "stenzek";
80+
repo = "discord-rpc";
81+
rev = "cc59d26d1d628fbd6527aac0ac1d6301f4978b92";
82+
hash = "sha256-8xXcx5w36eiJqtWm6qQfhEHgchVJbhP/jR94eMNNjHU=";
83+
};
84+
patches = oldAttrs.patches or [ ];
85+
});
86+
87+
vendorSoundtouch = soundtouch.overrideAttrs (oldAttrs: {
88+
pname = "soundtouch-duckstation";
89+
version = "2.3.3-unstable-2025-10-01";
90+
91+
src = fetchFromGitHub {
92+
owner = "stenzek";
93+
repo = "soundtouch";
94+
rev = "b281fda49645c158c2085e1f2e0c3b82c84379ac";
95+
hash = "sha256-RrGxZ2mJO4wi4kCgvATajd7rxqs2M8VRkZNow30kV+0=";
96+
};
97+
98+
nativeBuildInputs = [ cmake ];
99+
100+
preConfigure = null;
101+
});
102+
103+
vendorShaderc = shaderc.overrideAttrs (oldAttrs: {
104+
pname = "shaderc-duckstation";
105+
version = "2025.2-unstable-2025-04-25";
106+
src = fetchFromGitHub {
107+
owner = "stenzek";
108+
repo = "shaderc";
109+
rev = "4daf9d466ad00897f755163dd26f528d14e1db44";
110+
hash = "sha256-/o3LPYvMTlKhuvLQITnADmz8BTGXVaVR0aciOWVyFS8=";
111+
};
112+
113+
patches = (oldAttrs.patches or [ ]);
114+
cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [
115+
(lib.cmakeBool "SHADERC_SKIP_EXAMPLES" true)
116+
(lib.cmakeBool "SHADERC_SKIP_TESTS" true)
117+
];
118+
outputs = [
119+
"out"
120+
"lib"
121+
"dev"
122+
];
123+
postFixup = null;
124+
});
125+
126+
vendorSpirvCross = spirv-cross.overrideAttrs (oldAttrs: {
127+
pname = "spirv-cross-duckstation";
128+
patches = (oldAttrs.patches or [ ]);
129+
cmakeFlags = (oldAttrs.cmakeFlags or [ ]) ++ [
130+
(lib.cmakeBool "SPIRV_CROSS_CLI" false)
131+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_CPP" false)
132+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_C_API" true)
133+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_GLSL" true)
134+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_HLSL" false)
135+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_MSL" false)
136+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_REFLECT" false)
137+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_TESTS" false)
138+
(lib.cmakeBool "SPIRV_CROSS_ENABLE_UTIL" true)
139+
(lib.cmakeBool "SPIRV_CROSS_SHARED" true)
140+
(lib.cmakeBool "SPIRV_CROSS_STATIC" false)
141+
];
142+
});
143+
144+
nativeBuildInputs = [
145+
cmake
146+
pkg-config
147+
ninja
148+
extra-cmake-modules
149+
wayland-scanner
150+
makeBinaryWrapper
151+
qt6.wrapQtAppsHook
152+
qt6.qttools
153+
];
154+
155+
buildInputs = [
156+
sdl3
157+
zstd
158+
libwebp
159+
zlib
160+
libpng
161+
libjpeg
162+
freetype
163+
plutosvg
164+
cubeb
165+
cpuinfo
166+
libzip
167+
curl
168+
libX11
169+
wayland
170+
qt6.qtbase
171+
udev
172+
libbacktrace
173+
ffmpeg-headless
174+
]
175+
++ [
176+
finalAttrs.vendorDiscordRPC
177+
finalAttrs.vendorShaderc
178+
finalAttrs.vendorSoundtouch
179+
finalAttrs.vendorSpirvCross
180+
];
181+
182+
cmakeFlags = [
183+
(lib.cmakeBool "ALLOW_INSTALL" true)
184+
(lib.cmakeFeature "CMAKE_INSTALL_PREFIX" "${placeholder "out"}/lib/duckstation")
185+
];
186+
187+
qtWrapperArgs = [
188+
"--prefix LD_LIBRARY_PATH : ${(lib.makeLibraryPath [ ffmpeg-headless ])}"
189+
];
190+
191+
postInstall = ''
192+
makeWrapper $out/lib/duckstation/duckstation-qt $out/bin/duckstation-qt
193+
194+
mkdir -p $out/share/applications/
195+
ln -s $out/lib/duckstation/resources/org.duckstation.DuckStation.desktop \
196+
$out/share/applications/
197+
198+
mkdir -p $out/share/icons/hicolor/scalable/apps/
199+
ln -s $out/lib/duckstation/resources/org.duckstation.DuckStation.png \
200+
$out/share/icons/hicolor/scalable/apps/
201+
202+
pushd ..
203+
install -Dm644 LICENSE -t $out/share/doc/duckstation
204+
install -Dm644 README.* -t $out/share/doc/duckstation
205+
install -Dm644 CONTRIBUTORS.md -t $out/share/doc/duckstation
206+
popd
207+
'';
208+
209+
passthru = {
210+
updateScript = nix-update-script {
211+
extraArgs = [ "--version-regex=(v[0-9].[0-9]-[0-9]+)" ];
212+
};
213+
};
214+
215+
meta = {
216+
description = "Fast PlayStation 1 emulator for x86-64/AArch32/AArch64/RV64";
217+
longDescription = ''
218+
# DISCLAIMER
219+
This is an **unofficial** package, do not report any issues to
220+
duckstation developers. Instead, please report them to
221+
<https://github.com/NixOS/nixpkgs> or use the officially
222+
supported platform build at <https://duckstation.org> or other
223+
upstream-approved distribution mechanism not listed here. We
224+
(nixpkgs) do not endorse or condone any action taken on your own
225+
accord in regards to this package.
226+
'';
227+
homepage = "https://duckstation.org/";
228+
license = lib.licenses.cc-by-nc-nd-40;
229+
maintainers = with lib.maintainers; [ normalcea ];
230+
mainProgram = "duckstation-qt";
231+
platforms = lib.platforms.linux;
232+
};
233+
})
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
diff --git a/dep/CMakeLists.txt b/dep/CMakeLists.txt
2+
index 633267c66..8f9c65c39 100644
3+
--- a/dep/CMakeLists.txt
4+
+++ b/dep/CMakeLists.txt
5+
@@ -25,9 +25,9 @@ add_subdirectory(rcheevos EXCLUDE_FROM_ALL)
6+
disable_compiler_warnings_for_target(rcheevos)
7+
add_subdirectory(rapidyaml EXCLUDE_FROM_ALL)
8+
disable_compiler_warnings_for_target(rapidyaml)
9+
-add_subdirectory(cubeb EXCLUDE_FROM_ALL)
10+
-disable_compiler_warnings_for_target(cubeb)
11+
-disable_compiler_warnings_for_target(speex)
12+
+find_package(cubeb REQUIRED GLOBAL)
13+
+add_library(cubeb ALIAS cubeb::cubeb)
14+
+# disable_compiler_warnings_for_target(speex)
15+
16+
if(ENABLE_OPENGL)
17+
add_subdirectory(glad EXCLUDE_FROM_ALL)
18+
diff --git a/src/util/cubeb_audio_stream.cpp b/src/util/cubeb_audio_stream.cpp
19+
index e01cbfe78..294c6e59d 100644
20+
--- a/src/util/cubeb_audio_stream.cpp
21+
+++ b/src/util/cubeb_audio_stream.cpp
22+
@@ -261,9 +261,9 @@ std::vector<std::pair<std::string, std::string>> AudioStream::GetCubebDriverName
23+
std::vector<std::pair<std::string, std::string>> names;
24+
names.emplace_back(std::string(), TRANSLATE_STR("AudioStream", "Default"));
25+
26+
- const char** cubeb_names = cubeb_get_backend_names();
27+
- for (u32 i = 0; cubeb_names[i] != nullptr; i++)
28+
- names.emplace_back(cubeb_names[i], cubeb_names[i]);
29+
+ cubeb_backend_names cubeb_names = cubeb_get_backend_names();
30+
+ for (u32 i = 0; i < cubeb_names.count; i++)
31+
+ names.emplace_back(cubeb_names.names[i], cubeb_names.names[i]);
32+
return names;
33+
}
34+

0 commit comments

Comments
 (0)