Lugdunum  0.1.0
Image.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <set>
5 
8 
9 namespace lug {
10 namespace Graphics {
11 namespace Vulkan {
12 namespace API {
13 
14 namespace Builder {
15 class Image;
16 } // Builder
17 
18 class Device;
19 class DeviceMemory;
20 
22  friend class Builder::Image;
23  friend class Swapchain;
24 
25 public:
26  // TODO: Declare offset and extent outside
27  struct Extent {
28  uint32_t width;
29  uint32_t height;
30  };
31 
32 public:
33  Image() = default;
34 
35  Image(const Image&) = delete;
36  Image(Image&& Image);
37 
38  Image& operator=(const Image&) = delete;
39  Image& operator=(Image&& Image);
40 
41  ~Image();
42 
43  explicit operator VkImage() const {
44  return _image;
45  }
46 
47  const Extent& getExtent() const {
48  return _extent;
49  }
50 
51  void destroy();
52 
53  void bindMemory(const DeviceMemory& deviceMemory, VkDeviceSize memoryOffset = 0);
54 
55  const VkMemoryRequirements& getRequirements() const;
56  const DeviceMemory* getDeviceMemory() const;
57  VkDeviceSize getDeviceMemoryOffset() const;
58  VkFormat getFormat() const;
59 
60  // Return first format supported by given features and tiling
61  static VkFormat findSupportedFormat(const Device& device, const std::set<VkFormat>& formats, VkImageTiling tiling, VkFormatFeatureFlags features);
62 
63 private:
64  explicit Image(VkImage Image, const Device* device, const Extent& extent, VkFormat format, bool swapchainImage);
65 
66  static bool isFormatSupported(const Device& device, VkFormat format, VkImageTiling tiling, VkFormatFeatureFlags features);
67 
68 private:
69  VkImage _image{VK_NULL_HANDLE};
70  const Device* _device{nullptr};
71 
72  const DeviceMemory* _deviceMemory{nullptr};
73  VkDeviceSize _deviceMemoryOffset{0};
74 
76  VkFormat _format;
77  VkImageAspectFlags _aspect;
79 
80  VkMemoryRequirements _requirements{};
81 };
82 
84 
85 } // API
86 } // Vulkan
87 } // Graphics
88 } // lug
VkImageAspectFlags _aspect
Definition: Image.hpp:77
#define LUG_GRAPHICS_API
Definition: Export.hpp:11
const Extent & getExtent() const
Definition: Image.hpp:47