Skip to content

Commit 541ceec

Browse files
committed
all: update present semaphores
Now two sems are provided by Window::acquireNext() It fixes the validator errors and (I hope) clarifies a little how syncronization via semaphores works
1 parent f3beb24 commit 541ceec

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

samples/shadowmap/Renderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void Renderer::drawFrame()
139139
// but only on some platforms (not windows+nvidia, sadly).
140140
if (nextSwapchainImage)
141141
{
142-
auto [image, view, availableSem] = *nextSwapchainImage;
142+
auto [image, view, availableSem, readyForPresentSem] = *nextSwapchainImage;
143143

144144
ETNA_CHECK_VK_RESULT(currentCmdBuf.begin(vk::CommandBufferBeginInfo{}));
145145
{
@@ -167,7 +167,8 @@ void Renderer::drawFrame()
167167
}
168168
ETNA_CHECK_VK_RESULT(currentCmdBuf.end());
169169

170-
auto renderingDone = commandManager->submit(std::move(currentCmdBuf), std::move(availableSem));
170+
auto renderingDone = commandManager->submit(
171+
std::move(currentCmdBuf), std::move(availableSem), std::move(readyForPresentSem));
171172

172173
const bool presented = window->present(std::move(renderingDone), view);
173174

tasks/local_shadertoy1/App.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ void App::drawFrame()
111111
// because it kills the swapchain, so we skip frames in this case.
112112
if (nextSwapchainImage)
113113
{
114-
auto [backbuffer, backbufferView, backbufferAvailableSem] = *nextSwapchainImage;
114+
auto [backbuffer, backbufferView, backbufferAvailableSem, backbufferReadyForPresent] =
115+
*nextSwapchainImage;
115116

116117
ETNA_CHECK_VK_RESULT(currentCmdBuf.begin(vk::CommandBufferBeginInfo{}));
117118
{
@@ -158,10 +159,14 @@ void App::drawFrame()
158159
ETNA_CHECK_VK_RESULT(currentCmdBuf.end());
159160

160161
// We are done recording GPU commands now and we can send them to be executed by the GPU.
161-
// Note that the GPU won't start executing our commands before the semaphore is
162-
// signalled, which will happen when the OS says that the next swapchain image is ready.
163-
auto renderingDone =
164-
commandManager->submit(std::move(currentCmdBuf), std::move(backbufferAvailableSem));
162+
// Note that the GPU won't start executing our commands before the backbufferAvailableSem
163+
// semaphore is signalled, which will happen when the OS says that the next swapchain image is
164+
// ready, and the result image will be ready for present after backbufferReadyForPresent is
165+
// signalled by GPU
166+
auto renderingDone = commandManager->submit(
167+
std::move(currentCmdBuf),
168+
std::move(backbufferAvailableSem),
169+
std::move(backbufferReadyForPresent));
165170

166171
// Finally, present the backbuffer the screen, but only after the GPU tells the OS
167172
// that it is done executing the command buffer via the renderingDone semaphore.

tasks/model_bakery/renderer/Renderer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void Renderer::drawFrame()
101101

102102
if (nextSwapchainImage)
103103
{
104-
auto [image, view, availableSem] = *nextSwapchainImage;
104+
auto [image, view, availableSem, readyForPresentSem] = *nextSwapchainImage;
105105

106106
ETNA_CHECK_VK_RESULT(currentCmdBuf.begin(vk::CommandBufferBeginInfo{}));
107107
{
@@ -123,7 +123,8 @@ void Renderer::drawFrame()
123123
}
124124
ETNA_CHECK_VK_RESULT(currentCmdBuf.end());
125125

126-
auto renderingDone = commandManager->submit(std::move(currentCmdBuf), std::move(availableSem));
126+
auto renderingDone = commandManager->submit(
127+
std::move(currentCmdBuf), std::move(availableSem), std::move(readyForPresentSem));
127128

128129
const bool presented = window->present(std::move(renderingDone), view);
129130

0 commit comments

Comments
 (0)