Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
Fixed problem with errors thrown by vkAcquireNextImageKHR() and vkQue…
Browse files Browse the repository at this point in the history
…uePresentKHR() functions being incorrectly handled.
  • Loading branch information
Ekzuzy committed Sep 10, 2018
1 parent 39f230a commit 2ee3082
Showing 1 changed file with 25 additions and 25 deletions.
50 changes: 25 additions & 25 deletions Project/Common/SampleCommon.cpp
Expand Up @@ -62,15 +62,15 @@ namespace ApiWithoutSecrets {

void SampleCommon::AcquireImage( CurrentFrameData & current_frame, vk::RenderPass & render_pass ) {
// Acquire swapchain image
vk::Result result = vk::Result::eSuccess;
try {
result = GetDevice().acquireNextImageKHR( *current_frame.Swapchain->Handle, 3000000000, *current_frame.FrameResources->ImageAvailableSemaphore, vk::Fence(), &current_frame.SwapchainImageIndex );
} catch( ... ) {
if( vk::Result::eErrorOutOfDateKHR == result ) {
OnWindowSizeChanged();
} else {
throw;
}
switch (GetDevice().acquireNextImageKHR( *current_frame.Swapchain->Handle, 3000000000, *current_frame.FrameResources->ImageAvailableSemaphore, vk::Fence(), &current_frame.SwapchainImageIndex )) {
case vk::Result::eSuccess:
case vk::Result::eSuboptimalKHR:
break;
case vk::Result::eErrorOutOfDateKHR:
OnWindowSizeChanged();
break;
default:
throw std::exception( "Could not acquire swapchain image!" );
}
// Create a framebuffer for current frame
current_frame.FrameResources->Framebuffer = CreateFramebuffer( { *current_frame.Swapchain->ImageViews[current_frame.SwapchainImageIndex], *current_frame.FrameResources->DepthAttachment.View }, current_frame.Swapchain->Extent, render_pass );
Expand Down Expand Up @@ -139,23 +139,23 @@ namespace ApiWithoutSecrets {
// Present frame
{
vk::Result result = vk::Result::eSuccess;
try {
vk::PresentInfoKHR present_info(
1, // uint32_t waitSemaphoreCount
&(*current_frame.FrameResources->FinishedRenderingSemaphore), // const VkSemaphore *pWaitSemaphores
1, // uint32_t swapchainCount
&(*current_frame.Swapchain->Handle), // const VkSwapchainKHR *pSwapchains
&current_frame.SwapchainImageIndex // const uint32_t *pImageIndices
);
vk::PresentInfoKHR present_info(
1, // uint32_t waitSemaphoreCount
&(*current_frame.FrameResources->FinishedRenderingSemaphore), // const VkSemaphore *pWaitSemaphores
1, // uint32_t swapchainCount
&(*current_frame.Swapchain->Handle), // const VkSwapchainKHR *pSwapchains
&current_frame.SwapchainImageIndex // const uint32_t *pImageIndices
);

result = GetPresentQueue().Handle.presentKHR( present_info );
} catch( ... ) {
if( (vk::Result::eSuboptimalKHR == result) ||
(vk::Result::eErrorOutOfDateKHR == result) ) {
OnWindowSizeChanged();
} else {
throw;
}
switch (GetPresentQueue().Handle.presentKHR( &present_info )) {
case vk::Result::eSuccess:
break;
case vk::Result::eSuboptimalKHR:
case vk::Result::eErrorOutOfDateKHR:
OnWindowSizeChanged();
break;
default:
throw std::exception( "Could not present swapchain image!" );
}
}
}
Expand Down

0 comments on commit 2ee3082

Please sign in to comment.