mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-06-28 01:49:33 -06:00
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:
@ -13,12 +13,17 @@ CustomAsset::CustomAsset(std::shared_ptr<CustomAssetLibrary> library,
|
|||||||
|
|
||||||
std::size_t CustomAsset::Load()
|
std::size_t 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);
|
const auto load_information = LoadImpl(m_asset_id);
|
||||||
if (load_information.m_bytes_loaded > 0)
|
if (load_information.m_bytes_loaded > 0)
|
||||||
{
|
{
|
||||||
std::lock_guard lk(m_info_lock);
|
std::lock_guard lk(m_info_lock);
|
||||||
m_bytes_loaded = load_information.m_bytes_loaded;
|
m_bytes_loaded = load_information.m_bytes_loaded;
|
||||||
m_last_loaded_time = ClockType::now();
|
m_last_loaded_time = load_time;
|
||||||
return m_bytes_loaded;
|
return m_bytes_loaded;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user