diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index e80b7260..95b6c1b1 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -106,47 +106,6 @@ void VulkanExampleBase::destroyCommandBuffers() vkFreeCommandBuffers(device, cmdPool, static_cast(drawCmdBuffers.size()), drawCmdBuffers.data()); } -void VulkanExampleBase::createSetupCommandBuffer() -{ - if (setupCmdBuffer != VK_NULL_HANDLE) - { - vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer); - setupCmdBuffer = VK_NULL_HANDLE; // todo : check if still necessary - } - - VkCommandBufferAllocateInfo cmdBufAllocateInfo = - vkTools::initializers::commandBufferAllocateInfo( - cmdPool, - VK_COMMAND_BUFFER_LEVEL_PRIMARY, - 1); - - VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, &setupCmdBuffer)); - - VkCommandBufferBeginInfo cmdBufInfo = {}; - cmdBufInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - - VK_CHECK_RESULT(vkBeginCommandBuffer(setupCmdBuffer, &cmdBufInfo)); -} - -void VulkanExampleBase::flushSetupCommandBuffer() -{ - if (setupCmdBuffer == VK_NULL_HANDLE) - return; - - VK_CHECK_RESULT(vkEndCommandBuffer(setupCmdBuffer)); - - VkSubmitInfo submitInfo = {}; - submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &setupCmdBuffer; - - VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); - VK_CHECK_RESULT(vkQueueWaitIdle(queue)); - - vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer); - setupCmdBuffer = VK_NULL_HANDLE; -} - VkCommandBuffer VulkanExampleBase::createCommandBuffer(VkCommandBufferLevel level, bool begin) { VkCommandBuffer cmdBuffer; @@ -206,16 +165,12 @@ void VulkanExampleBase::prepare() vkDebug::DebugMarker::setup(device); } 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(vulkanDevice, queue, cmdPool); #if defined(__ANDROID__) @@ -718,11 +673,6 @@ VulkanExampleBase::~VulkanExampleBase() { vkDestroyDescriptorPool(device, descriptorPool, nullptr); } - if (setupCmdBuffer != VK_NULL_HANDLE) - { - vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer); - - } destroyCommandBuffers(); vkDestroyRenderPass(device, renderPass, nullptr); for (uint32_t i = 0; i < frameBuffers.size(); i++) @@ -1632,7 +1582,6 @@ void VulkanExampleBase::windowResize() // Recreate swap chain width = destWidth; height = destHeight; - createSetupCommandBuffer(); setupSwapChain(); // Recreate the frame buffers @@ -1648,8 +1597,6 @@ void VulkanExampleBase::windowResize() } setupFrameBuffer(); - flushSetupCommandBuffer(); - // Command buffers need to be recreated as they may store // references to the recreated frame buffer destroyCommandBuffers(); diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 94c879b1..002275bf 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -99,8 +99,6 @@ protected: VkFormat depthFormat; // Command buffer pool VkCommandPool cmdPool; - // Command buffer used for setup - VkCommandBuffer setupCmdBuffer = VK_NULL_HANDLE; /** @brief Pipeline stages used to wait at for graphics queue submissions */ VkPipelineStageFlags submitPipelineStages = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; // Contains command buffers and semaphores to be presented to the queue @@ -273,10 +271,6 @@ public: // Destroy all command buffers and set their handles to VK_NULL_HANDLE // May be necessary during runtime if options are toggled void destroyCommandBuffers(); - // Create command buffer for setup commands - void createSetupCommandBuffer(); - // Finalize setup command bufferm submit it to the queue and remove it - void flushSetupCommandBuffer(); // Command buffer creation // Creates and returns a new command buffer