2#include "../osi/foray_env.hpp"
6#include "../core/foray_managedimage.hpp"
8using namespace std::filesystem;
12 template <VkFormat FORMAT>
15 VkFormatProperties properties;
16 vkGetPhysicalDeviceFormatProperties(context->
VkbPhysicalDevice->physical_device, FORMAT, &properties);
17 if((properties.linearTilingFeatures & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT & VkFormatFeatureFlagBits::VK_FORMAT_FEATURE_TRANSFER_DST_BIT) > 0)
24 template <VkFormat FORMAT>
30 mInfo.Utf8Path = utf8path;
32 path fspath = utf8path;
33 if(fspath.has_extension())
37 if(fspath.has_filename())
47 if(mInfo.Extension ==
".exr")
49 return PopulateImageInfo_TinyExr();
53 return PopulateImageInfo_Stb();
57 template <VkFormat FORMAT>
62 logger()->warn(
"Image Loader: Invalid Image Info!");
66 if(mInfo.Extension ==
".exr")
68 return Load_TinyExr();
76 template <VkFormat FORMAT>
79 if(mCustomLoaderInfoDeleter && mCustomLoaderInfo)
81 mCustomLoaderInfoDeleter(mCustomLoaderInfo);
83 mCustomLoaderInfo =
nullptr;
84 mCustomLoaderInfoDeleter =
nullptr;
92 template <VkFormat FORMAT>
95 if(!mInfo.Valid || !mRawData.size())
100 UpdateManagedImageCI(ci);
102 image->
Create(context, ci);
103 WriteManagedImageData(image, afterwrite);
106 template <VkFormat FORMAT>
109 if(!mInfo.Valid || !mRawData.size())
114 UpdateManagedImageCI(ci);
116 image->
Create(context, ci);
117 WriteManagedImageData(cmdBuffer, image, afterwrite);
120 template <VkFormat FORMAT>
124 ci.
ImageCI.initialLayout = VkImageLayout::VK_IMAGE_LAYOUT_UNDEFINED;
125 ci.
ImageCI.usage = ci.
ImageCI.usage | VkImageUsageFlagBits::VK_IMAGE_USAGE_TRANSFER_DST_BIT;
126 ci.
ImageCI.extent = VkExtent3D{.width = mInfo.Extent.width, .height = mInfo.Extent.height, .depth = 1};
127 ci.
ImageCI.imageType = VkImageType::VK_IMAGE_TYPE_2D;
130 template <VkFormat FORMAT>
136 template <VkFormat FORMAT>
Extension of the commandbuffer wrapper for temporary host synchronized command buffer execution.
Definition foray_commandbuffer.hpp:41
Wraps allocation and lifetime functionality of VkImage.
Definition foray_managedimage.hpp:13
virtual void Create(Context *context, const CreateInfo &createInfo)
Allocates image, creates image, creates imageview.
void WriteDeviceLocalData(const void *data, size_t size, VkImageLayout layoutAfterWrite, VkBufferImageCopy &imageCopy)
Creates a staging buffer, writes staging buffer, transitions image layout to transfer destination opt...
Utf8 encoded path wrapper.
Definition foray_env.hpp:28
Definition foray_imageloader.hpp:34
void WriteManagedImageData(core::ManagedImage *image, VkImageLayout afterwrite) const
Definition foray_imageloader.inl:131
void UpdateManagedImageCI(core::ManagedImage::CreateInfo &ci) const
Definition foray_imageloader.inl:121
void Destroy()
Cleans up the loader.
Definition foray_imageloader.inl:77
bool Load()
Loads the file into CPU memory (Init first!)
Definition foray_imageloader.inl:58
static bool sFormatSupported(core::Context *context)
Checks if format the loader was initialized in supports linear tiling transfer and shader read.
Definition foray_imageloader.inl:13
bool Init(const osi::Utf8Path &utf8path)
Inits the image loader.
Definition foray_imageloader.inl:25
void InitManagedImage(core::Context *context, core::ManagedImage *image, core::ManagedImage::CreateInfo &ci, VkImageLayout afterwrite=VkImageLayout::VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL) const
Definition foray_imageloader.inl:93
std::string ToUtf8Path(std::filesystem::path path)
Convert std::filesystem::path type to UTF8 path.
Definition foray_dualbuffer.hpp:5
spdlog::logger * logger()
Gives access to a global available logger object. The logger writes to console & to a file next to th...
Non owning context object.
Definition foray_context.hpp:16
vkb::PhysicalDevice * VkbPhysicalDevice
A Vkb PhysicalDevice.
Definition foray_context.hpp:24
Combines all structs used for initialization.
Definition foray_managedimage.hpp:20
VkImageCreateInfo ImageCI
Vulkan Image CreateInfo.
Definition foray_managedimage.hpp:22