aboutsummaryrefslogtreecommitdiff
path: root/demos/cube.cpp
diff options
context:
space:
mode:
authorJeremy Hayes <jeremy@lunarg.com>2016-10-25 15:57:02 -0600
committerJeremy Hayes <jeremy@lunarg.com>2016-10-27 13:33:34 -0600
commit436226216ed8fe499fd32154624f0591dc27ad5b (patch)
treea1862d570cb08b0c4d9407967742672aeb9c49c4 /demos/cube.cpp
parent0852087a0a97e23d6e952a00b455842ac3c23550 (diff)
downloadusermoji-436226216ed8fe499fd32154624f0591dc27ad5b.tar.xz
cube.cpp: Remove excess tests from present fences
Instead of using a bool array and both checking and writing to it every frame for no reason, just create the presentation fences with the VK_FENCE_CREATE_SIGNALED_BIT flag. Change-Id: Icfa630a821bade51439ecbc6edddd4973d7bd4ed
Diffstat (limited to 'demos/cube.cpp')
-rw-r--r--demos/cube.cpp16
1 files changed, 4 insertions, 12 deletions
diff --git a/demos/cube.cpp b/demos/cube.cpp
index a0c7c477..419e01e7 100644
--- a/demos/cube.cpp
+++ b/demos/cube.cpp
@@ -234,7 +234,6 @@ struct Demo {
#elif defined(VK_USE_PLATFORM_XLIB_KHR) || defined(VK_USE_PLATFORM_XCB_KHR)
#elif defined(VK_USE_PLATFORM_WAYLAND_KHR)
#endif
- memset(fencesInited, 0, sizeof(bool) * FRAME_LAG);
memset(projection_matrix, 0, sizeof(projection_matrix));
memset(view_matrix, 0, sizeof(view_matrix));
memset(model_matrix, 0, sizeof(model_matrix));
@@ -293,9 +292,7 @@ struct Demo {
// Wait for fences from present operations
for (uint32_t i = 0; i < FRAME_LAG; i++) {
- if (fencesInited[i]) {
- device.waitForFences(1, &fences[i], VK_TRUE, UINT64_MAX);
- }
+ device.waitForFences(1, &fences[i], VK_TRUE, UINT64_MAX);
device.destroyFence(fences[i], nullptr);
device.destroySemaphore(image_acquired_semaphores[i], nullptr);
device.destroySemaphore(draw_complete_semaphores[i], nullptr);
@@ -400,17 +397,14 @@ struct Demo {
}
void draw() {
- if (fencesInited[frame_index]) {
- // Ensure no more than FRAME_LAG presentations are outstanding
- device.waitForFences(1, &fences[frame_index], VK_TRUE, UINT64_MAX);
- device.resetFences(1, &fences[frame_index]);
- }
+ // Ensure no more than FRAME_LAG presentations are outstanding
+ device.waitForFences(1, &fences[frame_index], VK_TRUE, UINT64_MAX);
+ device.resetFences(1, &fences[frame_index]);
// Get the index of the next available swapchain image:
auto result = device.acquireNextImageKHR(
swapchain, UINT64_MAX, image_acquired_semaphores[frame_index],
fences[frame_index], &current_buffer);
- fencesInited[frame_index] = true;
if (result == vk::Result::eErrorOutOfDateKHR) {
// swapchain is out of date (e.g. the window was resized) and
// must be recreated:
@@ -1163,7 +1157,6 @@ struct Demo {
vk::FenceCreateInfo const fence_ci;
for (uint32_t i = 0; i < FRAME_LAG; i++) {
device.createFence(&fence_ci, nullptr, &fences[i]);
- fencesInited[i] = false;
result = device.createSemaphore(&semaphoreCreateInfo, nullptr,
&image_acquired_semaphores[i]);
VERIFY(result == vk::Result::eSuccess);
@@ -2648,7 +2641,6 @@ struct Demo {
vk::SwapchainKHR swapchain;
std::unique_ptr<SwapchainBuffers[]> buffers;
vk::Fence fences[FRAME_LAG];
- bool fencesInited[FRAME_LAG];
uint32_t frame_index;
vk::CommandPool cmd_pool;