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 class VulkanImageData : public Image
51 {
52 public:
55 VulkanImageData(const ConstPointer<VulkanDevice>& instance, const String& image_id, uint04 mip_map_depth);
56 VulkanImageData(const ConstPointer<VulkanDevice>& instance, Buffer<String>& image_ids, uint04 mip_map_depth);
57 VulkanImageData(const ConstPointer<VulkanDevice>& instance, VkImage image, Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, bool image_owner);
58 VulkanImageData(const ConstPointer<VulkanDevice>& instance, Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
60 void clear(const RGBColor& color = RGBColor(0,0,0,0), VkCommandBuffer_T* command = nullptr);
61 uint04 mipMapDepth() const { return m_mip_map_depth; };
62 void setMipMapDepth(uint04 depth) { m_mip_map_depth = depth; };
63
64 uint04 arrayLayers() const { return m_array_layers; }
65 void setArrayLayers(uint04 array_layers) { m_array_layers = array_layers; }
66
67 const Time& modifiedTime() const { return m_modified_time; }
69 VkFormat getFormat() const;
70 void setFormat(VkFormat format);
71
72 void setDevice(const ConstPointer<VulkanDevice>& instance);
73 void cleanup(bool destroy_memory = true);
74 Vector<2, uint04> size() const final override;
75 ConstPointer<VulkanDevice> device() const { return m_device; }
76
77 VkImage vulkanImage() const { return m_vulkan_image; };
78 VkDeviceMemory vkMemory() const { return m_image_memory; }
79 static VkSampleCountFlagBits getSampleBitflags(uint04 multi_sample_count);
80 void setImageProperties(Vector<2, uint04> size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
81
82 void transitionImageLayout(VkImageLayout newLayout, VkCommandBuffer_T* command = nullptr);
83 void transitionImageLayout(VkImageLayout newLayout, uint04 miplevel, uint04 level, VkCommandBuffer_T* command = nullptr);
84 void setMultiSampleCount(uint04 count) { m_multi_sample_count = count; };
85 void setData(const String& image_id, uint04 layer);
86 void setData(const VulkanBuffer& buffer, uint04 mip_level, uint04 image_data, VkCommandBuffer_T* command = nullptr);
87 void setData(VkImage image, bool image_owner);
88 bool hasAlpha() const { return m_has_alpha; }
89 void rawSetLayout(VkImageLayout layout);
90 VkImageLayout layout(uint04 mip_level = 0) const;
91
92 public:
93 void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
94 private:
95 uint04 computeOffset(uint04 mip_level, uint04 image_layer);
96 VkImage m_vulkan_image;
97 Time m_modified_time;
98 Vector<2, uint04> m_size;
99 uint04 m_allocated_size;
100 VkDeviceMemory m_image_memory;
102 uint08 m_layout[32];
103 uint08 m_format;
104 uint04 m_mip_map_depth;
105 uint04 m_array_layers;
106 uint04 m_multi_sample_count;
107 bool m_has_alpha;
108 bool m_image_owner;
109 };
110
124
126 {
127 public:
128 VulkanImageView(const ConstPointer<VulkanImageData>& data, uint04 aspectFlags, bool create = true);
131 bool needsUpdate() const;
132 void create();
133 VkImageView vkImageView() const { return m_view; }
134 void cleanup();
135 private:
136 VkImageView m_view;
137 Time m_modified_time;
139 uint04 m_aspect_flags;
140 };
141}
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:64
Definition GraphicsPipeline.h:42
Definition Dictionary.h:48
Definition Image.h:39
Represents a color in the RGB space with optional alpha transparency.
Definition RGBColor.h:53
Definition String.h:40
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
An element of a vector space. An element of the real coordinate space Rn Basis vector,...
Definition Vector.hpp:62
Definition VulkanBuffer.h:43
Definition VulkanDevice.h:8
Definition VulkanImage.h:51
VulkanImageData(const ConstPointer< VulkanDevice > &instance)
Definition VulkanImage.cpp:22
void transitionImageLayout(VkImageLayout newLayout, VkCommandBuffer_T *command=nullptr)
Definition VulkanImage.cpp:335
Vector< 2, uint04 > size() const final override
Definition VulkanImage.cpp:159
static VkSampleCountFlagBits getSampleBitflags(uint04 multi_sample_count)
Definition VulkanImage.cpp:248
void setMipMapDepth(uint04 depth)
Definition VulkanImage.h:62
void setDevice(const ConstPointer< VulkanDevice > &instance)
Definition VulkanImage.cpp:139
VkImageLayout layout(uint04 mip_level=0) const
Definition VulkanImage.cpp:272
const Time & modifiedTime() const
Definition VulkanImage.h:67
void setFormat(VkFormat format)
Definition VulkanImage.cpp:18
uint04 arrayLayers() const
Definition VulkanImage.h:64
void rawSetLayout(VkImageLayout layout)
Definition VulkanImage.cpp:267
uint04 mipMapDepth() const
Definition VulkanImage.h:61
void clear(const RGBColor &color=RGBColor(0, 0, 0, 0), VkCommandBuffer_T *command=nullptr)
Definition VulkanImage.cpp:131
VkFormat getFormat() const
Definition VulkanImage.cpp:14
void setData(const String &image_id, uint04 layer)
Definition VulkanImage.cpp:163
ConstPointer< VulkanDevice > device() const
Definition VulkanImage.h:75
void setImageProperties(Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Definition VulkanImage.cpp:259
void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Definition VulkanImage.cpp:276
VkDeviceMemory vkMemory() const
Definition VulkanImage.h:78
~VulkanImageData()
Definition VulkanImage.cpp:126
VkImage vulkanImage() const
Definition VulkanImage.h:77
void cleanup(bool destroy_memory=true)
Definition VulkanImage.cpp:143
Vector< 2, uint04 > getMipSize(uint04 level) const
Definition VulkanImage.cpp:10
void setArrayLayers(uint04 array_layers)
Definition VulkanImage.h:65
void setMultiSampleCount(uint04 count)
Definition VulkanImage.h:84
bool hasAlpha() const
Definition VulkanImage.h:88
Definition VulkanImage.h:112
VulkanImageManager(const ConstPointer< VulkanDevice > &instance)
Definition VulkanImage.cpp:555
~VulkanImageManager()
Definition VulkanImage.cpp:559
ConstPointer< VulkanDevice > m_device
Definition VulkanImage.h:121
bool updateImages()
Definition VulkanImage.cpp:564
Dictionary< String, DynamicPointer< VulkanImageData > > m_file_map
Definition VulkanImage.h:120
ConstPointer< VulkanImageData > getImage(const String &file)
Definition VulkanImage.cpp:587
uint04 m_mip_map_depth
Definition VulkanImage.h:122
bool needsImageUpdate() const
Definition VulkanImage.cpp:577
Definition VulkanImage.h:126
void cleanup()
Definition VulkanImage.cpp:535
bool needsUpdate() const
Definition VulkanImage.cpp:551
~VulkanImageView()
Definition VulkanImage.cpp:547
VkImageView vkImageView() const
Definition VulkanImage.h:133
void create()
Definition VulkanImage.cpp:516
VulkanImageView(const ConstPointer< VulkanImageData > &data, uint04 aspectFlags, bool create=true)
Definition VulkanImage.cpp:501
Definition ACIColor.h:37
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer -Can represent exact integer values 0 thro...
Definition BaseValues.hpp:132
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:120