mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-29 21:56:58 +00:00
VideoCommon: support resetting custom asset loader
This commit is contained in:
parent
44e1ca256b
commit
8657d94e33
2 changed files with 21 additions and 1 deletions
|
@ -30,6 +30,7 @@ void CustomAssetLoader::Init()
|
|||
std::this_thread::sleep_for(TIME_BETWEEN_ASSET_MONITOR_CHECKS);
|
||||
|
||||
std::lock_guard lk(m_asset_load_lock);
|
||||
std::vector<CustomAssetLibrary::AssetID> dead_asset_ids;
|
||||
for (auto& [asset_id, asset_to_monitor] : m_assets_to_monitor)
|
||||
{
|
||||
if (auto ptr = asset_to_monitor.lock())
|
||||
|
@ -40,6 +41,15 @@ void CustomAssetLoader::Init()
|
|||
(void)ptr->Load();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dead_asset_ids.push_back(asset_id);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& dead_asset_id : dead_asset_ids)
|
||||
{
|
||||
m_assets_to_monitor.erase(dead_asset_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -52,6 +52,17 @@ public:
|
|||
std::shared_ptr<MeshAsset> LoadMesh(const CustomAssetLibrary::AssetID& asset_id,
|
||||
std::shared_ptr<CustomAssetLibrary> library);
|
||||
|
||||
void Reset()
|
||||
{
|
||||
std::lock_guard lk(m_asset_load_lock);
|
||||
m_game_textures.clear();
|
||||
m_pixel_shaders.clear();
|
||||
m_materials.clear();
|
||||
m_meshes.clear();
|
||||
m_total_bytes_loaded = 0;
|
||||
m_assets_to_monitor.clear();
|
||||
}
|
||||
|
||||
private:
|
||||
// TODO C++20: use a 'derived_from' concept against 'CustomAsset' when available
|
||||
template <typename AssetType>
|
||||
|
@ -71,7 +82,6 @@ private:
|
|||
{
|
||||
std::lock_guard lk(m_asset_load_lock);
|
||||
m_total_bytes_loaded -= a->GetByteSizeInMemory();
|
||||
m_assets_to_monitor.erase(a->GetAssetId());
|
||||
if (m_max_memory_available >= m_total_bytes_loaded && m_memory_exceeded)
|
||||
{
|
||||
INFO_LOG_FMT(VIDEO, "Asset memory went below limit, new assets can begin loading.");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue