From 7a2055a0b4cb3bea60d85e59edae4c9ba274e4d5 Mon Sep 17 00:00:00 2001 From: iwubcode Date: Thu, 4 Jul 2024 17:41:49 -0500 Subject: [PATCH] VideoCommon: move AssetMap to a types header file, so it can be pulled in without the DirectFilesystemAssetLibrary dependencies, the header will be expanded later --- Source/Core/DolphinLib.props | 1 + .../Assets/DirectFilesystemAssetLibrary.cpp | 6 +++--- .../Assets/DirectFilesystemAssetLibrary.h | 9 ++++----- Source/Core/VideoCommon/Assets/Types.h | 13 +++++++++++++ Source/Core/VideoCommon/CMakeLists.txt | 1 + .../GraphicsModSystem/Config/GraphicsModAsset.h | 5 +++-- 6 files changed, 25 insertions(+), 10 deletions(-) create mode 100644 Source/Core/VideoCommon/Assets/Types.h diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index c43c0027a9..16062d9164 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -663,6 +663,7 @@ + diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp index ff30a14c4c..73f275f3d5 100644 --- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp +++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.cpp @@ -436,9 +436,9 @@ CustomAssetLibrary::LoadInfo DirectFilesystemAssetLibrary::LoadTexture(const Ass } void DirectFilesystemAssetLibrary::SetAssetIDMapData(const AssetID& asset_id, - AssetMap asset_path_map) + VideoCommon::Assets::AssetMap asset_path_map) { - AssetMap previous_asset_map; + VideoCommon::Assets::AssetMap previous_asset_map; { std::lock_guard lk(m_asset_map_lock); previous_asset_map = m_assetid_to_asset_map_path[asset_id]; @@ -526,7 +526,7 @@ bool DirectFilesystemAssetLibrary::LoadMips(const std::filesystem::path& asset_p return true; } -DirectFilesystemAssetLibrary::AssetMap +VideoCommon::Assets::AssetMap DirectFilesystemAssetLibrary::GetAssetMapForID(const AssetID& asset_id) const { std::lock_guard lk(m_asset_map_lock); diff --git a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h index c63ca77ad3..cbc72a0e9a 100644 --- a/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h +++ b/Source/Core/VideoCommon/Assets/DirectFilesystemAssetLibrary.h @@ -9,6 +9,7 @@ #include #include "VideoCommon/Assets/CustomTextureData.h" +#include "VideoCommon/Assets/Types.h" #include "VideoCommon/Assets/WatchableFilesystemAssetLibrary.h" namespace VideoCommon @@ -18,8 +19,6 @@ namespace VideoCommon class DirectFilesystemAssetLibrary final : public WatchableFilesystemAssetLibrary { public: - using AssetMap = std::map; - LoadInfo LoadTexture(const AssetID& asset_id, TextureData* data) override; LoadInfo LoadPixelShader(const AssetID& asset_id, PixelShaderData* data) override; LoadInfo LoadMaterial(const AssetID& asset_id, MaterialData* data) override; @@ -31,7 +30,7 @@ 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, AssetMap asset_path_map); + void SetAssetIDMapData(const AssetID& asset_id, Assets::AssetMap asset_path_map); private: void PathModified(std::string_view path) override; @@ -40,10 +39,10 @@ private: bool LoadMips(const std::filesystem::path& asset_path, CustomTextureData::ArraySlice* data); // Gets the asset map given an asset id - AssetMap GetAssetMapForID(const AssetID& asset_id) const; + Assets::AssetMap GetAssetMapForID(const AssetID& asset_id) const; mutable std::mutex m_asset_map_lock; - std::map> m_assetid_to_asset_map_path; + std::map m_assetid_to_asset_map_path; mutable std::mutex m_path_map_lock; std::map> m_path_to_asset_id; diff --git a/Source/Core/VideoCommon/Assets/Types.h b/Source/Core/VideoCommon/Assets/Types.h new file mode 100644 index 0000000000..c10d45587c --- /dev/null +++ b/Source/Core/VideoCommon/Assets/Types.h @@ -0,0 +1,13 @@ +// Copyright 2024 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include +#include +#include + +namespace VideoCommon::Assets +{ +using AssetMap = std::map; +} diff --git a/Source/Core/VideoCommon/CMakeLists.txt b/Source/Core/VideoCommon/CMakeLists.txt index e166b9e071..f368ce657c 100644 --- a/Source/Core/VideoCommon/CMakeLists.txt +++ b/Source/Core/VideoCommon/CMakeLists.txt @@ -26,6 +26,7 @@ add_library(videocommon Assets/ShaderAsset.h Assets/TextureAsset.cpp Assets/TextureAsset.h + Assets/Types.h Assets/WatchableFilesystemAssetLibrary.cpp Assets/WatchableFilesystemAssetLibrary.h AsyncRequests.cpp diff --git a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h index 53d8d71892..d623a00e2e 100644 --- a/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h +++ b/Source/Core/VideoCommon/GraphicsModSystem/Config/GraphicsModAsset.h @@ -7,12 +7,13 @@ #include -#include "VideoCommon/Assets/DirectFilesystemAssetLibrary.h" +#include "VideoCommon/Assets/CustomAssetLibrary.h" +#include "VideoCommon/Assets/Types.h" struct GraphicsModAssetConfig { VideoCommon::CustomAssetLibrary::AssetID m_asset_id; - VideoCommon::DirectFilesystemAssetLibrary::AssetMap m_map; + VideoCommon::Assets::AssetMap m_map; void SerializeToConfig(picojson::object& json_obj) const; bool DeserializeFromConfig(const picojson::object& obj);