admin管理员组文章数量:1122846
I'm encountering validation errors when resizing a window in my Vulkan application. While the application works fine initially, resizing sometimes (about 1 in 2) causes synchronization issues and I receive the following validation errors:
vkQueueSubmit(): pSubmits[0].pCommandBuffers[0] VkCommandBuffer [...] is unrecorded and contains no commands. The Vulkan spec states: Each element of the pCommandBuffers member of each element of pSubmits must be in the pending or executable state.
vkQueuePresentKHR(): pPresentInfo->pSwapchains[0] images passed to present must be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR but is in VK_IMAGE_LAYOUT_UNDEFINED. The Vulkan spec states: Each element of pImageIndices must be the index of a presentable image acquired from the swapchain and in VK_IMAGE_LAYOUT_PRESENT_SRC_KHR.
I handle window resizing by recreating the swapchain and all associated resources (framebuffers, image views, etc.) I reset and re-record command buffers after resizing I update descriptor sets Here is my cleanupSwapChain and recreateSwapChain functions:
void cleanupSwapChain() {
gbuffer.cleanupFramebuffers(vulkanDevice, MAXFRAMESINFLIGHT);
gbuffer.cleanupImages(vulkanDevice, MAXFRAMESINFLIGHT);
for (auto imageView : swapChainImageViews) {
vkDestroyImageView(vulkanDevice.getDevice(), imageView, nullptr);
}
swapChainImageViews.clear();
if (gbuffer.getCommandBuffers().size() != swapChainImages.size()) {
gbuffer.freeCommandBuffers(vulkanDevice);
gbuffer.createCommandBuffers(vulkanDevice, MAXFRAMESINFLIGHT);
}
vkDestroySwapchainKHR(vulkanDevice.getDevice(), swapChain, nullptr);
}
void recreateSwapChain() {
int width = 0, height = 0;
glfwGetFramebufferSize(window, &width, &height);
while (width == 0 || height == 0) {
if (glfwWindowShouldClose(window))
return;
glfwGetFramebufferSize(window, &width, &height);
glfwWaitEvents();
}
vkDeviceWaitIdle(vulkanDevice.getDevice());
cleanupSwapChain();
createSwapChain();
createImageViews();
gbuffer.createImageViews(vulkanDevice, swapChainExtent, MAXFRAMESINFLIGHT);
gbuffer.updateDescriptorSets(vulkanDevice, MAXFRAMESINFLIGHT);
gbuffer.createFramebuffers(vulkanDevice, grid, swapChainImageViews, swapChainExtent, MAXFRAMESINFLIGHT);
}
本文标签: cResizing window in Vulkan has synchronization issuesStack Overflow
版权声明:本文标题:c++ - Resizing window in Vulkan has synchronization issues - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736282057a1926521.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论