summaryrefslogtreecommitdiff
path: root/include/resources/buffer.h
diff options
context:
space:
mode:
authorChuyan Zhang <chuyan@ucsb.edu>2024-10-10 18:51:05 -0700
committerChuyan Zhang <chuyan@ucsb.edu>2024-10-10 18:51:05 -0700
commit6271f5ce797bf12be64c710b66b1b9e93a239829 (patch)
tree44cc6a5ab5a20f7e55829f18b68a9f1191dac81d /include/resources/buffer.h
parentba27f3c22e79b91a2573b7efd00c5a3bbdb96dbc (diff)
downloadiris-main.tar.gz
iris-main.zip
move to new resource abstractionHEADmain
Diffstat (limited to 'include/resources/buffer.h')
-rw-r--r--include/resources/buffer.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/include/resources/buffer.h b/include/resources/buffer.h
new file mode 100644
index 0000000..7c6fe0e
--- /dev/null
+++ b/include/resources/buffer.h
@@ -0,0 +1,37 @@
+#pragma once
+
+#include <cstdint>
+#include <memory>
+#include <optional>
+#include <vk_mem_alloc.h>
+#include <vulkan/vulkan_core.h>
+namespace iris {
+
+struct BufferDesc {
+ uint64_t size;
+ std::optional<uint64_t> alignment;
+ VkBufferUsageFlags buffer_usage;
+ VmaMemoryUsage memory_usage;
+};
+
+struct Buffer_tt {
+ VkBuffer handle;
+ BufferDesc desc;
+
+ // Used during release
+ VkDevice device;
+ VmaAllocator allocator;
+ VmaAllocation allocation;
+ void release();
+
+ // Used during map/unmap
+ std::optional<void *> mapped_data;
+ void *map();
+ void unmap();
+
+ ~Buffer_tt() { release(); }
+};
+
+typedef std::shared_ptr<Buffer_tt> Buffer_s;
+
+} // namespace iris \ No newline at end of file