limit max frames in flight
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
a3249404bc
commit
42d62d423a
|
@ -80,6 +80,7 @@ typedef struct VulkanExtensions
|
|||
#define UBO_BUFFER_SIZE 16777216 /* 16MB */
|
||||
#define MAX_UBO_SECTION_SIZE 4096 /* 4KB */
|
||||
#define DESCRIPTOR_POOL_STARTING_SIZE 128
|
||||
#define MAX_FRAMES_IN_FLIGHT 3
|
||||
#define WINDOW_DATA "Refresh_VulkanWindowData"
|
||||
|
||||
#define IDENTITY_SWIZZLE \
|
||||
|
@ -875,6 +876,8 @@ typedef struct VulkanSwapchainData
|
|||
/* Synchronization primitives */
|
||||
VkSemaphore imageAvailableSemaphore;
|
||||
VkSemaphore renderFinishedSemaphore;
|
||||
|
||||
uint32_t submissionsInFlight;
|
||||
} VulkanSwapchainData;
|
||||
|
||||
typedef struct WindowData
|
||||
|
@ -4639,6 +4642,7 @@ static uint8_t VULKAN_INTERNAL_CreateSwapchain(
|
|||
uint32_t i;
|
||||
|
||||
swapchainData = SDL_malloc(sizeof(VulkanSwapchainData));
|
||||
swapchainData->submissionsInFlight = 0;
|
||||
|
||||
/* Each swapchain must have its own surface. */
|
||||
|
||||
|
@ -9616,6 +9620,12 @@ static Refresh_Texture* VULKAN_AcquireSwapchainTexture(
|
|||
|
||||
swapchainData = windowData->swapchainData;
|
||||
|
||||
/* Drop frames if too many submissions in flight */
|
||||
if (swapchainData->submissionsInFlight >= MAX_FRAMES_IN_FLIGHT)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Window is claimed but swapchain is invalid! */
|
||||
if (swapchainData == NULL)
|
||||
{
|
||||
|
@ -10057,6 +10067,11 @@ static void VULKAN_INTERNAL_CleanCommandBuffer(
|
|||
|
||||
/* Reset presentation data */
|
||||
|
||||
for (i = 0; i < commandBuffer->presentDataCount; i += 1)
|
||||
{
|
||||
commandBuffer->presentDatas[i].windowData->swapchainData->submissionsInFlight -= 1;
|
||||
}
|
||||
|
||||
commandBuffer->presentDataCount = 0;
|
||||
commandBuffer->waitSemaphoreCount = 0;
|
||||
commandBuffer->signalSemaphoreCount = 0;
|
||||
|
@ -10255,6 +10270,10 @@ static void VULKAN_Submit(
|
|||
presentData->windowData
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
presentData->windowData->swapchainData->submissionsInFlight += 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check if we can perform any cleanups */
|
||||
|
|
Loading…
Reference in New Issue