mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 21:30:19 -06:00
VideoCommon: add 'Unload' functionality to CustomAsset
This commit is contained in:
@ -23,6 +23,18 @@ bool CustomAsset::Load()
|
|||||||
return load_information.m_bytes_loaded != 0;
|
return load_information.m_bytes_loaded != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t CustomAsset::Unload()
|
||||||
|
{
|
||||||
|
UnloadImpl();
|
||||||
|
std::size_t bytes_loaded = 0;
|
||||||
|
{
|
||||||
|
std::lock_guard lk(m_info_lock);
|
||||||
|
bytes_loaded = m_bytes_loaded;
|
||||||
|
m_bytes_loaded = 0;
|
||||||
|
}
|
||||||
|
return bytes_loaded;
|
||||||
|
}
|
||||||
|
|
||||||
CustomAssetLibrary::TimeType CustomAsset::GetLastWriteTime() const
|
CustomAssetLibrary::TimeType CustomAsset::GetLastWriteTime() const
|
||||||
{
|
{
|
||||||
return m_owning_library->GetLastAssetWriteTime(m_asset_id);
|
return m_owning_library->GetLastAssetWriteTime(m_asset_id);
|
||||||
|
@ -28,6 +28,10 @@ public:
|
|||||||
// Loads the asset from the library returning a pass/fail result
|
// Loads the asset from the library returning a pass/fail result
|
||||||
bool Load();
|
bool Load();
|
||||||
|
|
||||||
|
// Unloads the asset data, resets the bytes loaded and
|
||||||
|
// returns the number of bytes unloaded
|
||||||
|
std::size_t Unload();
|
||||||
|
|
||||||
// Queries the last time the asset was modified or standard epoch time
|
// Queries the last time the asset was modified or standard epoch time
|
||||||
// if the asset hasn't been modified yet
|
// if the asset hasn't been modified yet
|
||||||
// Note: not thread safe, expected to be called by the loader
|
// Note: not thread safe, expected to be called by the loader
|
||||||
@ -53,6 +57,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
virtual CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) = 0;
|
virtual CustomAssetLibrary::LoadInfo LoadImpl(const CustomAssetLibrary::AssetID& asset_id) = 0;
|
||||||
|
virtual void UnloadImpl() = 0;
|
||||||
CustomAssetLibrary::AssetID m_asset_id;
|
CustomAssetLibrary::AssetID m_asset_id;
|
||||||
std::size_t m_handle;
|
std::size_t m_handle;
|
||||||
|
|
||||||
@ -89,6 +94,14 @@ protected:
|
|||||||
bool m_loaded = false;
|
bool m_loaded = false;
|
||||||
mutable std::mutex m_data_lock;
|
mutable std::mutex m_data_lock;
|
||||||
std::shared_ptr<UnderlyingType> m_data;
|
std::shared_ptr<UnderlyingType> m_data;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void UnloadImpl() override
|
||||||
|
{
|
||||||
|
std::lock_guard lk(m_data_lock);
|
||||||
|
m_loaded = false;
|
||||||
|
m_data.reset();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// A helper struct that contains
|
// A helper struct that contains
|
||||||
|
Reference in New Issue
Block a user