diff --git a/examples/textoverlay/textoverlay.cpp b/examples/textoverlay/textoverlay.cpp index 1ff4db49..0ef5e90b 100644 --- a/examples/textoverlay/textoverlay.cpp +++ b/examples/textoverlay/textoverlay.cpp @@ -64,7 +64,6 @@ private: VkPipeline pipeline; VkRenderPass renderPass; VkCommandPool commandPool; - std::vector cmdBuffers; std::vector frameBuffers; std::vector shaderStages; @@ -79,6 +78,8 @@ public: bool visible = true; + std::vector cmdBuffers; + TextOverlay( vks::VulkanDevice *vulkanDevice, VkQueue queue, @@ -622,24 +623,6 @@ public: VK_CHECK_RESULT(vkEndCommandBuffer(cmdBuffers[i])); } } - - // Submit the text command buffers to a queue - // Does a queue wait idle - void submit(VkQueue queue, uint32_t bufferindex) - { - if (!visible) - { - return; - } - - VkSubmitInfo submitInfo = {}; - submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &cmdBuffers[bufferindex]; - - VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); - VK_CHECK_RESULT(vkQueueWaitIdle(queue)); - } - }; /* @@ -936,16 +919,20 @@ public: { VulkanExampleBase::prepareFrame(); + std::vector commandBuffers = { + drawCmdBuffers[currentBuffer] + }; + if (textOverlay->visible) { + commandBuffers.push_back(textOverlay->cmdBuffers[currentBuffer]); + } + // Command buffer to be sumitted to the queue - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; + submitInfo.commandBufferCount = static_cast(commandBuffers.size()); + submitInfo.pCommandBuffers = commandBuffers.data(); // Submit to queue VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); - // Submit text overlay to queue - textOverlay->submit(queue, currentBuffer); - VulkanExampleBase::submitFrame(); }