From 087a60fa527aa198e6865d9ffa6846124ec3d778 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Sat, 2 Jan 2021 21:07:51 -0800 Subject: [PATCH] add wait API call --- include/Refresh.h | 5 +++++ src/Refresh.c | 9 +++++++++ src/Refresh_Driver.h | 7 ++++++- src/Refresh_Driver_Vulkan.c | 14 ++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/include/Refresh.h b/include/Refresh.h index 1d5a232..37914d8 100644 --- a/include/Refresh.h +++ b/include/Refresh.h @@ -1417,6 +1417,11 @@ REFRESHAPI void REFRESH_Submit( uint32_t commandBufferCount ); +/* Waits for the previous submission to complete. */ +REFRESHAPI void REFRESH_Wait( + REFRESH_Device *device +); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/Refresh.c b/src/Refresh.c index 88e557d..75a2d8c 100644 --- a/src/Refresh.c +++ b/src/Refresh.c @@ -972,4 +972,13 @@ void REFRESH_Submit( ); } +void REFRESH_Wait( + REFRESH_Device *device +) { + NULL_RETURN(device); + device->Wait( + device->driverData + ); +} + /* vim: set noexpandtab shiftwidth=8 tabstop=8: */ diff --git a/src/Refresh_Driver.h b/src/Refresh_Driver.h index 4b39763..2796037 100644 --- a/src/Refresh_Driver.h +++ b/src/Refresh_Driver.h @@ -564,6 +564,10 @@ struct REFRESH_Device uint32_t commandBufferCount ); + void(*Wait)( + REFRESH_Renderer *driverData + ); + /* Opaque pointer for the Driver */ REFRESH_Renderer *driverData; }; @@ -622,7 +626,8 @@ struct REFRESH_Device ASSIGN_DRIVER_FUNC(BindComputeTextures, name) \ ASSIGN_DRIVER_FUNC(AcquireCommandBuffer, name) \ ASSIGN_DRIVER_FUNC(QueuePresent, name) \ - ASSIGN_DRIVER_FUNC(Submit, name) + ASSIGN_DRIVER_FUNC(Submit, name) \ + ASSIGN_DRIVER_FUNC(Wait, name) typedef struct REFRESH_Driver { diff --git a/src/Refresh_Driver_Vulkan.c b/src/Refresh_Driver_Vulkan.c index 105310d..6f6a79a 100644 --- a/src/Refresh_Driver_Vulkan.c +++ b/src/Refresh_Driver_Vulkan.c @@ -8501,6 +8501,20 @@ static void VULKAN_Submit( SDL_stack_free(commandBuffers); } +static void VULKAN_Wait( + REFRESH_Renderer *driverData +) { + VulkanRenderer *renderer = (VulkanRenderer*) driverData; + + renderer->vkWaitForFences( + renderer->logicalDevice, + 1, + &renderer->inFlightFence, + VK_TRUE, + UINT64_MAX + ); +} + /* Device instantiation */ static inline uint8_t VULKAN_INTERNAL_SupportsExtension(