Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions attachments/15_hello_triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,11 @@ class HelloTriangleApplication
vk::PipelineStageFlags waitDestinationStageMask(vk::PipelineStageFlagBits::eColorAttachmentOutput);
const vk::SubmitInfo submitInfo{.waitSemaphoreCount = 1, .pWaitSemaphores = &*presentCompleteSemaphore, .pWaitDstStageMask = &waitDestinationStageMask, .commandBufferCount = 1, .pCommandBuffers = &*commandBuffer, .signalSemaphoreCount = 1, .pSignalSemaphores = &*renderFinishedSemaphore};
queue.submit(submitInfo, *drawFence);
while (vk::Result::eTimeout == device.waitForFences(*drawFence, vk::True, UINT64_MAX))
;
result = device.waitForFences(*drawFence, vk::True, UINT64_MAX);
if (result != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}

const vk::PresentInfoKHR presentInfoKHR{.waitSemaphoreCount = 1, .pWaitSemaphores = &*renderFinishedSemaphore, .swapchainCount = 1, .pSwapchains = &*swapChain, .pImageIndices = &imageIndex};
result = queue.presentKHR(presentInfoKHR);
Expand Down
7 changes: 5 additions & 2 deletions attachments/16_frames_in_flight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
8 changes: 5 additions & 3 deletions attachments/17_swap_chain_recreation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand All @@ -521,7 +524,6 @@ class HelloTriangleApplication
throw std::runtime_error("failed to acquire swap chain image!");
}

device.resetFences(*inFlightFences[frameIndex]);
commandBuffers[frameIndex].reset();
recordCommandBuffer(imageIndex);

Expand Down
7 changes: 5 additions & 2 deletions attachments/18_vertex_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/19_vertex_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/20_staging_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/21_index_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,8 +606,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/22_descriptor_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/23_descriptor_sets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/24_texture_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/25_sampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/26_texture_mapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -903,8 +903,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/27_depth_buffering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1004,8 +1004,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/28_model_loading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/29_mipmapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,8 +1130,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/30_multisampling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1193,8 +1193,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
14 changes: 10 additions & 4 deletions attachments/31_compute_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,8 +811,11 @@ class ComputeShaderApplication
void drawFrame()
{
auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, nullptr, *inFlightFences[frameIndex]);
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

// Update timeline value for this frame
Expand Down Expand Up @@ -877,8 +880,11 @@ class ComputeShaderApplication
.pValues = &graphicsSignalValue};

// Wait for graphics to complete before presenting
while (vk::Result::eTimeout == device.waitSemaphores(waitInfo, UINT64_MAX))
;
auto result = device.waitSemaphores(waitInfo, UINT64_MAX);
if (result != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for semaphore!");
}

vk::PresentInfoKHR presentInfo{
.waitSemaphoreCount = 0, // No binary semaphores needed
Expand Down
7 changes: 5 additions & 2 deletions attachments/32_ecosystem_utilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1584,8 +1584,11 @@ class HelloTriangleApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
6 changes: 5 additions & 1 deletion attachments/33_vulkan_profiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,7 +1554,11 @@ class HelloTriangleApplication

void drawFrame()
{
static_cast<void>(device.waitForFences({*inFlightFences[frameIndex]}, VK_TRUE, UINT64_MAX));
vk::Result result = device.waitForFences({*inFlightFences[frameIndex]}, VK_TRUE, UINT64_MAX);
if (result != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}

uint32_t imageIndex;
try
Expand Down
7 changes: 5 additions & 2 deletions attachments/35_gltf_ktx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1393,8 +1393,11 @@ class VulkanApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/36_multiple_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1526,8 +1526,11 @@ class VulkanApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
7 changes: 5 additions & 2 deletions attachments/37_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1185,8 +1185,11 @@ class MultithreadedApplication
void drawFrame()
{
// Wait for the previous frame to finish
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}

// If the framebuffer was resized, rebuild the swap chain before acquiring a new image
if (framebufferResized)
Expand Down
7 changes: 5 additions & 2 deletions attachments/38_ray_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1823,8 +1823,11 @@ class VulkanRaytracingApplication
{
// Note: inFlightFences, presentCompleteSemaphores, and commandBuffers are indexed by frameIndex,
// while renderFinishedSemaphores is indexed by imageIndex
while (vk::Result::eTimeout == device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX))
;
auto fenceResult = device.waitForFences(*inFlightFences[frameIndex], vk::True, UINT64_MAX);
if (fenceResult != vk::Result::eSuccess)
{
throw std::runtime_error("failed to wait for fence!");
}
device.resetFences(*inFlightFences[frameIndex]);

auto [result, imageIndex] = swapChain.acquireNextImage(UINT64_MAX, *presentCompleteSemaphores[frameIndex], nullptr);
Expand Down
Loading
Loading