Files
DroidDeck/tools/gamescope/patches/0100-realtime-queue-and-gamepad-cursor.patch
The412Banner f66138505f 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.
2026-09-23 09:12:15 -04:00

107 lines
4.3 KiB
Diff

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()