summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2023-06-05 23:32:02 +0200
committerGitHub <noreply@github.com>2023-06-05 23:32:02 +0200
commit678db26f684edaac7c0ea699f2ac2b4771e31993 (patch)
treea766e794f51250d81d6d44e169eb716bd2579115 /Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h
parentce2b63dcc086f95c7278827a079f007faa7f34ad (diff)
parent9d7ab477387bb9afc00181dfa70e1e0d1a27b28b (diff)
Merge pull request #11891 from iwubcode/asset_thread_safety
VideoCommon: add additional locks around asset access / usage
Diffstat (limited to 'Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h')
-rw-r--r--Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h
index d04981dac3..4f02d107cf 100644
--- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h
+++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h
@@ -5,6 +5,7 @@
#include <chrono>
#include <filesystem>
#include <map>
+#include <mutex>
#include <string>
#include "VideoCommon/Assets/CustomAssetLibrary.h"
@@ -18,6 +19,8 @@ class CustomTextureData;
class DirectFilesystemAssetLibrary final : public CustomAssetLibrary
{
public:
+ using AssetMap = std::map<std::string, std::filesystem::path>;
+
LoadInfo LoadTexture(const AssetID& asset_id, CustomTextureData* data) override;
// Gets the latest time from amongst all the files in the asset map
@@ -26,12 +29,16 @@ public:
// Assigns the asset id to a map of files, how this map is read is dependent on the data
// For instance, a raw texture would expect the map to have a single entry and load that
// file as the asset. But a model file data might have its data spread across multiple files
- void SetAssetIDMapData(const AssetID& asset_id,
- std::map<std::string, std::filesystem::path> asset_path_map);
+ void SetAssetIDMapData(const AssetID& asset_id, AssetMap asset_path_map);
private:
// Loads additional mip levels into the texture structure until _mip<N> texture is not found
bool LoadMips(const std::filesystem::path& asset_path, CustomTextureData* data);
+
+ // Gets the asset map given an asset id
+ AssetMap GetAssetMapForID(const AssetID& asset_id) const;
+
+ mutable std::mutex m_lock;
std::map<AssetID, std::map<std::string, std::filesystem::path>> m_assetid_to_asset_map_path;
};
} // namespace VideoCommon