mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
The gamepad-cursor port queried the X pointer on every vblank, a blocking round trip to Xwayland on the paint thread. With no cursor image the position comes from wlserver as upstream; while the cursor is hidden for inactivity X is asked every 50 ms. The realtime-queue comment now says it is a no-op on KGSL Turnip.
128 lines
5.2 KiB
Diff
128 lines
5.2 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; the fallback below covers a driver that refuses. KGSL
|
|
+ // Turnip accepts but ignores it (one submit-queue priority, contexts created alike). 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 10990b8..08afbc4 100644
|
|
--- a/src/steamcompmgr.cpp
|
|
+++ b/src/steamcompmgr.cpp
|
|
@@ -2025,18 +2025,53 @@ void MouseCursor::UpdatePosition()
|
|
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;
|
|
+ // Nothing to draw (the gamepad UI, most games): the position only feeds focus and zoom, and
|
|
+ // wlserver's copy is what stock gamescope uses for those. No round trip to X.
|
|
+ if ( m_imageEmpty )
|
|
{
|
|
- m_bConstrained = false;
|
|
-
|
|
m_x = wlserver.mouse_surface_cursorx;
|
|
m_y = wlserver.mouse_surface_cursory;
|
|
+ wlserver_unlock();
|
|
+ return;
|
|
}
|
|
wlserver_unlock();
|
|
+
|
|
+ // 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.) That is a blocking
|
|
+ // round trip to Xwayland on the paint thread, which waits while Xwayland is busy drawing the
|
|
+ // client's interface: once per vblank only while the sprite is shown, and every 50 ms while
|
|
+ // it is hidden for inactivity - enough to bring it back within a few frames of a move.
|
|
+ if ( wlserver.bCursorHidden )
|
|
+ {
|
|
+ const uint64_t now = get_time_in_nanos();
|
|
+ if ( now - m_ulLastPointerQuery < 50'000'000ul )
|
|
+ return;
|
|
+ m_ulLastPointerQuery = now;
|
|
+ }
|
|
+ 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 );
|
|
+
|
|
+ if ( root_x != m_x || root_y != m_y )
|
|
+ {
|
|
+ m_x = root_x;
|
|
+ m_y = root_y;
|
|
+ wlserver.ulLastMovedCursorTime = get_time_in_nanos();
|
|
+ wlserver.bCursorHidden = !wlserver.bCursorHasImage;
|
|
+ hasRepaintNonBasePlane = true;
|
|
+ }
|
|
}
|
|
|
|
void MouseCursor::checkSuspension()
|
|
diff --git a/src/steamcompmgr.hpp b/src/steamcompmgr.hpp
|
|
index c428784..bd62fd1 100644
|
|
--- a/src/steamcompmgr.hpp
|
|
+++ b/src/steamcompmgr.hpp
|
|
@@ -109,6 +109,7 @@ private:
|
|
|
|
int m_x = 0, m_y = 0;
|
|
bool m_bConstrained = false;
|
|
+ uint64_t m_ulLastPointerQuery = 0;
|
|
int m_hotspotX = 0, m_hotspotY = 0;
|
|
|
|
gamescope::OwningRc<CVulkanTexture> m_texture;
|