From be65cf0fc2ff63c06648241c91e0ecfa989d2b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Mon, 11 Sep 2023 17:45:54 +0200 Subject: [PATCH] Assert improvements --- Common/MemoryUtil.cpp | 6 ++++-- GPU/Common/ReplacedTexture.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/MemoryUtil.cpp b/Common/MemoryUtil.cpp index 68f0d2b0850a..4cebd6eb4d2b 100644 --- a/Common/MemoryUtil.cpp +++ b/Common/MemoryUtil.cpp @@ -26,6 +26,7 @@ #include "Common/MemoryUtil.h" #include "Common/StringUtils.h" #include "Common/SysError.h" +#include "Common/Data/Text/Parsers.h" #ifdef _WIN32 #include "Common/CommonWindows.h" @@ -257,8 +258,9 @@ void *AllocateAlignedMemory(size_t size, size_t alignment) { } #endif #endif - - _assert_msg_(ptr != nullptr, "Failed to allocate aligned memory of size %llu", (unsigned long long)size); + char temp[32]; + NiceSizeFormat(size, temp, sizeof(temp)); + _assert_msg_(ptr != nullptr, "Failed to allocate aligned memory of size %s (%llu)", temp, (unsigned long long)size); return ptr; } diff --git a/GPU/Common/ReplacedTexture.cpp b/GPU/Common/ReplacedTexture.cpp index 8856282dd501..84fd0e2d9350 100644 --- a/GPU/Common/ReplacedTexture.cpp +++ b/GPU/Common/ReplacedTexture.cpp @@ -672,6 +672,7 @@ ReplacedTexture::LoadLevelResult ReplacedTexture::LoadLevelData(VFSFileReference png.format = PNG_FORMAT_RGBA; std::vector &out = data_[mipLevel]; + // TODO: Should probably try to handle out-of-memory gracefully here. out.resize(level.w * level.h * 4); if (!png_image_finish_read(&png, nullptr, &out[0], level.w * 4, nullptr)) { ERROR_LOG(G3D, "Could not load texture replacement: %s - %s", filename.c_str(), png.message);