You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SwapChain should be recreated while resizing windows.
Destroy the swapchain and create the swapchain again.
For example:
VkResult res = swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete);
if (!((res == VK_SUCCESS) || (res == VK_SUBOPTIMAL_KHR))) {
if (res == VK_ERROR_OUT_OF_DATE_KHR) {
// Swap chain is no longer compatible with the surface and needs to be recreated
windowResize();
return;
} else {
VK_CHECK_RESULT(res);
}
}
VK_CHECK_RESULT(vkQueueWaitIdle(queue));
void VulkanBase::windowResize()
{
if (!prepared)
{
return;
}
prepared = false;
// Ensure all operations on the device have been finished before destroying resources
vkDeviceWaitIdle(device);
// Recreate swap chain
width = destWidth;
height = destHeight;
setupSwapChain();
// Recreate the frame buffers
vkDestroyImageView(device, depthStencil.view, nullptr);
vkDestroyImage(device, depthStencil.image, nullptr);
vkFreeMemory(device, depthStencil.mem, nullptr);
setupDepthStencil();
for (uint32_t i = 0; i < frameBuffers.size(); i++) {
vkDestroyFramebuffer(device, frameBuffers[i], nullptr);
}
setupFrameBuffer();
if ((width > 0.0f) && (height > 0.0f)) {
if (settings.overlay) {
UIOverlay.resize(width, height);
}
}
// Command buffers need to be recreated as they may store
// references to the recreated frame buffer
destroyCommandBuffers();
createCommandBuffers();
buildCommandBuffers();
vkDeviceWaitIdle(device);
if ((width > 0.0f) && (height > 0.0f)) {
camera.updateAspectRatio((float)width / (float)height);
}
// Notify derived class
windowResized();
viewChanged();
prepared = true;
}
The text was updated successfully, but these errors were encountered:
@mattparks
I am writing a project for vulkan: https://github.com/engineer1109/LearnVulkan
The project contains the above codes. I hope this will help you.
You can see the swapchain recreation while resizing window to deal with the VK_ERROR_OUT_OF_DATE_KHR.
SwapChain should be recreated while resizing windows.
Destroy the swapchain and create the swapchain again.
For example:
The text was updated successfully, but these errors were encountered: