From d0047d6da557dbcf7bc432a22aa9bcf64ddafb1f Mon Sep 17 00:00:00 2001 From: Guillaume Meunier Date: Tue, 16 Jan 2024 21:28:37 +0100 Subject: [PATCH] Wait for fence before reusing the command buffer, create the command pool with the eResetCommandBuffer flag --- client/render/scene_data.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/render/scene_data.cpp b/client/render/scene_data.cpp index 80aa9d4c..e6b6e60b 100644 --- a/client/render/scene_data.cpp +++ b/client/render/scene_data.cpp @@ -514,13 +514,14 @@ public: auto & cb = command_buffers[index % num_images_in_flight]; auto & fence = fences[index % num_images_in_flight].first; + // Wait for the previous submit to finish before overwriting fences[...].second + device.waitForFences(*fence, true, 1'000'000'000); // TODO check for timeout + auto [image_data, mime_type] = visit_source(gltf_image.data); auto [image, resources] = do_load_image(device, cb, mime_type, image_data, srgb[index]); - // Wait for the previous submit to finish before overwriting fences[...].second - device.waitForFences(*fence, true, 1'000'000'000); // TODO check for timeout - device.resetFences(*fence); + device.resetFences(*fence); fences[index % num_images_in_flight].second = std::move(resources); images.emplace_back(std::make_shared(std::move(image))); @@ -802,7 +803,7 @@ scene_data scene_loader::operator()(const std::filesystem::path & gltf_path) { vk::PhysicalDeviceProperties physical_device_properties = physical_device.getProperties(); vk::raii::CommandPool cb_pool{device, vk::CommandPoolCreateInfo{ - .flags = vk::CommandPoolCreateFlagBits::eTransient, + .flags = vk::CommandPoolCreateFlagBits::eTransient | vk::CommandPoolCreateFlagBits::eResetCommandBuffer, .queueFamilyIndex = queue_family_index, }};