@@ -446,7 +446,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
446
446
return logFail (" Failed to Create Semaphores!" );
447
447
448
448
m_overflowSubmitsScratchSemaphoreInfo.semaphore = m_overflowSubmitScratchSemaphore.get ();
449
- m_overflowSubmitsScratchSemaphoreInfo.value = 1ull ;
449
+ m_overflowSubmitsScratchSemaphoreInfo.value = 0ull ;
450
450
451
451
// Let's just use the same queue since there's no need for async present
452
452
if (!m_surface)
@@ -777,21 +777,15 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
777
777
.stageMask = asset::PIPELINE_STAGE_FLAGS::ALL_COMMANDS_BITS
778
778
};
779
779
780
- const IQueue::SSubmitInfo::SSemaphoreInfo thisFrameRendered = {
781
- .semaphore = m_renderSemaphore.get (),
782
- .value = m_realFrameIx + 1u ,
783
- .stageMask = asset::PIPELINE_STAGE_FLAGS::ALL_COMMANDS_BITS
784
- };
785
-
786
780
IQueue::SSubmitInfo::SCommandBufferInfo cmdbufs[1u ] = { {.cmdbuf = m_commandBuffers[resourceIx].get () } };
787
781
IQueue::SSubmitInfo::SSemaphoreInfo waitSems[2u ] = { acquired, prevFrameRendered };
788
- IQueue::SSubmitInfo::SSemaphoreInfo singalSems[2u ] = { m_overflowSubmitsScratchSemaphoreInfo, thisFrameRendered };
789
782
790
- SIntendedSubmitInfo intendedNextSubmit;
791
- intendedNextSubmit.frontHalf .queue = getGraphicsQueue ();
792
- intendedNextSubmit.frontHalf .commandBuffers = cmdbufs;
793
- intendedNextSubmit.frontHalf .waitSemaphores = waitSems;
794
- intendedNextSubmit.signalSemaphores = singalSems;
783
+ SIntendedSubmitInfo intendedNextSubmit = {
784
+ .queue = getGraphicsQueue (),
785
+ .waitSemaphores = waitSems,
786
+ .commandBuffers = cmdbufs,
787
+ .scratchSemaphore = m_overflowSubmitsScratchSemaphoreInfo
788
+ };
795
789
796
790
addObjects (intendedNextSubmit);
797
791
@@ -919,7 +913,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
919
913
void submitDraws (SIntendedSubmitInfo& intendedSubmitInfo, bool inBetweenSubmit)
920
914
{
921
915
const auto resourceIx = m_realFrameIx%m_framesInFlight;
922
- auto * cb = intendedSubmitInfo.frontHalf . getScratchCommandBuffer ();
916
+ auto * cb = intendedSubmitInfo.getScratchCommandBuffer ();
923
917
auto &r = drawBuffer;
924
918
925
919
asset::SViewport vp =
@@ -1099,23 +1093,26 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
1099
1093
else
1100
1094
{
1101
1095
cb->end ();
1102
- IQueue::SSubmitInfo submitInfo = static_cast <IQueue::SSubmitInfo>(intendedSubmitInfo);
1103
- if (getGraphicsQueue ()->submit ({ &submitInfo, 1u }) == IQueue::RESULT::SUCCESS)
1096
+
1097
+ const auto nextFrameIx = m_realFrameIx+1u ;
1098
+ const IQueue::SSubmitInfo::SSemaphoreInfo thisFrameRendered = {
1099
+ .semaphore = m_renderSemaphore.get (),
1100
+ .value = nextFrameIx,
1101
+ .stageMask = asset::PIPELINE_STAGE_FLAGS::ALL_COMMANDS_BITS
1102
+ };
1103
+ if (getGraphicsQueue ()->submit (intendedSubmitInfo.popSubmit ({&thisFrameRendered,1 })) == IQueue::RESULT::SUCCESS)
1104
1104
{
1105
- m_realFrameIx++;
1106
- intendedSubmitInfo.advanceScratchSemaphoreValue (); // last submits needs to also advance scratch sema value like overflowSubmit() does
1105
+ m_realFrameIx = nextFrameIx;
1107
1106
1108
- IQueue::SSubmitInfo::SSemaphoreInfo renderFinished =
1109
- {
1110
- .semaphore = m_renderSemaphore.get (),
1111
- .value = m_realFrameIx,
1112
- .stageMask = PIPELINE_STAGE_FLAGS::COLOR_ATTACHMENT_OUTPUT_BIT
1113
- };
1114
- m_surface->present (m_currentImageAcquire.imageIndex , { &renderFinished, 1u });
1107
+ IQueue::SSubmitInfo::SSemaphoreInfo presentWait = thisFrameRendered;
1108
+ // the stages for a wait semaphore operation are about what stage you WAIT in, not what stage you wait for
1109
+ presentWait.stageMask = PIPELINE_STAGE_FLAGS::NONE; // top of pipe, there's no explicit presentation engine stage
1110
+ m_surface->present (m_currentImageAcquire.imageIndex ,{&presentWait,1 });
1115
1111
}
1116
1112
}
1117
1113
1118
- m_overflowSubmitsScratchSemaphoreInfo.value = intendedSubmitInfo.getScratchSemaphoreNextWait ().value ; // because we need this info consistent within frames
1114
+ // NOTE: one can just make `m_overflowSubmitsScratchSemaphoreInfo` a reference tied to `intendedSubmitInfo.scratchSemaphore
1115
+ m_overflowSubmitsScratchSemaphoreInfo.value = intendedSubmitInfo.scratchSemaphore .value ; // because we need this info consistent within frames
1119
1116
}
1120
1117
1121
1118
void endFrameRender (SIntendedSubmitInfo& intendedSubmitInfo)
@@ -1163,7 +1160,7 @@ class ComputerAidedDesign final : public examples::SimpleWindowedApplication, pu
1163
1160
}
1164
1161
1165
1162
// Use the last command buffer in intendedNextSubmit, it should be in recording state
1166
- auto * cmdbuf = intendedNextSubmit.frontHalf . getScratchCommandBuffer ();
1163
+ auto * cmdbuf = intendedNextSubmit.getScratchCommandBuffer ();
1167
1164
1168
1165
assert (cmdbuf->getState () == video::IGPUCommandBuffer::STATE::RECORDING && cmdbuf->isResettable ());
1169
1166
assert (cmdbuf->getRecordingFlags ().hasFlags (video::IGPUCommandBuffer::USAGE::ONE_TIME_SUBMIT_BIT));
0 commit comments