From dd5b64e35661f83240f360897c381a4456ed3db0 Mon Sep 17 00:00:00 2001 From: saschawillems Date: Sun, 5 Jun 2016 20:21:00 +0200 Subject: [PATCH] Refactoring, removed device wait idles --- multisampling/multisampling.cpp | 42 +++++++++++++-------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/multisampling/multisampling.cpp b/multisampling/multisampling.cpp index 7276c979..bb475e50 100644 --- a/multisampling/multisampling.cpp +++ b/multisampling/multisampling.cpp @@ -144,7 +144,7 @@ public: VkMemoryAllocateInfo memAlloc = vkTools::initializers::memoryAllocateInfo(); memAlloc.allocationSize = memReqs.size; // We prefer a lazily allocated memory type - // This means that the memory get allocated when the implementation sees fit, e.g. when first using the images + // This means that the memory gets allocated when the implementation sees fit, e.g. when first using the images VkBool32 lazyMemType = getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, &memAlloc.memoryTypeIndex); if (!lazyMemType) { @@ -401,27 +401,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)); - - VK_CHECK_RESULT(vkQueueWaitIdle(queue)); - } - void loadTextures() { textureLoader->loadTexture( @@ -649,8 +628,9 @@ public: // Vertex shader uniform buffer block createBuffer( VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, sizeof(uboVS), - &uboVS, + nullptr, &uniformData.vsScene.buffer, &uniformData.vsScene.memory, &uniformData.vsScene.descriptor); @@ -679,6 +659,20 @@ public: vkUnmapMemory(device, uniformData.vsScene.memory); } + void draw() + { + VulkanExampleBase::prepareFrame(); + + // 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)); + + VulkanExampleBase::submitFrame(); + } + void prepare() { VulkanExampleBase::prepare(); @@ -698,9 +692,7 @@ public: { if (!prepared) return; - vkDeviceWaitIdle(device); draw(); - vkDeviceWaitIdle(device); updateUniformBuffers(); }