From 6627369ea7a3fa774353d9a6619c24f228bfe5f7 Mon Sep 17 00:00:00 2001 From: kj16609 Date: Sun, 4 Aug 2024 23:56:45 -0400 Subject: [PATCH] Add better error printout for image creation errors --- src/engine/image/ImageHandle.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/engine/image/ImageHandle.cpp b/src/engine/image/ImageHandle.cpp index e0d1658..5cec791 100644 --- a/src/engine/image/ImageHandle.cpp +++ b/src/engine/image/ImageHandle.cpp @@ -72,10 +72,17 @@ namespace fgl::engine VmaAllocationCreateInfo alloc_info {}; alloc_info.usage = VMA_MEMORY_USAGE_GPU_ONLY; - if ( vmaAllocateMemoryForImage( - Device::getInstance().allocator(), getVkImage(), &alloc_info, &m_allocation, &m_allocation_info ) - != VK_SUCCESS ) + if ( const auto result = vmaAllocateMemoryForImage( + Device::getInstance().allocator(), getVkImage(), &alloc_info, &m_allocation, &m_allocation_info ); + result != VK_SUCCESS ) + { + log::critical( + "Failed to allocate memory for image of size ({},{}) with error {}", + m_extent.width, + m_extent.height, + static_cast< int >( result ) ); throw std::runtime_error( "Failed to allocate memory for image" ); + } if ( vmaBindImageMemory( Device::getInstance().allocator(), m_allocation, getVkImage() ) != VK_SUCCESS ) throw std::runtime_error( "Failed to bind memory" );