diff options
| author | iwubcode <iwubcode@users.noreply.github.com> | 2023-06-04 23:01:29 -0500 |
|---|---|---|
| committer | iwubcode <iwubcode@users.noreply.github.com> | 2023-06-05 16:19:46 -0500 |
| commit | 9d7ab477387bb9afc00181dfa70e1e0d1a27b28b (patch) | |
| tree | a766e794f51250d81d6d44e169eb716bd2579115 /Source/Core/VideoCommon/Assets/TextureAsset.cpp | |
| parent | ce2b63dcc086f95c7278827a079f007faa7f34ad (diff) | |
VideoCommon: add additional locks around asset access and usage to ensure thread safety
Diffstat (limited to 'Source/Core/VideoCommon/Assets/TextureAsset.cpp')
| -rw-r--r-- | Source/Core/VideoCommon/Assets/TextureAsset.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/Assets/TextureAsset.cpp b/Source/Core/VideoCommon/Assets/TextureAsset.cpp index 21f897fc19..0715dc6492 100644 --- a/Source/Core/VideoCommon/Assets/TextureAsset.cpp +++ b/Source/Core/VideoCommon/Assets/TextureAsset.cpp @@ -9,31 +9,35 @@ namespace VideoCommon { CustomAssetLibrary::LoadInfo RawTextureAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id) { - std::lock_guard lk(m_lock); auto potential_data = std::make_shared<CustomTextureData>(); const auto loaded_info = m_owning_library->LoadTexture(asset_id, potential_data.get()); if (loaded_info.m_bytes_loaded == 0) return {}; - m_loaded = true; - m_data = std::move(potential_data); + { + std::lock_guard lk(m_data_lock); + m_loaded = true; + m_data = std::move(potential_data); + } return loaded_info; } CustomAssetLibrary::LoadInfo GameTextureAsset::LoadImpl(const CustomAssetLibrary::AssetID& asset_id) { - std::lock_guard lk(m_lock); auto potential_data = std::make_shared<CustomTextureData>(); const auto loaded_info = m_owning_library->LoadGameTexture(asset_id, potential_data.get()); if (loaded_info.m_bytes_loaded == 0) return {}; - m_loaded = true; - m_data = std::move(potential_data); + { + std::lock_guard lk(m_data_lock); + m_loaded = true; + m_data = std::move(potential_data); + } return loaded_info; } bool GameTextureAsset::Validate(u32 native_width, u32 native_height) const { - std::lock_guard lk(m_lock); + std::lock_guard lk(m_data_lock); if (!m_loaded) { |
