268 TRACE_EVENT0(
"impeller",
"CreateDeviceTexture");
269 vk::ImageCreateInfo image_info;
271 image_info.imageType = vk::ImageType::e2D;
273 image_info.extent = VkExtent3D{
274 static_cast<uint32_t
>(desc.size.width),
275 static_cast<uint32_t
>(desc.size.height),
279 image_info.mipLevels = desc.mip_count;
281 image_info.tiling = vk::ImageTiling::eOptimal;
282 image_info.initialLayout = vk::ImageLayout::eUndefined;
285 supports_memoryless_textures);
286 image_info.sharingMode = vk::SharingMode::eExclusive;
288 VmaAllocationCreateInfo alloc_nfo = {};
291 alloc_nfo.preferredFlags =
293 desc.storage_mode, supports_memoryless_textures));
296 auto create_info_native =
297 static_cast<vk::ImageCreateInfo::NativeType
>(image_info);
299 VkImage vk_image = VK_NULL_HANDLE;
300 VmaAllocation allocation = {};
301 VmaAllocationInfo allocation_info = {};
303 auto result = vk::Result{::vmaCreateImage(allocator,
310 if (result != vk::Result::eSuccess) {
312 << vk::to_string(result)
316 <<
" [VK]Flags: " << vk::to_string(image_info.flags)
317 <<
" [VK]Format: " << vk::to_string(image_info.format)
318 <<
" [VK]Usage: " << vk::to_string(image_info.usage)
319 <<
" [VK]Mem. Flags: "
320 << vk::to_string(vk::MemoryPropertyFlags(
321 alloc_nfo.preferredFlags));
326 auto image = vk::Image{vk_image};
328 vk::ImageViewCreateInfo view_info = {};
329 view_info.image = image;
331 view_info.format = image_info.format;
333 view_info.subresourceRange.levelCount = image_info.mipLevels;
341 view_info.components.a = vk::ComponentSwizzle::eR;
342 view_info.components.r = vk::ComponentSwizzle::eA;
345 auto [result, image_view] = device.createImageViewUnique(view_info);
346 if (result != vk::Result::eSuccess) {
347 VALIDATION_LOG <<
"Unable to create an image view for allocation: "
348 << vk::to_string(result);
351 resource_.
Swap(ImageResource(ImageVMA{allocator, allocation, image},
352 std::move(image_view)));