Skip to content

Commit 355c694

Browse files
authored
all: update present semaphores (Mrkol#39)
* 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 * hack lint ok let's try this peace of code
1 parent f3beb24 commit 355c694

5 files changed

Lines changed: 30 additions & 17 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,24 @@ jobs:
2525
- uses: ZedThree/clang-tidy-review@v0.21.0
2626
id: review
2727
with:
28-
apt_packages: 'wget,libx11-dev'
28+
apt_packages: 'sudo,wget,libx11-dev,xorg-dev,ca-certificates,gpg'
2929
build_dir: build
30-
cmake_command: | # Awful, dirty hacks to get the vulkan-sdk and cmake version we need
30+
install_commands: | # Awful, dirty hacks to get the vulkan-sdk and cmake version we need
3131
wget -qO- https://packages.lunarg.com/lunarg-signing-key-pub.asc | \
3232
tee /etc/apt/trusted.gpg.d/lunarg.asc && \
3333
wget -qO /etc/apt/sources.list.d/lunarg-vulkan-1.4.313-noble.list \
3434
https://packages.lunarg.com/vulkan/1.4.313/lunarg-vulkan-1.4.313-noble.list && \
35-
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main'\
36-
| sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
37-
apt update && \
38-
apt-get -y install libvulkan-dev vulkan-headers cmake && \
39-
cmake -Bbuild -S. -DCMAKE_EXPORT_COMPILE_COMMANDS=on
35+
(test -f /usr/share/doc/kitware-archive-keyring/copyright || \
36+
wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null \
37+
| gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null) && \
38+
echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ noble main' | \
39+
sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null && \
40+
sudo apt-get update && \
41+
(test -f /usr/share/doc/kitware-archive-keyring/copyright || \
42+
sudo rm /usr/share/keyrings/kitware-archive-keyring.gpg) && \
43+
apt-get -y install kitware-archive-keyring libvulkan-dev vulkan-headers cmake
44+
cmake_command: |
45+
cmake -Bbuild -S. -DCMAKE_EXPORT_COMPILE_COMMANDS=on -DGLFW_BUILD_WAYLAND=off
4046
clang_tidy_checks: '' # Use closest .clang-tidy config, not some weird default
4147
split_workflow: true # So that comments work with fork PRs
4248

cmake/thirdparty.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ CPMAddPackage(
5454
CPMAddPackage(
5555
NAME etna
5656
GITHUB_REPOSITORY AlexandrShcherbakov/etna
57-
VERSION 1.10.1
57+
VERSION 1.11.0
5858
)
5959

6060
# Type-erased function containers that actually work

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, backbufferReadyForPresentSem] =
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
164+
// is ready, and the result image will be ready for present after backbufferReadyForPresent
165+
// is signalled by GPU
166+
auto renderingDone = commandManager->submit(
167+
std::move(currentCmdBuf),
168+
std::move(backbufferAvailableSem),
169+
std::move(backbufferReadyForPresentSem));
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)