diff options
| author | Mai <mai.iam2048@gmail.com> | 2024-02-16 15:46:52 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-16 15:46:52 -0500 |
| commit | 21300bb21b5b60c8249bb0d13445037bdc9f7da4 (patch) | |
| tree | 58a3d7a47b0809f58d8c7198aa2a8d59203af653 /Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp | |
| parent | 946aa45abdc42f4b0306a8ff9c19703f204f3a53 (diff) | |
| parent | b669580aeb5209004dec00a1b1447c7949fc0073 (diff) | |
Merge pull request #12457 from iwubcode/asset_memory_limit
VideoCommon: handle asset memory going over reserved limit correctly
Diffstat (limited to 'Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp index dfe640ffe8..119d7444ea 100644 --- a/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp +++ b/Source/Core/VideoCommon/Assets/CustomAssetLoader.cpp @@ -3,7 +3,6 @@ #include "VideoCommon/Assets/CustomAssetLoader.h" -#include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" #include "VideoCommon/Assets/CustomAssetLibrary.h" @@ -48,19 +47,22 @@ void CustomAssetLoader::Init() m_asset_load_thread.Reset("Custom Asset Loader", [this](std::weak_ptr<CustomAsset> asset) { if (auto ptr = asset.lock()) { + if (m_memory_exceeded) + return; + if (ptr->Load()) { std::lock_guard lk(m_asset_load_lock); const std::size_t asset_memory_size = ptr->GetByteSizeInMemory(); - if (m_max_memory_available >= m_total_bytes_loaded + asset_memory_size) - { - m_total_bytes_loaded += asset_memory_size; - m_assets_to_monitor.try_emplace(ptr->GetAssetId(), ptr); - } - else + m_total_bytes_loaded += asset_memory_size; + m_assets_to_monitor.try_emplace(ptr->GetAssetId(), ptr); + if (m_total_bytes_loaded > m_max_memory_available) { - ERROR_LOG_FMT(VIDEO, "Failed to load asset {} because there was not enough memory.", + ERROR_LOG_FMT(VIDEO, + "Asset memory exceeded with asset '{}', future assets won't load until " + "memory is available.", ptr->GetAssetId()); + m_memory_exceeded = true; } } } |
