VideoCommon: move AssetMap to a types header file, so it can be pulled in without the DirectFilesystemAssetLibrary dependencies, the header will be expanded later

This commit is contained in:
iwubcode 2024-07-04 17:41:49 -05:00
parent db40bc4269
commit 7a2055a0b4
6 changed files with 25 additions and 10 deletions

View File

@ -663,6 +663,7 @@
<ClInclude Include="VideoCommon\Assets\MeshAsset.h" />
<ClInclude Include="VideoCommon\Assets\ShaderAsset.h" />
<ClInclude Include="VideoCommon\Assets\TextureAsset.h" />
<ClInclude Include="VideoCommon\Assets\Types.h" />
<ClInclude Include="VideoCommon\Assets\WatchableFilesystemAssetLibrary.h" />
<ClInclude Include="VideoCommon\AsyncRequests.h" />
<ClInclude Include="VideoCommon\AsyncShaderCompiler.h" />

View File

@ -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);

View File

@ -9,6 +9,7 @@
#include <string>
#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<std::string, std::filesystem::path>;
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<AssetID, std::map<std::string, std::filesystem::path>> m_assetid_to_asset_map_path;
std::map<AssetID, Assets::AssetMap> m_assetid_to_asset_map_path;
mutable std::mutex m_path_map_lock;
std::map<std::string, AssetID, std::less<>> m_path_to_asset_id;

View File

@ -0,0 +1,13 @@
// Copyright 2024 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <filesystem>
#include <map>
#include <string>
namespace VideoCommon::Assets
{
using AssetMap = std::map<std::string, std::filesystem::path>;
}

View File

@ -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

View File

@ -7,12 +7,13 @@
#include <picojson.h>
#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);