Lugdunum  0.1.0
DeviceMemory.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <vector>
5 
7 
8 namespace lug {
9 namespace Graphics {
10 namespace Vulkan {
11 namespace API {
12 
13 class Buffer;
14 class Device;
15 class Image;
16 
17 namespace Builder {
18 
19 class DeviceMemory {
20 public:
21  DeviceMemory(const API::Device& deviceMemory);
22 
23  DeviceMemory(const DeviceMemory&) = delete;
24  DeviceMemory(DeviceMemory&&) = delete;
25 
26  DeviceMemory& operator=(const DeviceMemory&) = delete;
27  DeviceMemory& operator=(DeviceMemory&&) = delete;
28 
29  ~DeviceMemory() = default;
30 
31  // Setters
32  void setMemoryFlags(VkMemoryPropertyFlags flags);
33 
34  bool addBuffer(API::Buffer& buffer);
35  bool addImage(API::Image& image);
36 
37  // Build methods
38  bool build(API::DeviceMemory& instance, VkResult* returnResult = nullptr);
39  std::unique_ptr<API::DeviceMemory> build(VkResult* returnResult = nullptr);
40 
41 public:
42  static uint32_t findMemoryType(const API::Device& device, uint32_t memoryTypeBits, VkMemoryPropertyFlags requiredFlags);
43 
44 private:
46 
47  VkMemoryPropertyFlags _memoryFlags{VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT};
48  uint32_t _memoryTypeBits{0xFFFFFFFF};
49 
50  std::vector<API::Buffer*> _buffers;
51  std::vector<API::Image*> _images;
52 };
53 
55 
56 } // Builder
57 } // API
58 } // Vulkan
59 } // Graphics
60 } // lug
bool build(API::DeviceMemory &instance, VkResult *returnResult=nullptr)
static uint32_t findMemoryType(const API::Device &device, uint32_t memoryTypeBits, VkMemoryPropertyFlags requiredFlags)
void setMemoryFlags(VkMemoryPropertyFlags flags)
Definition: DeviceMemory.inl:1
DeviceMemory & operator=(const DeviceMemory &)=delete
DeviceMemory(const API::Device &deviceMemory)