From 2ead02037dc89e987fbc0a021fe470e29d226cfd Mon Sep 17 00:00:00 2001 From: Chuyan Zhang Date: Sat, 7 Sep 2024 00:40:38 -0700 Subject: Add more encapsulation, use VMA for allocation --- src/vulkan_helper.h | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'src/vulkan_helper.h') diff --git a/src/vulkan_helper.h b/src/vulkan_helper.h index 089a09f..b6f270a 100644 --- a/src/vulkan_helper.h +++ b/src/vulkan_helper.h @@ -1,5 +1,8 @@ -#include +#include #include +#include + +#include #include #include @@ -15,16 +18,56 @@ namespace iris { +struct Buffer_t { + VkBuffer buffer; + VmaAllocator allocator; + VmaAllocation allocation; + + VkBufferUsageFlags flags; + VkDeviceSize size; + + ~Buffer_t(); +}; + +typedef std::shared_ptr Buffer; + +struct Texture2D_t { + VkImage image; + VmaAllocator allocator; + VmaAllocation allocation; + VkImageView image_view; + + VkImageUsageFlags flags; + VkExtent2D extent; + + ~Texture2D_t(); +}; + +typedef std::shared_ptr Texture2D; + struct Device { VkInstance instance; VkPhysicalDevice physical_device; VkDevice device; uint32_t main_queue_family_index; VkQueue graphics_queue; + VmaAllocator allocator; Device( std::vector layers, std::vector instance_extensions); + ~Device(); + + Buffer create_buffer( + VkDeviceSize size, + VkBufferUsageFlags usage, + VmaMemoryUsage memory_usage = VMA_MEMORY_USAGE_AUTO); + + Texture2D create_texture( + VkExtent2D extent, + VkFormat format, + VkImageUsageFlags usage, + VmaMemoryUsage memory_usage = VMA_MEMORY_USAGE_AUTO); }; } // namespace iris \ No newline at end of file -- cgit v1.2.3-70-g09d2