#include "resources/image.h" #include "vulkan_helper.h" #include namespace iris { VkImageView Image_tt::get_image_view(const ImageViewDesc &desc) { auto it = image_views.find(desc); if (it != image_views.end()) { return it->second; } // Not found, create the image view VkImageViewCreateInfo view_create_info = { .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, .image = handle, .viewType = desc.view_type, .format = desc.format, .components = { .r = VK_COMPONENT_SWIZZLE_IDENTITY, .g = VK_COMPONENT_SWIZZLE_IDENTITY, .b = VK_COMPONENT_SWIZZLE_IDENTITY, .a = VK_COMPONENT_SWIZZLE_IDENTITY, }, .subresourceRange = { .aspectMask = desc.aspect_mask, .baseMipLevel = desc.base_mip_level, .levelCount = desc.mip_levels, .baseArrayLayer = desc.base_array_layer, .layerCount = desc.array_layers, }, }; VkImageView view; CHECK_VULKAN(vkCreateImageView( device, &view_create_info, nullptr, &view)); image_views[desc] = view; return view; } } // namespace iris