GPU: Fix Vulkan backend never checking deallocations (#12567)

---------

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
This commit is contained in:
Evan Hemsley
2025-03-17 13:19:41 -07:00
committed by GitHub
parent 715301cef5
commit 0bd70684b3

View File

@@ -1106,6 +1106,7 @@ struct VulkanRenderer
VulkanMemoryAllocator *memoryAllocator; VulkanMemoryAllocator *memoryAllocator;
VkPhysicalDeviceMemoryProperties memoryProperties; VkPhysicalDeviceMemoryProperties memoryProperties;
bool checkEmptyAllocations;
WindowData **claimedWindows; WindowData **claimedWindows;
Uint32 claimedWindowCount; Uint32 claimedWindowCount;
@@ -1546,6 +1547,10 @@ static void VULKAN_INTERNAL_RemoveMemoryUsedRegion(
usedRegion->offset, usedRegion->offset,
usedRegion->size); usedRegion->size);
if (usedRegion->allocation->usedRegionCount == 0) {
renderer->checkEmptyAllocations = true;
}
SDL_free(usedRegion); SDL_free(usedRegion);
SDL_UnlockMutex(renderer->allocatorLock); SDL_UnlockMutex(renderer->allocatorLock);
@@ -10375,7 +10380,6 @@ static bool VULKAN_Submit(
VkPipelineStageFlags waitStages[MAX_PRESENT_COUNT]; VkPipelineStageFlags waitStages[MAX_PRESENT_COUNT];
Uint32 swapchainImageIndex; Uint32 swapchainImageIndex;
VulkanTextureSubresource *swapchainTextureSubresource; VulkanTextureSubresource *swapchainTextureSubresource;
Uint8 commandBufferCleaned = 0;
VulkanMemorySubAllocator *allocator; VulkanMemorySubAllocator *allocator;
bool presenting = false; bool presenting = false;
@@ -10491,12 +10495,10 @@ static bool VULKAN_Submit(
renderer, renderer,
renderer->submittedCommandBuffers[i], renderer->submittedCommandBuffers[i],
false); false);
commandBufferCleaned = 1;
} }
} }
if (commandBufferCleaned) { if (renderer->checkEmptyAllocations) {
SDL_LockMutex(renderer->allocatorLock); SDL_LockMutex(renderer->allocatorLock);
for (Uint32 i = 0; i < VK_MAX_MEMORY_TYPES; i += 1) { for (Uint32 i = 0; i < VK_MAX_MEMORY_TYPES; i += 1) {
@@ -10512,6 +10514,8 @@ static bool VULKAN_Submit(
} }
} }
renderer->checkEmptyAllocations = false;
SDL_UnlockMutex(renderer->allocatorLock); SDL_UnlockMutex(renderer->allocatorLock);
} }