void VulkanBase::prepare() { if (enableValidation) vkDebug::setupDebugging(instance, VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT, NULL); createCommandPool(); createSetupCommandBuffer(); setupSwapChain(); createCommandBuffers(); setupDepthStencil(); setupRenderPass(); createPipelineCache(); setupFrameBuffer(); flushSetupCommandBuffer(); // Recreate setup command buffer for derived class createSetupCommandBuffer(); // Create a simple texture loader class textureLoader = new vkTools::VulkanTextureLoader(physicalDevice, device, queue, cmdPool); }
void VulkanExampleBase::windowResize() { if (!prepared) { return; } prepared = false; // Recreate swap chain width = destWidth; height = destHeight; createSetupCommandBuffer(); 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(); flushSetupCommandBuffer(); // Command buffers need to be recreated as they may store // references to the recreated frame buffer destroyCommandBuffers(); createCommandBuffers(); buildCommandBuffers(); vkQueueWaitIdle(queue); vkDeviceWaitIdle(device); // Notify derived class windowResized(); viewChanged(); prepared = true; }