Created
February 26, 2021 04:46
-
-
Save DavidEGrayson/011d02f5546a37ee48ade6479ee0479d to your computer and use it in GitHub Desktop.
Patch for https://github.com/Overv/VulkanTutorial/blob/master/code/15_hello_triangle.cpp that shows what is happening with fences.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/code/15_hello_triangle.cpp b/code/15_hello_triangle.cpp | |
index 532520e..31f2bd7 100644 | |
--- a/code/15_hello_triangle.cpp | |
+++ b/code/15_hello_triangle.cpp | |
@@ -642,12 +642,15 @@ private: | |
void drawFrame() { | |
vkWaitForFences(device, 1, &inFlightFences[currentFrame], VK_TRUE, UINT64_MAX); | |
+ VkFence waited = inFlightFences[currentFrame]; | |
uint32_t imageIndex; | |
vkAcquireNextImageKHR(device, swapChain, UINT64_MAX, imageAvailableSemaphores[currentFrame], VK_NULL_HANDLE, &imageIndex); | |
+ VkFence waited2 = NULL; | |
if (imagesInFlight[imageIndex] != VK_NULL_HANDLE) { | |
vkWaitForFences(device, 1, &imagesInFlight[imageIndex], VK_TRUE, UINT64_MAX); | |
+ waited2 = imagesInFlight[imageIndex]; | |
} | |
imagesInFlight[imageIndex] = inFlightFences[currentFrame]; | |
@@ -673,6 +676,10 @@ private: | |
throw std::runtime_error("failed to submit draw command buffer!"); | |
} | |
+ printf("Frame %d: waited for fence %p, acquired image %d, waited for fence %p, submitted with fence %p\n", | |
+ (int)currentFrame, waited, (int)imageIndex, waited2, inFlightFences[currentFrame] | |
+ ); | |
+ | |
VkPresentInfoKHR presentInfo{}; | |
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment