#include "camera.h"
/* defines */
-#define FRAME_LAG 2
#define FENCE_TIMEOUT UINT64_MAX
/**************************/
/* for the moment: one cmd buffer per swapchain image */
static std::vector<VkCommandBuffer>vk_cmd_buffers;
static std::vector<VkFence>vk_fences;
-static struct vk_semaphores vk_semas[FRAME_LAG];
+static struct vk_semaphores *vk_semas;
/* FIXME make them part of each object's functions/params */
static struct vk_renderer vk_rnd;
abort();
}
- vk_frame_idx = (vk_frame_idx + 1) % FRAME_LAG;
+ vk_frame_idx = (vk_frame_idx + 1) % (vk_chain.num_images - 1);
printf("display %d\n", count++);
printf("current image %u\n", vk_current_image);
static void
vk_cleanup()
{
+ int num_images = vk_chain.num_images - 1;
+
vk_destroy_image(&vk_core, &vk_depth_att.obj);
vk_destroy_renderer(&vk_core, &vk_rnd);
vk_destroy_fences(&vk_core, vk_fences.size(), vk_fences.data());
vk_fences.clear();
- for (int i = 0; i < FRAME_LAG; i++)
+ for (int i = 0; i < num_images; i++)
vk_destroy_semaphores(&vk_core, &vk_semas[i]);
+ free(vk_semas);
for (size_t i = 0; i < vk_cmd_buffers.size(); i++)
vk_destroy_cmd_buffers(&vk_core, vk_cmd_buffers.size(), vk_cmd_buffers.data());
memset(&sinfo, 0, sizeof sinfo);
sinfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
- vk_fences.resize(FRAME_LAG, VK_NULL_HANDLE);
+ vk_fences.resize(vk_chain.num_images - 1, VK_NULL_HANDLE);
- for (int i = 0; i < FRAME_LAG; i++) {
+ vk_semas = (vk_semaphores *)malloc(sizeof(vk_semaphores) * (vk_chain.num_images - 1));
+ for (uint32_t i = 0; i < (vk_chain.num_images - 1); i++) {
if (vkCreateFence(vk_core.dev, &finfo, 0, &vk_fences[i]) != VK_SUCCESS) {
fprintf(stderr, "Failed to create fence: %d\n", i);
return false;