API Documentation
Loading...
Searching...
No Matches
VulkanImage.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: VulkanImage
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanDevice.h"
37#include "Base/Headers/File.h"
41
42typedef uint32_t VkImageUsageFlags;
43typedef uint32_t VkMemoryPropertyFlags;
44namespace NDEVR
45{
46 class File;
47 class VulkanInstance;
48 class VulkanBuffer;
49 /**--------------------------------------------------------------------------------------------------
50 \brief A pointer to an Image and functions relating to that image within the Vulkan logic space.
51 **/
52 class VulkanImageData : public Image
53 {
54 public:
57 VulkanImageData(const ConstPointer<VulkanDevice>& instance, const String& image_id, uint04 mip_map_depth);
58 VulkanImageData(const ConstPointer<VulkanDevice>& instance, Buffer<String>& image_ids, uint04 mip_map_depth);
59 VulkanImageData(const ConstPointer<VulkanDevice>& instance, VkImage image, Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, bool image_owner);
60 VulkanImageData(const ConstPointer<VulkanDevice>& instance, Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
62 void clear(const RGBColor& color = RGBColor(0,0,0,0), VkCommandBuffer_T* command = nullptr);
63 uint04 mipMapDepth() const { return m_mip_map_depth; };
64 void setMipMapDepth(uint04 depth) { m_mip_map_depth = depth; };
65
66 uint04 arrayLayers() const { return m_array_layers; }
67 void setArrayLayers(uint04 array_layers) { m_array_layers = array_layers; }
68
69 const Time& modifiedTime() const { return m_modified_time; }
71 VkFormat getFormat() const;
72 void setFormat(VkFormat format);
73
75 void cleanup(bool destroy_memory = true);
76 Vector<2, uint04> size() const final override;
77 ConstPointer<VulkanDevice> device() const { return m_device; }
78
79 VkImage vulkanImage() const { return m_vulkan_image; };
80 VkDeviceMemory vkMemory() const { return m_image_memory; }
81 static VkSampleCountFlagBits getSampleBitflags(uint04 multi_sample_count);
82 void setImageProperties(Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
83
84 void transitionImageLayout(VkImageLayout newLayout, VkCommandBuffer_T* command = nullptr);
85 void transitionImageLayout(VkImageLayout newLayout, uint04 miplevel, uint04 level, VkCommandBuffer_T* command = nullptr);
86 void setMultiSampleCount(uint04 count) { m_multi_sample_count = count; };
87 void setData(const String& image_id, uint04 layer);
88 void setData(const VulkanBuffer& buffer, uint04 mip_level, uint04 image_data, VkCommandBuffer_T* command = nullptr);
89 void setData(VkImage image, bool image_owner);
90 bool hasAlpha() const { return m_has_alpha; }
91 void rawSetLayout(VkImageLayout layout);
92 VkImageLayout layout(uint04 mip_level = 0) const;
93
94 public:
95 void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
96 private:
97 uint04 computeOffset(uint04 mip_level, uint04 image_layer);
98 VkImage m_vulkan_image;
99 Time m_modified_time;
100 Vector<2, uint04> m_size;
101 uint04 m_allocated_size;
102 VkDeviceMemory m_image_memory;
104 uint08 m_layout[32];
105 uint08 m_format;
106 uint04 m_mip_map_depth;
107 uint04 m_array_layers;
108 uint04 m_multi_sample_count;
109 bool m_has_alpha;
110 bool m_image_owner;
111 };
112 /**--------------------------------------------------------------------------------------------------
113 \brief Manages all images within the Vulkan space.
114 **/
128 /**--------------------------------------------------------------------------------------------------
129 \brief Manages a view within the Vulkan logic space. See:
130 https://vulkan-tutorial.com/Drawing_a_triangle/Presentation/Image_views
131 **/
133 {
134 public:
135 VulkanImageView(const ConstPointer<VulkanImageData>& data, uint04 aspectFlags, bool create = true);
138 bool needsUpdate() const;
139 void create();
140 VkImageView vkImageView() const { return m_view; }
141 void cleanup();
142 private:
143 VkImageView m_view;
144 Time m_modified_time;
146 uint04 m_aspect_flags;
147 };
148}
uint64_t VkImageView
Definition ImageResources.h:41
uint32_t VkMemoryPropertyFlags
Definition VulkanImage.h:43
uint32_t VkImageUsageFlags
Definition VulkanImage.h:42
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition GraphicsPipeline.h:42
A hash-based key-value store, useful for quick associative lookups. Key features include:
Definition Dictionary.h:61
A root class that stores an an array of pixel data that can be displayed as an Image.
Definition Image.h:40
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:54
The core String class for the NDEVR API.
Definition String.h:69
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
A fixed-size array with better performance compared to dynamic containers.
Definition Vector.hpp:60
Stores bools to be sent to both the Vertex and Fragment shaders in the Vulkan space.
Definition VulkanBuffer.h:46
A GraphicsDevice for managing Vulkan limitations and actions. See: https://docs.vulkan....
Definition VulkanDevice.h:12
A pointer to an Image and functions relating to that image within the Vulkan logic space.
Definition VulkanImage.h:53
VulkanImageData(const ConstPointer< VulkanDevice > &instance)
void transitionImageLayout(VkImageLayout newLayout, VkCommandBuffer_T *command=nullptr)
Vector< 2, uint04 > size() const final override
void setMipMapDepth(uint04 depth)
Definition VulkanImage.h:64
void setDevice(const ConstPointer< VulkanDevice > &instance)
VkImageLayout layout(uint04 mip_level=0) const
static VkSampleCountFlagBits getSampleBitflags(uint04 multi_sample_count)
const Time & modifiedTime() const
Definition VulkanImage.h:69
void setFormat(VkFormat format)
uint04 arrayLayers() const
Definition VulkanImage.h:66
void rawSetLayout(VkImageLayout layout)
void setData(VkImage image, bool image_owner)
uint04 mipMapDepth() const
Definition VulkanImage.h:63
void clear(const RGBColor &color=RGBColor(0, 0, 0, 0), VkCommandBuffer_T *command=nullptr)
VkFormat getFormat() const
void setData(const String &image_id, uint04 layer)
ConstPointer< VulkanDevice > device() const
Definition VulkanImage.h:77
VulkanImageData(const ConstPointer< VulkanDevice > &instance, Buffer< String > &image_ids, uint04 mip_map_depth)
void setImageProperties(Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
VkDeviceMemory vkMemory() const
Definition VulkanImage.h:80
VulkanImageData(const ConstPointer< VulkanDevice > &instance, VkImage image, Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, bool image_owner)
VulkanImageData(const ConstPointer< VulkanDevice > &instance, const String &image_id, uint04 mip_map_depth)
void setData(const VulkanBuffer &buffer, uint04 mip_level, uint04 image_data, VkCommandBuffer_T *command=nullptr)
VkImage vulkanImage() const
Definition VulkanImage.h:79
void transitionImageLayout(VkImageLayout newLayout, uint04 miplevel, uint04 level, VkCommandBuffer_T *command=nullptr)
void cleanup(bool destroy_memory=true)
Vector< 2, uint04 > getMipSize(uint04 level) const
void setArrayLayers(uint04 array_layers)
Definition VulkanImage.h:67
VulkanImageData(VulkanImageData &&instance)
void setMultiSampleCount(uint04 count)
Definition VulkanImage.h:86
bool hasAlpha() const
Definition VulkanImage.h:90
VulkanImageData(const ConstPointer< VulkanDevice > &instance, Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Manages all images within the Vulkan space.
Definition VulkanImage.h:116
VulkanImageManager(const ConstPointer< VulkanDevice > &instance)
ConstPointer< VulkanDevice > m_device
Definition VulkanImage.h:125
Dictionary< String, DynamicPointer< VulkanImageData > > m_file_map
Definition VulkanImage.h:124
ConstPointer< VulkanImageData > getImage(const String &file)
uint04 m_mip_map_depth
Definition VulkanImage.h:126
bool needsImageUpdate() const
Manages a view within the Vulkan logic space. See: https://vulkan-tutorial.com/Drawing_a_triangle/Pre...
Definition VulkanImage.h:133
VulkanImageView(VulkanImageView &&old)
bool needsUpdate() const
VkImageView vkImageView() const
Definition VulkanImage.h:140
VulkanImageView(const ConstPointer< VulkanImageData > &data, uint04 aspectFlags, bool create=true)
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
Definition BaseValues.hpp:106
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96