kondrak / vkQuake2

id Software's Quake 2 v3.21 with mission packs and Vulkan support (Windows, Linux, macOS, FreeBSD, Raspberry Pi 4)
GNU General Public License v2.0
899 stars 89 forks source link

Exclusive fullscreen (lost): game queues present with not acquired image. #112

Closed dor666 closed 4 years ago

dor666 commented 4 years ago

Application should not call vkQueuePresentKHR with unacquired image.

Spec defines VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT as failure code for vkAcquireNextImageKHR so image is not considered acquired.

If an image is acquired successfully, vkAcquireNextImageKHR must either return VK_SUCCESS, or VK_SUBOPTIMAL_KHR if the swapchain no longer matches the surface properties exactly, but can still be used for presentation.

Api dump snippet of issue:

vkAcquireNextImageKHR(device, swapchain, timeout, semaphore, fence, pImageIndex) returns VkResult VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT (-1000255000):
    device:                         VkDevice = 00000239422C78C0
    swapchain:                      VkSwapchainKHR = 000002394273BC30
    timeout:                        uint64_t = 4294967295
    semaphore:                      VkSemaphore = 0000023948071290
    fence:                          VkFence = 0000000000000000
    pImageIndex:                    uint32_t* = 2

[...]

Thread 0, Frame 405, Time 21494328 us:
vkQueuePresentKHR(queue, pPresentInfo) returns VkResult VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT (-1000255000):
    queue:                          VkQueue = 000002393F9780B0
    pPresentInfo:                   const VkPresentInfoKHR* = 000000FF3917FAB0:
        sType:                          VkStructureType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR (1000001001)
        pNext:                          const void* = NULL
        waitSemaphoreCount:             uint32_t = 1
        pWaitSemaphores:                const VkSemaphore* = 00007FFBF93E46C8
            pWaitSemaphores[0]:             const VkSemaphore = 0000023948071420
        swapchainCount:                 uint32_t = 1
        pSwapchains:                    const VkSwapchainKHR* = 00007FFBF910F548
            pSwapchains[0]:                 const VkSwapchainKHR = 000002394273BC30
        pImageIndices:                  const uint32_t* = 00007FFBF91150D8
            pImageIndices[0]:               const uint32_t = 2
        pResults:                       VkResult* = NULL

Impact: Presenting unacquired images can cause hangs on Intel HW with newer Win10 versions.

kondrak commented 4 years ago

Thanks for catching this, that does indeed look like obvious spec validation, I'll have a look at it.