Mandrill 2025.6.0
Loading...
Searching...
No Matches
Image.h
1#pragma once
2
3#include "Common.h"
4
5#include "Device.h"
6#include "Log.h"
7
8namespace Mandrill
9{
14 class Image
15 {
16 public:
17 MANDRILL_NON_COPYABLE(Image)
18
19
32 MANDRILL_API Image(ptr<Device> pDevice, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevels,
33 VkSampleCountFlagBits samples, VkFormat format, VkImageTiling tiling,
34 VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
35
50 MANDRILL_API Image(ptr<Device> pDevice, uint32_t width, uint32_t height, uint32_t depth, uint32_t mipLevels,
51 VkSampleCountFlagBits samples, VkFormat format, VkImageTiling tiling,
52 VkImageUsageFlags usage, VkDeviceMemory memory, VkDeviceSize offset);
53
57 MANDRILL_API ~Image();
58
63 MANDRILL_API void createImageView(VkImageAspectFlags aspectFlags);
64
69 MANDRILL_API VkImage getImage() const
70 {
71 return mImage;
72 }
73
78 MANDRILL_API void setImageView(VkImageView imageView)
79 {
80 mImageView = imageView;
81 }
82
87 MANDRILL_API VkImageView getImageView() const
88 {
89 return mImageView;
90 }
91
96 MANDRILL_API VkDeviceMemory getMemory() const
97 {
98 return mMemory;
99 }
100
105 MANDRILL_API VkImageUsageFlags getUsage() const
106 {
107 return mUsage;
108 }
109
114 MANDRILL_API VkMemoryPropertyFlags getProperties() const
115 {
116 return mProperties;
117 }
118
123 MANDRILL_API void* getHostMap() const
124 {
125 if (!(mProperties & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) {
126 Log::Error("Unable to access host map of buffer that is not host coherent.");
127 return nullptr;
128 }
129 return mpHostMap;
130 }
131
136 MANDRILL_API VkFormat getFormat() const
137 {
138 return mFormat;
139 }
140
145 MANDRILL_API uint32_t getWidth() const
146 {
147 return mWidth;
148 }
149
154 MANDRILL_API uint32_t getHeight() const
155 {
156 return mHeight;
157 }
158
163 MANDRILL_API uint32_t getDepth() const
164 {
165 return mDepth;
166 }
167
172 MANDRILL_API uint32_t getMipLevels() const
173 {
174 return mMipLevels;
175 }
176
177 private:
178 ptr<Device> mpDevice;
179
180 VkImage mImage;
181 VkImageView mImageView;
182
183 VkImageUsageFlags mUsage;
184 VkMemoryPropertyFlags mProperties;
185
186 VkDeviceMemory mMemory;
187 bool mOwnMemory;
188 void* mpHostMap;
189
190 uint32_t mWidth;
191 uint32_t mHeight;
192 uint32_t mDepth;
193
194 uint32_t mMipLevels;
195 VkFormat mFormat;
196 VkImageTiling mTiling;
197 };
198} // namespace Mandrill
Image class for managing Vulkan images. This class handles the creation and destruction of images,...
Definition Image.h:15
MANDRILL_API ~Image()
Destructor for image.
Definition Image.cpp:78
MANDRILL_API VkImageView getImageView() const
Get the VkImageView handle.
Definition Image.h:87
MANDRILL_API VkDeviceMemory getMemory() const
Get the device memory.
Definition Image.h:96
MANDRILL_API VkFormat getFormat() const
Get the format of the image.
Definition Image.h:136
MANDRILL_API uint32_t getDepth() const
Get the depth of the image.
Definition Image.h:163
MANDRILL_API void * getHostMap() const
If the buffer memory is host-coherent, this returns the pointor to the memory.
Definition Image.h:123
MANDRILL_API VkMemoryPropertyFlags getProperties() const
Get the memory property flags.
Definition Image.h:114
MANDRILL_API VkImageUsageFlags getUsage() const
Get the image usage flags.
Definition Image.h:105
MANDRILL_API void setImageView(VkImageView imageView)
Use this function if image view is created externally.
Definition Image.h:78
MANDRILL_API void createImageView(VkImageAspectFlags aspectFlags)
Create a default image view for Image object.
Definition Image.cpp:97
MANDRILL_API VkImage getImage() const
Get the VkImage handle.
Definition Image.h:69
MANDRILL_API uint32_t getHeight() const
Get the height of the image.
Definition Image.h:154
MANDRILL_API uint32_t getWidth() const
Get the width of the image.
Definition Image.h:145
MANDRILL_API uint32_t getMipLevels() const
Get the mipmap levels of the image.
Definition Image.h:172