MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ transfer_format()

std::optional< ImageFormat > MayaFlux::Portal::Graphics::TextureLoom::transfer_format ( const std::shared_ptr< Core::VKImage > &  image,
vk::ImageUsageFlagBits  required_usage 
)
staticprivate

Definition at line 1029 of file TextureLoom.cpp.

1032{
1033 if (!image || !image->is_initialized()) {
1034 return std::nullopt;
1035 }
1036
1037 if (image->get_type() != Core::VKImage::Type::TYPE_2D
1038 || image->get_depth() != 1 || image->get_array_layers() != 1) {
1039 return std::nullopt;
1040 }
1041
1042 if (!static_cast<bool>(image->get_usage_flags() & required_usage)) {
1043 return std::nullopt;
1044 }
1045
1046 const auto aspects = image->get_aspect_flags();
1047 if (static_cast<bool>(aspects & vk::ImageAspectFlagBits::eDepth)
1048 && static_cast<bool>(aspects & vk::ImageAspectFlagBits::eStencil)) {
1049 return std::nullopt;
1050 }
1051
1052 const auto format = from_vulkan_format(image->get_format());
1053 if (!format) {
1054 return std::nullopt;
1055 }
1056
1057 const size_t byte_count = calculate_image_size(image->get_width(), image->get_height(), 1, *format);
1058 if (byte_count == 0 || byte_count > image->get_size_bytes()) {
1059 return std::nullopt;
1060 }
1061
1062 return format;
1063}
IO::ImageData image
Definition Decoder.cpp:47
bool format
static size_t calculate_image_size(uint32_t width, uint32_t height, uint32_t depth, ImageFormat format)
Calculate image data size.
static std::optional< ImageFormat > from_vulkan_format(vk::Format vk_format)
Convert Vulkan format to Portal ImageFormat.

References calculate_image_size(), format, from_vulkan_format(), image, and MayaFlux::Core::VKImage::TYPE_2D.

Referenced by readable_format(), and writable_format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: