From e5eed5bdfa01cf549436c6001eaf334d266acc40 Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Sat, 14 Sep 2024 22:38:51 -0700 Subject: fix lifetime problem --- src/vulkan_helper.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/vulkan_helper.h') diff --git a/src/vulkan_helper.h b/src/vulkan_helper.h index ebdd691..c2b1c8c 100644 --- a/src/vulkan_helper.h +++ b/src/vulkan_helper.h @@ -23,14 +23,13 @@ struct Buffer_t { VkBuffer buffer; VmaAllocator allocator; VmaAllocation allocation; - VkBufferUsageFlags flags; VkDeviceSize size; void *mapped_data = nullptr; - ~Buffer_t(); void* map(); void unmap(); + void release(); }; typedef std::shared_ptr Buffer; @@ -45,7 +44,7 @@ struct Texture2D_t { VkImageUsageFlags flags; VkExtent2D extent; - ~Texture2D_t(); + void release(); }; typedef std::shared_ptr Texture2D; @@ -60,12 +59,21 @@ struct CommandBuffer { VkQueue queue; CommandBuffer(VkDevice device, uint32_t queue_family_index, VkQueue queue); - ~CommandBuffer(); - + void destroy(); void begin(VkCommandBufferUsageFlags flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT); void submit_sync(); }; +struct AsyncCommandBuffer { + VkDevice device; + VkCommandPool pool; + VkCommandBuffer buffer; + VkQueue queue; + + AsyncCommandBuffer(VkDevice device, uint32_t queue_family_index, VkQueue queue); + void destroy(); +}; + struct Device { VkInstance instance; VkPhysicalDevice physical_device; @@ -75,6 +83,7 @@ struct Device { VmaAllocator allocator; #ifdef USE_VULKAN_VALIDATION_LAYERS VkDebugReportCallbackEXT debugReportCallback; + VkDebugUtilsMessengerEXT debugUtilsMessenger; #endif Device() = delete; @@ -122,6 +131,7 @@ struct Device { }); CommandBuffer create_command_buffer(); + AsyncCommandBuffer create_async_command_buffer(); }; } // namespace iris \ No newline at end of file -- cgit v1.2.3-70-g09d2