Lugdunum  0.1.0
Buffer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 
7 
8 namespace lug {
9 namespace Graphics {
10 namespace Vulkan {
11 namespace API {
12 
13 namespace Builder {
14 class Buffer;
15 } // Builder
16 
17 class CommandBuffer;
18 class Device;
19 class DeviceMemory;
20 
22  friend class Builder::Buffer;
23 
24 public:
25  Buffer() = default;
26 
27  Buffer(const Buffer&) = delete;
28  Buffer(Buffer&& buffer);
29 
30  Buffer& operator=(const Buffer&) = delete;
31  Buffer& operator=(Buffer&& buffer);
32 
33  ~Buffer();
34 
35  explicit operator VkBuffer() const {
36  return _buffer;
37  }
38 
39  void destroy();
40 
41  void bindMemory(const DeviceMemory& deviceMemory, VkDeviceSize memoryOffset = 0);
42 
43  bool updateData(const void *data, VkDeviceSize size, VkDeviceSize offset = 0) const;
44 
45  const VkMemoryRequirements& getRequirements() const;
46  const DeviceMemory* getDeviceMemory() const;
47  VkDeviceSize getDeviceMemoryOffset() const;
48 
49 private:
50  explicit Buffer(VkBuffer Buffer, const Device* device);
51 
52 private:
53  VkBuffer _buffer{VK_NULL_HANDLE};
54  const Device* _device{nullptr};
55 
56  const DeviceMemory* _deviceMemory{nullptr};
57  VkDeviceSize _deviceMemoryOffset{0};
58 
59  VkMemoryRequirements _requirements{};
60 };
61 
63 
64 } // API
65 } // Vulkan
66 } // Graphics
67 } // lug
#define LUG_GRAPHICS_API
Definition: Export.hpp:11