novelrt / NovelRT

A cross-platform 2D game engine accompanied by a strong toolset for visual novels.
MIT License
184 stars 42 forks source link

Fix a Vulkan race condition between the swapchain and command buffer #474

Closed tannergooding closed 2 years ago

tannergooding commented 2 years ago

There was a race condition between vkAcquireNextImageKHR and vkQueueSubmit where the image may not have been "acquired" (and therefore may still be in use by the device) before new draws were made to it.

This is a minimal fix to ensure that the race doesn't exist. Ideally we eventually change these waits to happen in the "correct" places (e.g. the presentCompletionGraphicsFence should be waited just before vkQueueSubmit and executeGraphicsFence should be waited just before vkQueuePresentKHR). Optionally this could be done using the semaphores instead of full fences.