Consolidate Present as a special submit.
This commit is contained in:
parent
1db942f1a9
commit
7351415ebf
|
|
@ -581,10 +581,7 @@ class Device final
|
||||||
return {m_Swapchain.m_Extent.width, m_Swapchain.m_Extent.height};
|
return {m_Swapchain.m_Extent.width, m_Swapchain.m_Extent.height};
|
||||||
}
|
}
|
||||||
|
|
||||||
using Receipt = u32;
|
void Present(Frame &frame, GraphicsContext &graphicsContext);
|
||||||
Receipt Submit(Frame &frame, GraphicsContext &graphicsContext);
|
|
||||||
|
|
||||||
void Present(Frame &frame);
|
|
||||||
|
|
||||||
friend Context;
|
friend Context;
|
||||||
friend GraphicsContext;
|
friend GraphicsContext;
|
||||||
|
|
|
||||||
|
|
@ -980,13 +980,11 @@ systems::Device::GetNextFrame()
|
||||||
return currentFrame;
|
return currentFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
systems::Device::Receipt
|
void
|
||||||
systems::Device::Submit(Frame &frame, GraphicsContext &graphicsContext)
|
systems::Device::Present(Frame &frame, GraphicsContext &graphicsContext)
|
||||||
{
|
{
|
||||||
// TODO Consider a semaphore pool that you can 'pick' a semaphore from and use for submits.
|
|
||||||
// This can be used as a wait-semaphore for the next submit if you say 'depends on'.
|
|
||||||
vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput;
|
vk::PipelineStageFlags waitDstStage = vk::PipelineStageFlagBits::eColorAttachmentOutput;
|
||||||
vk::SubmitInfo submitInfo = {
|
const vk::SubmitInfo submitInfo = {
|
||||||
.waitSemaphoreCount = 1,
|
.waitSemaphoreCount = 1,
|
||||||
.pWaitSemaphores = &frame.m_ImageAcquireSem,
|
.pWaitSemaphores = &frame.m_ImageAcquireSem,
|
||||||
.pWaitDstStageMask = &waitDstStage,
|
.pWaitDstStageMask = &waitDstStage,
|
||||||
|
|
@ -995,17 +993,11 @@ systems::Device::Submit(Frame &frame, GraphicsContext &graphicsContext)
|
||||||
.signalSemaphoreCount = 1,
|
.signalSemaphoreCount = 1,
|
||||||
.pSignalSemaphores = &frame.m_RenderFinishSem,
|
.pSignalSemaphores = &frame.m_RenderFinishSem,
|
||||||
};
|
};
|
||||||
auto result = m_GraphicsQueue.submit(1, &submitInfo, frame.m_FrameAvailableFence);
|
vk::Result result = m_GraphicsQueue.submit(1, &submitInfo, frame.m_FrameAvailableFence);
|
||||||
ERROR_IF(Failed(result), "Command queue submit failed. Cause: {}", result)
|
ERROR_IF(Failed(result), "Command queue submit failed. Cause: {}", result)
|
||||||
THEN_ABORT(result);
|
THEN_ABORT(result);
|
||||||
|
|
||||||
return 0;
|
const vk::PresentInfoKHR presentInfo = {
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
systems::Device::Present(Frame &frame)
|
|
||||||
{
|
|
||||||
vk::PresentInfoKHR presentInfo = {
|
|
||||||
.waitSemaphoreCount = 1,
|
.waitSemaphoreCount = 1,
|
||||||
.pWaitSemaphores = &frame.m_RenderFinishSem,
|
.pWaitSemaphores = &frame.m_RenderFinishSem,
|
||||||
.swapchainCount = 1,
|
.swapchainCount = 1,
|
||||||
|
|
@ -1013,7 +1005,7 @@ systems::Device::Present(Frame &frame)
|
||||||
.pImageIndices = &frame.m_ImageIdx,
|
.pImageIndices = &frame.m_ImageIdx,
|
||||||
.pResults = nullptr,
|
.pResults = nullptr,
|
||||||
};
|
};
|
||||||
switch (auto result = m_GraphicsQueue.presentKHR(&presentInfo))
|
switch (result = m_GraphicsQueue.presentKHR(&presentInfo))
|
||||||
{
|
{
|
||||||
case vk::Result::eSuccess:
|
case vk::Result::eSuccess:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -184,9 +184,7 @@ main(int, char **)
|
||||||
|
|
||||||
context.End();
|
context.End();
|
||||||
|
|
||||||
device.Submit(currentFrame, context);
|
device.Present(currentFrame, context);
|
||||||
|
|
||||||
device.Present(currentFrame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
device.WaitIdle();
|
device.WaitIdle();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue