mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
gamescope: a build of the runtime's 3.16.29 with Armada's ARM64 client fixes and a realtime-queue switch, from Arch's own package in CI
Four of Armada's patches apply to 3.16.29 as they are (appid-focus fallback, ARM64 night mode, ARM64 colour-temperature slider, P3 red); two more are ported by hand: realtime-priority Vulkan queues on GAMESCOPE_FORCE_VULKAN_REALTIME=1 without CAP_SYS_NICE, and the gamepad cursor sprite following the X pointer. build-gamescope.yml builds Arch Linux ARM's package with them in an Arch container, checks every NEEDED library against the runtime's own list, and publishes the binary as a release asset for the apk to stage over /usr/local/bin/gamescope.
This commit is contained in:
1 parent
65b00242d9
commit
687b882983
9 files changed
+2580
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# gamescope patches carried by the app
|
||||
|
||||
Built by `.github/workflows/build-gamescope.yml` on top of the exact gamescope the Linux runtime
|
||||
ships (3.16.29, Arch Linux ARM's package, same build options), and staged from the apk over
|
||||
`/usr/local/bin/gamescope` at each session start - the hosted runtime image is never touched.
|
||||
The binary's shared-library needs are checked against `runtime-sonames.txt`, the runtime's own
|
||||
library list, before anything is published.
|
||||
|
||||
- `0002-steamcompmgr-fallback-appid-focus.patch` - Armada (armada-os/armada), verbatim.
|
||||
- `0009-fix-arm64-steam-night-mode.patch` - Armada, verbatim: the ARM64 client packs the
|
||||
night-mode property differently; the slider did nothing.
|
||||
- `0019-steamcompmgr-arm64-virtual-white.patch` - Armada, verbatim: the colour-temperature
|
||||
slider's (x, y) arrives as one 64-bit element from the ARM64 client; y is recovered from x.
|
||||
- `0020-color-p3-red-is-wide-gamut.patch` - Armada, verbatim.
|
||||
- `0100-realtime-queue-and-gamepad-cursor.patch` - this app, two of Armada's ported by hand onto
|
||||
3.16.29: realtime-priority Vulkan queues on request (`GAMESCOPE_FORCE_VULKAN_REALTIME=1`)
|
||||
without CAP_SYS_NICE, which proot can never have; and the gamepad-driven cursor sprite following
|
||||
the X pointer that XTest moves (it sat frozen).
|
||||
|
||||
Sixteen more of Armada's patches are DRM/lease/HDR-on-KMS work for a native display, which this
|
||||
app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the runtime has.
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/bash
|
||||
# Runs INSIDE an Arch Linux ARM container (menci/archlinuxarm:base-devel) on an arm64 runner.
|
||||
# Builds Arch's own gamescope package of the runtime's version with the patches in ./patches
|
||||
# added, then keeps only the gamescope binary, checks its library needs against the runtime's
|
||||
# list, and packs it as gamescope.tzst (usr/local/bin/gamescope) for the apk to stage.
|
||||
set -euxo pipefail
|
||||
VERSION=${GAMESCOPE_VERSION:-3.16.29}
|
||||
WORK=/work
|
||||
cd "$WORK"
|
||||
pacman -Syu --noconfirm --needed git sudo zstd binutils
|
||||
# makepkg refuses root; a builder user with passwordless sudo installs the dependencies.
|
||||
id builder >/dev/null 2>&1 || useradd -m builder
|
||||
echo 'builder ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builder
|
||||
rm -rf pkg && mkdir pkg && cp -r tools/gamescope/patches pkg/ && chown -R builder pkg
|
||||
# Arch's packaging for exactly this version: the tag is <pkgver>-<pkgrel>; the first rel is tried
|
||||
# first, later ones after it.
|
||||
sudo -u builder bash -c "
|
||||
set -euxo pipefail
|
||||
cd pkg
|
||||
for rel in 1 2 3 4; do
|
||||
if git clone -q --depth 1 --branch ${VERSION}-\$rel https://gitlab.archlinux.org/archlinux/packaging/packages/gamescope.git arch 2>/dev/null; then break; fi
|
||||
done
|
||||
test -f arch/PKGBUILD
|
||||
cd arch
|
||||
grep -q '^pkgver=${VERSION}$' PKGBUILD
|
||||
cp ../patches/*.patch .
|
||||
# Add our patches to the source list and apply them after Arch's own prepare() steps.
|
||||
PATCHES=\$(ls *.patch | sort)
|
||||
{ echo; echo 'source+=('; for p in \$PATCHES; do echo \" \$p\"; done; echo ')'; for p in \$PATCHES; do echo \"sha256sums+=('SKIP')\"; done; } >> PKGBUILD
|
||||
cat >> PKGBUILD <<'PREP'
|
||||
|
||||
_steamdeck_prepare() {
|
||||
cd gamescope
|
||||
for p in \$(ls \"\$srcdir\"/*.patch | sort); do
|
||||
echo \"applying \$(basename \"\$p\")\"
|
||||
patch -p1 --no-backup-if-mismatch < \"\$p\"
|
||||
done
|
||||
}
|
||||
if declare -f prepare >/dev/null; then
|
||||
eval \"\$(declare -f prepare | sed 's/^prepare ()/_arch_prepare ()/')\"
|
||||
prepare() { _arch_prepare; _steamdeck_prepare; }
|
||||
else
|
||||
prepare() { _steamdeck_prepare; }
|
||||
fi
|
||||
PREP
|
||||
makepkg -s --noconfirm --skipchecksums --skippgpcheck
|
||||
ls -l *.pkg.tar.*
|
||||
"
|
||||
cd "$WORK"
|
||||
rm -rf out && mkdir -p out/usr/local/bin
|
||||
PKG=$(ls pkg/arch/gamescope-*.pkg.tar.* | grep -v -- '-debug-' | head -1)
|
||||
tar --use-compress-program=unzstd -xf "$PKG" -C out --strip-components=2 usr/bin/gamescope
|
||||
mv out/gamescope out/usr/local/bin/gamescope
|
||||
chmod 755 out/usr/local/bin/gamescope
|
||||
strip --strip-unneeded out/usr/local/bin/gamescope || true
|
||||
# Every NEEDED library must be one the runtime ships, or the binary would not load there.
|
||||
NEEDED=$(readelf -d out/usr/local/bin/gamescope | sed -n 's/.*NEEDED.*\[\(.*\)\]/\1/p')
|
||||
echo "NEEDED: $NEEDED"
|
||||
MISSING=""
|
||||
for lib in $NEEDED; do grep -qx "$lib" tools/gamescope/runtime-sonames.txt || MISSING="$MISSING $lib"; done
|
||||
if [ -n "$MISSING" ]; then echo "ERROR: not in the runtime:$MISSING"; exit 3; fi
|
||||
(cd out && tar --use-compress-program='zstd -19' -cf ../gamescope.tzst usr)
|
||||
sha256sum gamescope.tzst | tee gamescope.tzst.sha256
|
||||
ls -l gamescope.tzst out/usr/local/bin/gamescope
|
||||
@@ -0,0 +1,36 @@
|
||||
From: virtudude <virtudude@protonmail.com>
|
||||
Subject: [PATCH] steamcompmgr: fallback focus to GAMESCOPE_FALLBACK_APPID
|
||||
|
||||
When no baselayer window is focusable, show the window whose appid equals
|
||||
$GAMESCOPE_FALLBACK_APPID (a boot splash / loading screen opting in via its
|
||||
STEAM_GAME atom). Yields to the real window as soon as one appears. Focus
|
||||
selection only, off the per-frame composite path.
|
||||
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 231e245a..2054a092 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -4251,6 +4251,23 @@ pick_primary_focus_and_override(
|
||||
found:;
|
||||
}
|
||||
|
||||
+ static const uint32_t s_fallbackAppID = []() {
|
||||
+ const char *e = getenv( "GAMESCOPE_FALLBACK_APPID" );
|
||||
+ return e ? (uint32_t)strtoul( e, nullptr, 0 ) : 0u;
|
||||
+ }();
|
||||
+ if ( !focus && s_fallbackAppID )
|
||||
+ {
|
||||
+ for ( steamcompmgr_win_t *fallback_window : vecPossibleFocusWindows )
|
||||
+ {
|
||||
+ if ( fallback_window->appID == s_fallbackAppID )
|
||||
+ {
|
||||
+ focus = fallback_window;
|
||||
+ localGameFocused = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
if ( !focus && ( !globalFocus || !controlledFocus ) )
|
||||
{
|
||||
if ( !vecPossibleFocusWindows.empty() )
|
||||
@@ -0,0 +1,31 @@
|
||||
From 1a8b967a8d4c35457719d94137f2695967a1f7d8 Mon Sep 17 00:00:00 2001
|
||||
From: JPyke3 <github@pyk.ee>
|
||||
Date: Sun, 2 Aug 2026 22:24:43 +1000
|
||||
Subject: [PATCH] steamcompmgr: work around ARM64 Steam night mode property
|
||||
|
||||
---
|
||||
src/steamcompmgr.cpp | 8 ++++++++
|
||||
1 file changed, 8 insertions(+)
|
||||
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index b74b8a7e..f7fb9895 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -7394,9 +7394,17 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
|
||||
}
|
||||
|
||||
nightmode_t nightmode;
|
||||
+
|
||||
+ #if defined (__aarch64__)
|
||||
+ nightmode.amount = vec[0];
|
||||
+ nightmode.hue = 25.0f / 360.0f;
|
||||
+ nightmode.saturation = vec[1];
|
||||
+ #else
|
||||
nightmode.amount = vec[0];
|
||||
nightmode.hue = vec[1];
|
||||
nightmode.saturation = vec[2];
|
||||
+ #endif
|
||||
+
|
||||
|
||||
if ( set_color_nightmode( nightmode ) )
|
||||
hasRepaint = true;
|
||||
@@ -0,0 +1,34 @@
|
||||
From: virtudude <virtudude@protonmail.com>
|
||||
Subject: [PATCH] steamcompmgr: recover the virtual white y on ARM64
|
||||
|
||||
Steam's color temperature slider sets GAMESCOPE_DISPLAY_VIRTUAL_WHITE
|
||||
to a white point (x, y). The ARM64 client passes the two floats as one
|
||||
64-bit property element, so gamescope reads x and a zero y, and a white
|
||||
point with y = 0 is ignored: the slider did nothing on ARM64. The same
|
||||
packing fault is behind the night mode workaround.
|
||||
|
||||
Steam derives the pair from the CIE daylight locus (its 6500 K x is
|
||||
D65's), so when y is missing recover it from x with the locus quadratic,
|
||||
within 0.002 of the true value across the slider's range; outside that
|
||||
range the point is left invalid as before.
|
||||
|
||||
---
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index e54194b..4131467 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -6940,6 +6940,14 @@ handle_property_notify(xwayland_ctx_t *ctx, XPropertyEvent *ev)
|
||||
{
|
||||
g_ColorMgmt.pending.outputVirtualWhite.x = santitize_float( bit_cast<float>( user_vec[0] ) );
|
||||
g_ColorMgmt.pending.outputVirtualWhite.y = santitize_float( bit_cast<float>( user_vec[1] ) );
|
||||
+#if defined(__aarch64__)
|
||||
+ // The ARM64 Steam client packs the pair as one 64-bit element, so only x arrives;
|
||||
+ // Steam derives the pair from the CIE daylight locus, so y follows from x.
|
||||
+ // Drop once the client sends both floats (y arrives non-zero).
|
||||
+ float x = g_ColorMgmt.pending.outputVirtualWhite.x;
|
||||
+ if ( x >= 0.25f && x <= 0.55f && g_ColorMgmt.pending.outputVirtualWhite.y <= 0.01f )
|
||||
+ g_ColorMgmt.pending.outputVirtualWhite.y = -3.0f * x * x + 2.87f * x - 0.275f;
|
||||
+#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -0,0 +1,25 @@
|
||||
From: virtudude <virtudude@protonmail.com>
|
||||
Subject: [PATCH] color: count a DCI-P3 red as wide gamut
|
||||
|
||||
BIsWideGamut() takes a red y below 0.320 as the sign of a wide-gamut
|
||||
panel. DCI-P3 red is exactly (0.680, 0.320), so a panel profiled with P3
|
||||
primaries is treated as narrow and the SDR gamut wideness slider only
|
||||
adjusts clipping instead of mapping between Rec.709 and the native
|
||||
gamut. Make the comparison inclusive.
|
||||
|
||||
---
|
||||
diff --git a/src/color_helpers.cpp b/src/color_helpers.cpp
|
||||
index 64430a5..f4dcd98 100644
|
||||
--- a/src/color_helpers.cpp
|
||||
+++ b/src/color_helpers.cpp
|
||||
@@ -830,8 +830,8 @@ void calcColorTransform( lut1d_t * pShaper, int nLutSize1d,
|
||||
|
||||
bool BIsWideGamut( const displaycolorimetry_t & nativeDisplayOutput )
|
||||
{
|
||||
- // Use red as a sentinal for a wide-gamut display
|
||||
- return ( nativeDisplayOutput.primaries.r.x > 0.650f && nativeDisplayOutput.primaries.r.y < 0.320f );
|
||||
+ // Use red as a sentinal for a wide-gamut display; DCI-P3 red sits exactly on the threshold
|
||||
+ return ( nativeDisplayOutput.primaries.r.x > 0.650f && nativeDisplayOutput.primaries.r.y <= 0.320f );
|
||||
}
|
||||
|
||||
void buildSDRColorimetry( displaycolorimetry_t * pColorimetry, colormapping_t *pMapping,
|
||||
@@ -0,0 +1,106 @@
|
||||
diff --git a/src/rendervulkan.cpp b/src/rendervulkan.cpp
|
||||
index 54e4efc..024af02 100644
|
||||
--- a/src/rendervulkan.cpp
|
||||
+++ b/src/rendervulkan.cpp
|
||||
@@ -538,6 +538,14 @@ bool CVulkanDevice::createDevice()
|
||||
}
|
||||
|
||||
float queuePriorities = 1.0f;
|
||||
+ // Without CAP_SYS_NICE gamescope never asks for realtime-priority queues. Under proot on
|
||||
+ // Android there is no capability to have, but the driver may still grant the priority (Turnip
|
||||
+ // does on Adreno), and the existing fallback below covers a driver that refuses. Opt in with
|
||||
+ // GAMESCOPE_FORCE_VULKAN_REALTIME=1. (Armada's --force-vulkan-realtime, as an environment switch.)
|
||||
+ const char *pszForceRealtime = getenv( "GAMESCOPE_FORCE_VULKAN_REALTIME" );
|
||||
+ const bool useRealtimeVulkanQueue = gamescope::Process::HasCapSysNice() || ( pszForceRealtime && atoi( pszForceRealtime ) != 0 );
|
||||
+ if ( useRealtimeVulkanQueue && !gamescope::Process::HasCapSysNice() )
|
||||
+ fprintf( stderr, "gamescope: requesting realtime-priority Vulkan queues without CAP_SYS_NICE (GAMESCOPE_FORCE_VULKAN_REALTIME)\n" );
|
||||
|
||||
VkDeviceQueueGlobalPriorityCreateInfoEXT queueCreateInfoEXT = {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_GLOBAL_PRIORITY_CREATE_INFO_EXT,
|
||||
@@ -549,14 +557,14 @@ bool CVulkanDevice::createDevice()
|
||||
{
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
- .pNext = gamescope::Process::HasCapSysNice() ? &queueCreateInfoEXT : nullptr,
|
||||
+ .pNext = useRealtimeVulkanQueue ? &queueCreateInfoEXT : nullptr,
|
||||
.queueFamilyIndex = m_queueFamily,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = &queuePriorities
|
||||
},
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
- .pNext = gamescope::Process::HasCapSysNice() ? &queueCreateInfoEXT : nullptr,
|
||||
+ .pNext = useRealtimeVulkanQueue ? &queueCreateInfoEXT : nullptr,
|
||||
.queueFamilyIndex = m_generalQueueFamily,
|
||||
.queueCount = 1,
|
||||
.pQueuePriorities = &queuePriorities
|
||||
@@ -682,14 +690,14 @@ bool CVulkanDevice::createDevice()
|
||||
};
|
||||
|
||||
VkResult res = vk.CreateDevice(physDev(), &deviceCreateInfo, nullptr, &m_device);
|
||||
- if ( res == VK_ERROR_NOT_PERMITTED_KHR && gamescope::Process::HasCapSysNice() )
|
||||
+ if ( res == VK_ERROR_NOT_PERMITTED_KHR && useRealtimeVulkanQueue )
|
||||
{
|
||||
fprintf(stderr, "vkCreateDevice failed with a high-priority queue (general + compute). Falling back to regular priority (general).\n");
|
||||
queueCreateInfos[1].pNext = nullptr;
|
||||
res = vk.CreateDevice(physDev(), &deviceCreateInfo, nullptr, &m_device);
|
||||
|
||||
|
||||
- if ( res == VK_ERROR_NOT_PERMITTED_KHR && gamescope::Process::HasCapSysNice() )
|
||||
+ if ( res == VK_ERROR_NOT_PERMITTED_KHR && useRealtimeVulkanQueue )
|
||||
{
|
||||
fprintf(stderr, "vkCreateDevice failed with a high-priority queue (compute). Falling back to regular priority (all).\n");
|
||||
queueCreateInfos[0].pNext = nullptr;
|
||||
diff --git a/src/steamcompmgr.cpp b/src/steamcompmgr.cpp
|
||||
index 18b799e..16f7846 100644
|
||||
--- a/src/steamcompmgr.cpp
|
||||
+++ b/src/steamcompmgr.cpp
|
||||
@@ -2020,23 +2020,41 @@ MouseCursor::MouseCursor(xwayland_ctx_t *ctx)
|
||||
|
||||
void MouseCursor::UpdatePosition()
|
||||
{
|
||||
+ // The gamepad-driven cursor is moved through XTest, which moves the X pointer and nothing
|
||||
+ // else: wlserver's copy of the position never changes, so the sprite sat frozen while the
|
||||
+ // pointer moved. Ask X where the pointer is. (Armada 0001, on 3.16.29.)
|
||||
+ Window root_ret, child_ret;
|
||||
+ int root_x = m_x, root_y = m_y, win_x = 0, win_y = 0;
|
||||
+ unsigned int mask;
|
||||
+ XQueryPointer( m_ctx->dpy, DefaultRootWindow( m_ctx->dpy ),
|
||||
+ &root_ret, &child_ret,
|
||||
+ &root_x, &root_y,
|
||||
+ &win_x, &win_y,
|
||||
+ &mask );
|
||||
+
|
||||
wlserver_lock();
|
||||
struct wlr_pointer_constraint_v1 *pConstraint = wlserver.GetCursorConstraint();
|
||||
if ( pConstraint && pConstraint->current.cursor_hint.enabled )
|
||||
{
|
||||
m_bConstrained = true;
|
||||
-
|
||||
m_x = pConstraint->current.cursor_hint.x;
|
||||
m_y = pConstraint->current.cursor_hint.y;
|
||||
+ wlserver_unlock();
|
||||
+ return;
|
||||
}
|
||||
- else
|
||||
+ m_bConstrained = false;
|
||||
+ wlserver_unlock();
|
||||
+ if ( root_x != m_x || root_y != m_y )
|
||||
{
|
||||
- m_bConstrained = false;
|
||||
-
|
||||
- m_x = wlserver.mouse_surface_cursorx;
|
||||
- m_y = wlserver.mouse_surface_cursory;
|
||||
+ m_x = root_x;
|
||||
+ m_y = root_y;
|
||||
+ if ( !m_imageEmpty )
|
||||
+ {
|
||||
+ wlserver.ulLastMovedCursorTime = get_time_in_nanos();
|
||||
+ wlserver.bCursorHidden = !wlserver.bCursorHasImage;
|
||||
+ hasRepaintNonBasePlane = true;
|
||||
+ }
|
||||
}
|
||||
- wlserver_unlock();
|
||||
}
|
||||
|
||||
void MouseCursor::checkSuspension()
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user