mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-12-05 20:45:43 +00:00
fix(gamescope): destroy the image of a failed texture allocation and build patches on pull requests
This commit is contained in:
1 parent
ab4116d425
commit
f2c8d5e091
4 files changed
+79
-11
No files matched your search
@@ -7,6 +7,15 @@ on:
|
||||
- 'tools/gamescope/build-in-arch.sh'
|
||||
- 'tools/gamescope/patches/**'
|
||||
- 'tools/gamescope/runtime-sonames.txt'
|
||||
- 'tools/gamescope/tests/**'
|
||||
- '.github/workflows/build-gamescope.yml'
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
paths:
|
||||
- 'tools/gamescope/build-in-arch.sh'
|
||||
- 'tools/gamescope/patches/**'
|
||||
- 'tools/gamescope/runtime-sonames.txt'
|
||||
- 'tools/gamescope/tests/**'
|
||||
- '.github/workflows/build-gamescope.yml'
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
@@ -16,11 +25,11 @@ on:
|
||||
default: ''
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ inputs.tag && format('gamescope-tag-{0}', inputs.tag) || format('gamescope-{0}-{1}', github.event_name, github.ref) }}
|
||||
cancel-in-progress: ${{ github.event_name == 'push' }}
|
||||
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -138,7 +138,10 @@ app's Wayland-hosted gamescope never reaches, or need a newer gamescope than the
|
||||
`vkQueuePresentKHR` and `vkAcquireNextImageKHR` calls now log their VkResult. A failed attempt
|
||||
releases whatever it created, so a retry never finds the surface still owned by a half-built
|
||||
swapchain, and is retried up to 10 times, 100 ms apart. A swapchain that still cannot be made
|
||||
ends gamescope with a logged reason instead of the assertion.
|
||||
ends gamescope with a logged reason instead of the assertion. A texture whose
|
||||
`vkAllocateMemory` (or bind onto shared memory) failed kept its `VkImage`, which the destructor only
|
||||
destroys together with owned memory; it is destroyed on that failure, so a retry that succeeds
|
||||
leaves nothing behind.
|
||||
|
||||
The shared DroidDeck patch also includes `0116-release-cursor-shm-buffers.patch`: pointer cursor
|
||||
surfaces have no X11/xdg window association, so routing their commits through `g_PendingCommits`
|
||||
|
||||
@@ -19,7 +19,20 @@ index 0835bfe..21a287d 100644
|
||||
#include "Utils/Algorithm.h"
|
||||
|
||||
#if defined(__linux__)
|
||||
@@ -3224,7 +3228,10 @@ bool acquire_next_image( void )
|
||||
@@ -2629,2 +2633,4 @@
|
||||
}
|
||||
+ g_device.vk.DestroyImage( g_device.device(), m_vkImage, nullptr );
|
||||
+ m_vkImage = VK_NULL_HANDLE;
|
||||
return false;
|
||||
@@ -2654,2 +2660,7 @@
|
||||
memRequirements.memoryTypeBits, fdProperties.memoryTypeBits );
|
||||
+ if ( m_vkImageMemory == VK_NULL_HANDLE )
|
||||
+ {
|
||||
+ g_device.vk.DestroyImage( g_device.device(), m_vkImage, nullptr );
|
||||
+ m_vkImage = VK_NULL_HANDLE;
|
||||
+ }
|
||||
return false;
|
||||
@@ -3224,7 +3235,10 @@ bool acquire_next_image( void )
|
||||
{
|
||||
VkResult res = g_device.vk.AcquireNextImageKHR( g_device.device(), g_output.swapChain, UINT64_MAX, VK_NULL_HANDLE, g_output.acquireFence, &g_output.nOutImage );
|
||||
if ( res != VK_SUCCESS && res != VK_SUBOPTIMAL_KHR )
|
||||
@@ -30,7 +43,7 @@ index 0835bfe..21a287d 100644
|
||||
if ( g_device.vk.WaitForFences( g_device.device(), 1, &g_output.acquireFence, false, UINT64_MAX ) != VK_SUCCESS )
|
||||
return false;
|
||||
return g_device.vk.ResetFences( g_device.device(), 1, &g_output.acquireFence ) == VK_SUCCESS;
|
||||
@@ -3330,7 +3337,8 @@ void vulkan_present_to_window( void )
|
||||
@@ -3330,7 +3344,8 @@ void vulkan_present_to_window( void )
|
||||
.pImageIndices = &g_output.nOutImage,
|
||||
};
|
||||
|
||||
@@ -40,7 +53,7 @@ index 0835bfe..21a287d 100644
|
||||
{
|
||||
if ( g_device.supportsPresentWait() )
|
||||
{
|
||||
@@ -3339,7 +3347,11 @@ void vulkan_present_to_window( void )
|
||||
@@ -3339,7 +3354,11 @@ void vulkan_present_to_window( void )
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -52,7 +65,7 @@ index 0835bfe..21a287d 100644
|
||||
|
||||
while ( !acquire_next_image() )
|
||||
vulkan_remake_swapchain();
|
||||
@@ -3461,2 +3473,6 @@
|
||||
@@ -3461,2 +3480,6 @@
|
||||
- if ( g_device.vk.GetPhysicalDeviceSurfaceCapabilitiesKHR( g_device.physDev(), pOutput->surface, &pOutput->surfaceCaps ) != VK_SUCCESS )
|
||||
- return false;
|
||||
+ VkResult capsResult = g_device.vk.GetPhysicalDeviceSurfaceCapabilitiesKHR( g_device.physDev(), pOutput->surface, &pOutput->surfaceCaps );
|
||||
@@ -61,7 +74,7 @@ index 0835bfe..21a287d 100644
|
||||
+ vk_errorf( capsResult, "vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed" );
|
||||
+ return false;
|
||||
+ }
|
||||
@@ -3559,7 +3575,12 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
@@ -3559,7 +3582,12 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
.clipped = VK_TRUE,
|
||||
};
|
||||
|
||||
@@ -75,7 +88,7 @@ index 0835bfe..21a287d 100644
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -3606,6 +3627,19 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
@@ -3606,6 +3634,19 @@ bool vulkan_make_swapchain( VulkanOutput_t *pOutput )
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -95,7 +108,7 @@ index 0835bfe..21a287d 100644
|
||||
bool vulkan_remake_swapchain( void )
|
||||
{
|
||||
std::unique_lock lock(present_wait_lock);
|
||||
@@ -3618,9 +3652,3 @@ bool vulkan_remake_swapchain( void )
|
||||
@@ -3618,9 +3659,3 @@ bool vulkan_remake_swapchain( void )
|
||||
|
||||
- pOutput->outputImages.clear();
|
||||
- pOutput->presentationImages.clear();
|
||||
@@ -106,7 +119,7 @@ index 0835bfe..21a287d 100644
|
||||
- g_device.vk.DestroySwapchainKHR( g_device.device(), pOutput->swapChain, nullptr );
|
||||
+ vulkan_release_swapchain( pOutput );
|
||||
|
||||
@@ -3630,9 +3658,18 @@ bool vulkan_remake_swapchain( void )
|
||||
@@ -3630,9 +3665,18 @@ bool vulkan_remake_swapchain( void )
|
||||
for (auto& pCaptureTexture : pOutput->pCaptureTextures)
|
||||
pCaptureTexture = nullptr;
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from pathlib import Path
|
||||
import unittest
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
PATCH = ROOT / "tools/gamescope/patches/0936-nested-swapchain-remake-retries.patch"
|
||||
DESTROY = "g_device.vk.DestroyImage( g_device.device(), m_vkImage, nullptr );"
|
||||
RESET = "m_vkImage = VK_NULL_HANDLE;"
|
||||
|
||||
|
||||
def hunks():
|
||||
out = []
|
||||
for line in PATCH.read_text().splitlines():
|
||||
if line.startswith("@@"):
|
||||
out.append([])
|
||||
elif out:
|
||||
out[-1].append(line)
|
||||
return out
|
||||
|
||||
|
||||
def hunk_after(anchor):
|
||||
for hunk in hunks():
|
||||
if any(anchor in line for line in hunk):
|
||||
return hunk
|
||||
raise AssertionError(anchor)
|
||||
|
||||
|
||||
class SwapchainImageReleaseTest(unittest.TestCase):
|
||||
def test_failed_allocation_destroys_the_image(self):
|
||||
hunk = hunk_after(DESTROY)
|
||||
added = [line[1:].strip() for line in hunk if line.startswith("+")]
|
||||
self.assertEqual(added, [DESTROY, RESET])
|
||||
self.assertEqual(hunk[-1].strip(), "return false;")
|
||||
|
||||
def test_failed_bind_destroys_only_an_image_the_destructor_would_skip(self):
|
||||
hunk = hunk_after("if ( m_vkImageMemory == VK_NULL_HANDLE )")
|
||||
added = [line[1:].strip() for line in hunk if line.startswith("+")]
|
||||
self.assertEqual(added, ["if ( m_vkImageMemory == VK_NULL_HANDLE )", "{", DESTROY, RESET, "}"])
|
||||
self.assertEqual(hunk[-1].strip(), "return false;")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user