Skip to content
Permalink
Browse files

- change SubmitCommands to handle all parts of the present

  • Loading branch information...
dpjudas committed Apr 11, 2019
1 parent 095ea3c commit a0f618311a259fbafce9002be4b4d6c2262f9cb6
Showing with 32 additions and 32 deletions.
  1. +32 −32 src/rendering/vulkan/system/vk_framebuffer.cpp
@@ -160,8 +160,6 @@ void VulkanFrameBuffer::Update()

Flush3D.Clock();

presentImageIndex = swapChain->AcquireImage(GetClientWidth(), GetClientHeight(), mSwapChainImageAvailableSemaphore.get());

GetPostprocess()->SetActiveRenderTarget();

Draw2D();
@@ -170,29 +168,9 @@ void VulkanFrameBuffer::Update()
mRenderState->EndRenderPass();
mRenderState->EndFrame();

if (presentImageIndex != 0xffffffff)
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, true);

SubmitCommands(true);

Flush3D.Unclock();

FPSLimit();

Finish.Reset();
Finish.Clock();

if (presentImageIndex != 0xffffffff)
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());

vkWaitForFences(device->device, 1, &mRenderFinishedFence->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(device->device, 1, &mRenderFinishedFence->fence);

mDrawCommands.reset();
mTransferCommands.reset();
DeleteFrameObjects();

Finish.Unclock();
SubmitCommands(true);

Super::Update();
}
@@ -207,6 +185,16 @@ void VulkanFrameBuffer::DeleteFrameObjects()

void VulkanFrameBuffer::SubmitCommands(bool finish)
{
if (finish)
{
Finish.Reset();
Finish.Clock();

presentImageIndex = swapChain->AcquireImage(GetClientWidth(), GetClientHeight(), mSwapChainImageAvailableSemaphore.get());
if (presentImageIndex != 0xffffffff)
mPostprocess->DrawPresentTexture(mOutputLetterbox, true, true);
}

if (mTransferCommands)
{
mTransferCommands->end();
@@ -217,10 +205,12 @@ void VulkanFrameBuffer::SubmitCommands(bool finish)
submit.execute(device, device->graphicsQueue);
}

mDrawCommands->end();

QueueSubmit submit;
submit.addCommandBuffer(mDrawCommands.get());
if (mDrawCommands)
{
mDrawCommands->end();
submit.addCommandBuffer(mDrawCommands.get());
}
if (mTransferCommands)
{
submit.addWait(VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, mTransferSemaphore.get());
@@ -232,13 +222,23 @@ void VulkanFrameBuffer::SubmitCommands(bool finish)
}
submit.execute(device, device->graphicsQueue, mRenderFinishedFence.get());

if (!finish)
if (finish)
{
FPSLimit();

if (presentImageIndex != 0xffffffff)
swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get());
}

vkWaitForFences(device->device, 1, &mRenderFinishedFence->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(device->device, 1, &mRenderFinishedFence->fence);
mDrawCommands.reset();
mTransferCommands.reset();
DeleteFrameObjects();

if (finish)
{
vkWaitForFences(device->device, 1, &mRenderFinishedFence->fence, VK_TRUE, std::numeric_limits<uint64_t>::max());
vkResetFences(device->device, 1, &mRenderFinishedFence->fence);
mDrawCommands.reset();
mTransferCommands.reset();
DeleteFrameObjects();
Finish.Unclock();
}
}

0 comments on commit a0f6183

Please sign in to comment.
You can’t perform that action at this time.