11#pragma once
22
33#include < cstddef>
4+ #include < utility>
45
56#include < quark/utils/raii.hpp>
67#include < quark/utils/result.hpp>
8+ #include < quark/vk/allocator.hpp>
79#include < vk_mem_alloc.h>
810#include < vulkan/vulkan_core.h>
911
@@ -13,43 +15,35 @@ class Buffer final {
1315
1416public:
1517 struct CreateInfo {
16- VmaAllocator allocator = nullptr ;
18+ const Allocator * allocator = nullptr ;
1719 VkDeviceSize size{};
1820 VkBufferUsageFlags usage{};
19- VmaMemoryUsage memory_usage = VMA_MEMORY_USAGE_AUTO ;
21+ VmaMemoryUsage memory_usage{ VMA_MEMORY_USAGE_AUTO } ;
2022 VmaAllocationCreateFlags allocation_flags{};
21- VkSharingMode sharing_mode = VK_SHARING_MODE_EXCLUSIVE ;
23+ VkSharingMode sharing_mode{ VK_SHARING_MODE_EXCLUSIVE } ;
2224 };
2325
2426 Buffer () = default ;
2527 ~Buffer () { destroy (); }
2628
27- QUARK_NO_COPY (Buffer); // do we want copy or not?
29+ QUARK_NO_COPY (Buffer);
2830
2931 Buffer (Buffer &&other) noexcept
30- : allocator_(other.allocator_), buffer_(other.buffer_),
31- allocation_ (other.allocation_), size_(other.size_) {
32- other.allocator_ = nullptr ;
33- other.buffer_ = VK_NULL_HANDLE ;
34- other.allocation_ = nullptr ;
35- other.size_ = 0 ;
36- }
32+ : allocator_(std::exchange(other.allocator_, nullptr )),
33+ buffer_ (std::exchange(other.buffer_, VK_NULL_HANDLE )),
34+ allocation_(std::exchange(other.allocation_, nullptr )),
35+ size_(std::exchange(other.size_, 0 )) {}
3736
3837 Buffer &operator =(Buffer &&other) noexcept {
3938 if (this == &other) {
4039 return *this ;
4140 }
4241
4342 this ->destroy ();
44- allocator_ = other.allocator_ ;
45- buffer_ = other.buffer_ ;
46- allocation_ = other.allocation_ ;
47- size_ = other.size_ ;
48-
49- other.allocator_ = nullptr ;
50- other.buffer_ = VK_NULL_HANDLE ;
51- other.allocation_ = nullptr ;
52- other.size_ = 0 ;
43+ allocator_ = std::exchange (other.allocator_ , nullptr );
44+ buffer_ = std::exchange (other.buffer_ , VK_NULL_HANDLE );
45+ allocation_ = std::exchange (other.allocation_ , nullptr );
46+ size_ = std::exchange (other.size_ , 0 );
5347 return *this ;
5448 }
5549
0 commit comments