VideoCommon: update CustomAsset's load time to be before the load occurs (this prevents issues where the load time might be incorrectly inflated by long load operations)

Co-authored-by: Jordan Woyak <jordan.woyak@gmail.com>
This commit is contained in:
iwubcode 2025-05-23 23:27:11 -05:00
parent d5c33232fe
commit 22c7c0a719
1 changed files with 8 additions and 2 deletions

View File

@ -13,13 +13,19 @@ CustomAsset::CustomAsset(std::shared_ptr<CustomAssetLibrary> library,
bool CustomAsset::Load()
{
// The load time needs to come from before the data is actually read.
// Using a time point from after the read marks the asset as more up-to-date than it actually is,
// and has potential to race (and not be updated) if a change happens immediately after load.
const auto load_time = ClockType::now();
const auto load_information = LoadImpl(m_asset_id);
if (load_information.m_bytes_loaded > 0)
{
m_bytes_loaded = load_information.m_bytes_loaded;
m_last_loaded_time = ClockType::now();
m_last_loaded_time = load_time;
return true;
}
return load_information.m_bytes_loaded != 0;
return false;
}
void CustomAsset::Unload()