33#include "VulkanDefines.h"
34#include "VulkanDevice.h"
35#include <NDEVR/Image.h>
36#include <NDEVR/Pointer.h>
37#include <NDEVR/File.h>
38#include <NDEVR/RGBColor.h>
39#include <NDEVR/Dictionary.h>
40#include <NDEVR/Buffer.h>
42typedef uint32_t VkImageUsageFlags;
43typedef uint32_t VkMemoryPropertyFlags;
132 VkDeviceMemory
vkMemory()
const {
return m_image_memory; }
164 void setData(VkImage image,
bool image_owner);
183 void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
186 VkImage m_vulkan_image;
187 Time m_modified_time;
190 VkDeviceMemory m_image_memory;
196 uint04 m_multi_sample_count;
197 uint04 m_bytes_per_pixel = 4;
260 VkImage m_last_image;
The equivelent of std::vector but with a bit more control.
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
A hash-based key-value store, useful for quick associative lookups.
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
A root class that stores an an array of pixel data that can be displayed as an Image.
Represents a color in the RGB space with optional alpha transparency.
The core String View class for the NDEVR API.
Represents a timestamp with utilities for manipulation and conversion.
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
A GPU buffer managed through the Vulkan API, used for vertex, index, and uniform data.
A GraphicsDevice for managing Vulkan limitations and actions.
Vector< 2, uint04 > size() const final override
Returns the image dimensions.
void clear(const RGBColor &color=RGBColor(0, 0, 0, 0), VkCommandBuffer_T *command=nullptr)
Clears the image to the given color.
VkImageLayout layout(uint04 mip_level=0) const
Returns the current layout of the specified mip level.
VkFormat getFormat() const
Returns the Vulkan format of this image.
uint04 arrayLayers() const
Returns the number of array layers.
const Time & getModifiedTime() const
Returns the last modification time of the image data.
VulkanImageData(const ConstPointer< VulkanDevice > &instance)
Constructs an empty Vulkan image on the given device.
static VkSampleCountFlagBits getSampleBitflags(uint04 multi_sample_count)
Converts a multi-sample count to Vulkan sample count flags.
VkDeviceMemory vkMemory() const
Returns the device memory backing this image.
VulkanImageData(VulkanImageData &&instance) noexcept
Move constructor.
void setArrayLayers(uint04 array_layers)
Sets the number of array layers.
void rawSetLayout(VkImageLayout layout)
Directly sets the tracked layout without issuing a transition command.
VulkanImageData(const ConstPointer< VulkanDevice > &instance, const StringView &image_id, uint04 mip_map_depth)
Constructs a Vulkan image from a single image file.
void setData(const StringView &image_id, uint04 layer)
Loads image data from a file into a specific array layer.
void cleanup(bool destroy_memory=true)
Releases Vulkan resources.
void transitionImageLayout(VkImageLayout newLayout, uint04 miplevel, uint04 level, VkCommandBuffer_T *command=nullptr)
Transitions a specific mip level range to a new layout.
void setDevice(const ConstPointer< VulkanDevice > &instance)
Sets the Vulkan device for this image.
void createImage(VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Creates the Vulkan image object with the specified properties.
~VulkanImageData()
Destructor.
ConstPointer< VulkanDevice > device() const
Returns the Vulkan device.
Vector< 2, uint04 > getMipSize(uint04 level) const
Calculates the dimensions of a specific mip level.
VulkanImageData(const ConstPointer< VulkanDevice > &instance, VkImage image, Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, bool image_owner)
Constructs a Vulkan image wrapping an existing VkImage handle.
void setMipMapDepth(uint04 depth)
Sets the mip map depth.
void setMultiSampleCount(uint04 count)
Sets the multi-sample count.
void setData(VkImage image, bool image_owner)
Assigns an existing VkImage to this object.
VulkanImageData(const ConstPointer< VulkanDevice > &instance, Buffer< String > &image_ids, uint04 mip_map_depth)
Constructs a Vulkan image array from multiple image files.
uint04 mipMapDepth() const
Returns the mip map depth.
void checkAndUpdateMemory(VkMemoryPropertyFlags properties, bool bind_image)
Checks and updates the memory allocation to match the required properties.
bool hasAlpha() const
Returns whether the image has an alpha channel.
void setFormat(VkFormat format)
Sets the Vulkan format for this image.
VkImage vulkanImage() const
Returns the underlying VkImage handle.
VulkanImageData(const ConstPointer< VulkanDevice > &instance, Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Constructs a new Vulkan image with the given properties.
void transitionImageLayout(VkImageLayout newLayout, VkCommandBuffer_T *command=nullptr)
Transitions the entire image to a new layout.
void setImageProperties(Vector< 2, uint04 > size, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
Configures the image properties and allocates resources.
VulkanImageManager(const ConstPointer< VulkanDevice > &instance)
Constructs an image manager for the given device.
ConstPointer< VulkanDevice > m_device
The Vulkan device.
Time m_check_time
The last time images were checked for updates.
~VulkanImageManager()
Destructor.
ConstPointer< VulkanImageData > getImage(const StringView &file)
Retrieves or loads a Vulkan image from a file path.
bool updateImages()
Updates all managed images that have changed on disk.
uint04 m_mip_map_depth
The mip map depth used for new images.
Dictionary< String, DynamicPointer< VulkanImageData > > m_file_map
Maps file paths to loaded image data.
bool needsImageUpdate(Time time)
Checks whether any images need updating since the given time.
bool needsUpdate() const
Checks whether the view needs to be recreated due to image changes.
void create()
Creates or recreates the Vulkan image view.
VkImageView vkImageView() const
Returns the underlying Vulkan image view handle.
VulkanImageView(const ConstPointer< VulkanImageData > &data, uint04 aspectFlags, bool create=true)
Constructs an image view for the given image data.
~VulkanImageView()
Destructor.
void cleanup()
Releases the Vulkan image view resources.
VulkanImageView(VulkanImageView &&old)
Move constructor.
The connection between the NDEVR API and the Vulkan library.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ file
The source file path associated with this object.