Consolidate Present as a special submit.

This commit is contained in:
Anish Bhobe 2025-05-07 18:27:13 +02:00
parent 1db942f1a9
commit 7351415ebf
3 changed files with 8 additions and 21 deletions

View File

@ -581,10 +581,7 @@ class Device final
return {m_Swapchain.m_Extent.width, m_Swapchain.m_Extent.height};
}
using Receipt = u32;
Receipt Submit(Frame &frame, GraphicsContext &graphicsContext);
void Present(Frame &frame);
void Present(Frame &frame, GraphicsContext &graphicsContext);
friend Context;
friend GraphicsContext;

View File

@ -980,13 +980,11 @@ systems::Device::GetNextFrame()
return currentFrame;
}
systems::Device::Receipt
systems::Device::Submit(Frame &frame, GraphicsContext &graphicsContext)
void
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::SubmitInfo submitInfo = {
const vk::SubmitInfo submitInfo = {
.waitSemaphoreCount = 1,
.pWaitSemaphores = &frame.m_ImageAcquireSem,
.pWaitDstStageMask = &waitDstStage,
@ -995,17 +993,11 @@ systems::Device::Submit(Frame &frame, GraphicsContext &graphicsContext)
.signalSemaphoreCount = 1,
.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)
THEN_ABORT(result);
return 0;
}
void
systems::Device::Present(Frame &frame)
{
vk::PresentInfoKHR presentInfo = {
const vk::PresentInfoKHR presentInfo = {
.waitSemaphoreCount = 1,
.pWaitSemaphores = &frame.m_RenderFinishSem,
.swapchainCount = 1,
@ -1013,7 +1005,7 @@ systems::Device::Present(Frame &frame)
.pImageIndices = &frame.m_ImageIdx,
.pResults = nullptr,
};
switch (auto result = m_GraphicsQueue.presentKHR(&presentInfo))
switch (result = m_GraphicsQueue.presentKHR(&presentInfo))
{
case vk::Result::eSuccess:
break;

View File

@ -184,9 +184,7 @@ main(int, char **)
context.End();
device.Submit(currentFrame, context);
device.Present(currentFrame);
device.Present(currentFrame, context);
}
device.WaitIdle();