Refactoring, removed device wait idles

This commit is contained in:
saschawillems 2016-06-05 20:21:00 +02:00
parent 52a7da9ace
commit dd5b64e356

View file

@ -144,7 +144,7 @@ public:
VkMemoryAllocateInfo memAlloc = vkTools::initializers::memoryAllocateInfo(); VkMemoryAllocateInfo memAlloc = vkTools::initializers::memoryAllocateInfo();
memAlloc.allocationSize = memReqs.size; memAlloc.allocationSize = memReqs.size;
// We prefer a lazily allocated memory type // 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); VkBool32 lazyMemType = getMemoryType(memReqs.memoryTypeBits, VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT, &memAlloc.memoryTypeIndex);
if (!lazyMemType) 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, &currentBuffer));
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() void loadTextures()
{ {
textureLoader->loadTexture( textureLoader->loadTexture(
@ -649,8 +628,9 @@ public:
// Vertex shader uniform buffer block // Vertex shader uniform buffer block
createBuffer( createBuffer(
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
sizeof(uboVS), sizeof(uboVS),
&uboVS, nullptr,
&uniformData.vsScene.buffer, &uniformData.vsScene.buffer,
&uniformData.vsScene.memory, &uniformData.vsScene.memory,
&uniformData.vsScene.descriptor); &uniformData.vsScene.descriptor);
@ -679,6 +659,20 @@ public:
vkUnmapMemory(device, uniformData.vsScene.memory); 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() void prepare()
{ {
VulkanExampleBase::prepare(); VulkanExampleBase::prepare();
@ -698,9 +692,7 @@ public:
{ {
if (!prepared) if (!prepared)
return; return;
vkDeviceWaitIdle(device);
draw(); draw();
vkDeviceWaitIdle(device);
updateUniformBuffers(); updateUniformBuffers();
} }