274 vk::ImageCreateInfo image_info;
276 image_info.imageType = vk::ImageType::e2D;
278 image_info.extent = VkExtent3D{
279 static_cast<uint32_t
>(desc.size.width),
280 static_cast<uint32_t
>(desc.size.height),
284 image_info.mipLevels = desc.mip_count;
286 image_info.tiling = vk::ImageTiling::eOptimal;
287 image_info.initialLayout = vk::ImageLayout::eUndefined;
289 desc.format, desc.usage, desc.storage_mode,
290 supports_memoryless_textures, supports_framebuffer_fetch);
291 image_info.sharingMode = vk::SharingMode::eExclusive;
293 VmaAllocationCreateInfo alloc_nfo = {};
296 alloc_nfo.preferredFlags =
298 desc.storage_mode, supports_memoryless_textures));
301 auto create_info_native =
302 static_cast<vk::ImageCreateInfo::NativeType
>(image_info);
304 VkImage vk_image = VK_NULL_HANDLE;
305 VmaAllocation allocation = {};
306 VmaAllocationInfo allocation_info = {};
308 auto result = vk::Result{::vmaCreateImage(allocator,
315 if (result != vk::Result::eSuccess) {
317 << vk::to_string(result)
321 <<
" [VK]Flags: " << vk::to_string(image_info.flags)
322 <<
" [VK]Format: " << vk::to_string(image_info.format)
323 <<
" [VK]Usage: " << vk::to_string(image_info.usage)
324 <<
" [VK]Mem. Flags: "
325 << vk::to_string(vk::MemoryPropertyFlags(
326 alloc_nfo.preferredFlags));
331 auto image = vk::Image{vk_image};
333 vk::ImageViewCreateInfo view_info = {};
334 view_info.image = image;
336 view_info.format = image_info.format;
338 view_info.subresourceRange.levelCount = image_info.mipLevels;
346 view_info.components.a = vk::ComponentSwizzle::eR;
347 view_info.components.r = vk::ComponentSwizzle::eA;
350 auto [result, image_view] = device.createImageViewUnique(view_info);
351 if (result != vk::Result::eSuccess) {
352 VALIDATION_LOG <<
"Unable to create an image view for allocation: "
353 << vk::to_string(result);
356 resource_.
Swap(ImageResource(ImageVMA{allocator, allocation, image},
357 std::move(image_view)));