From c4fba75a122f3901c0e1afc966eab232a593df00 Mon Sep 17 00:00:00 2001
From: Evan Hemsley <[EMAIL REDACTED]>
Date: Fri, 4 Apr 2025 14:27:18 -0700
Subject: [PATCH] GPU Vulkan: Clean up in Submit in headless mode (#12744)
(cherry picked from commit 33f90f2e41a1567b2d40c00e8e8869e9573ca4e5)
---
src/gpu/vulkan/SDL_gpu_vulkan.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/gpu/vulkan/SDL_gpu_vulkan.c b/src/gpu/vulkan/SDL_gpu_vulkan.c
index 5324c0a327c39..5a41450808e59 100644
--- a/src/gpu/vulkan/SDL_gpu_vulkan.c
+++ b/src/gpu/vulkan/SDL_gpu_vulkan.c
@@ -10461,7 +10461,9 @@ static bool VULKAN_Submit(
Uint32 swapchainImageIndex;
VulkanTextureSubresource *swapchainTextureSubresource;
VulkanMemorySubAllocator *allocator;
- bool presenting = (vulkanCommandBuffer->presentDataCount > 0);
+ bool performCleanups =
+ (renderer->claimedWindowCount > 0 && vulkanCommandBuffer->presentDataCount > 0) ||
+ renderer->claimedWindowCount == 0;
SDL_LockMutex(renderer->submitLock);
@@ -10484,7 +10486,7 @@ static bool VULKAN_Submit(
swapchainTextureSubresource);
}
- if (presenting &&
+ if (performCleanups &&
renderer->allocationsToDefragCount > 0 &&
!renderer->defragInProgress) {
if (!VULKAN_INTERNAL_DefragmentMemory(renderer, vulkanCommandBuffer))
@@ -10568,8 +10570,7 @@ static bool VULKAN_Submit(
(presentData->windowData->frameCounter + 1) % renderer->allowedFramesInFlight;
}
- // If presenting, check if we can perform any cleanups
- if (presenting) {
+ if (performCleanups) {
for (Sint32 i = renderer->submittedCommandBufferCount - 1; i >= 0; i -= 1) {
vulkanResult = renderer->vkGetFenceStatus(
renderer->logicalDevice,