diff --git a/computeparticles/computeparticles.cpp b/computeparticles/computeparticles.cpp index fa1e6acf..4c02e783 100644 --- a/computeparticles/computeparticles.cpp +++ b/computeparticles/computeparticles.cpp @@ -90,6 +90,7 @@ public: VulkanExample() : VulkanExampleBase(ENABLE_VALIDATION) { + enableTextOverlay = true; title = "Vulkan Example - Compute shader particle system"; } @@ -225,25 +226,6 @@ public: } - void draw() - { - // Get next image in the swap chain (back/front buffer) - VK_CHECK_RESULT(swapChain.acquireNextImage(semaphores.presentComplete, ¤tBuffer)); - - submitPostPresentBarrier(swapChain.buffers[currentBuffer].image); - - // Command buffer to be sumitted to the queue - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; - - // Submit to queue - VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); - - submitPrePresentBarrier(swapChain.buffers[currentBuffer].image); - - VK_CHECK_RESULT(swapChain.queuePresent(queue, currentBuffer, semaphores.renderComplete)); - } - // Setup and fill the compute shader storage buffers for // vertex positions and velocities void prepareStorageBuffers() @@ -590,6 +572,7 @@ public: // Compute shader uniform buffer block createBuffer( VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, sizeof(computeUbo), nullptr, &uniformData.computeShader.ubo.buffer, @@ -648,6 +631,17 @@ public: vkGetDeviceQueue(device, queueIndex, 0, &computeQueue); } + void draw() + { + VulkanExampleBase::prepareFrame(); + + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &drawCmdBuffers[currentBuffer]; + VK_CHECK_RESULT(vkQueueSubmit(queue, 1, &submitInfo, VK_NULL_HANDLE)); + + VulkanExampleBase::submitFrame(); + } + void prepare() { VulkanExampleBase::prepare(); @@ -684,7 +678,6 @@ public: } } - vkDeviceWaitIdle(device); updateUniformBuffers(); }