mirror of
https://github.com/libretro/parallel-gx1.git
synced 2026-11-11 03:11:28 -10:00
watcher ran a thread per watched directory (the texture pack's, the graphics mods') so that a texture file changed on disk while a game ran was loaded again; on Windows its backend throws, so its file was the one built with exceptions. A texture pack or mod is now read as the game starts, and a change to it is seen at the next start. With it go Common::FilesystemWatcher, the library's map from file to asset kept only to answer the watcher, and the asset cache's dirty asset queue that only the watcher filled.
45 lines
1.6 KiB
C++
45 lines
1.6 KiB
C++
// Copyright 2023 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
#include <chrono>
|
|
#include <filesystem>
|
|
#include <map>
|
|
#include <string>
|
|
|
|
#include "VideoCommon/Assets/CustomTextureData.h"
|
|
#include "VideoCommon/Assets/TextureAsset.h"
|
|
#include "VideoCommon/Assets/Types.h"
|
|
#include "VideoCommon/Assets/CustomAssetLibrary.h"
|
|
|
|
#include "Common/AtomicMap.h"
|
|
|
|
namespace VideoCommon
|
|
{
|
|
// This class implements 'CustomAssetLibrary' and loads any assets
|
|
// directly from the filesystem
|
|
class DirectFilesystemAssetLibrary final : public CustomAssetLibrary
|
|
{
|
|
public:
|
|
DirectFilesystemAssetLibrary();
|
|
~DirectFilesystemAssetLibrary() override;
|
|
DirectFilesystemAssetLibrary(const DirectFilesystemAssetLibrary&) = delete;
|
|
DirectFilesystemAssetLibrary& operator=(const DirectFilesystemAssetLibrary&) = delete;
|
|
|
|
LoadInfo LoadTexture(const AssetID& asset_id, CustomTextureData* data) override;
|
|
|
|
// 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, Assets::AssetMap asset_path_map);
|
|
|
|
private:
|
|
// Gets the asset map given an asset id
|
|
Assets::AssetMap GetAssetMapForID(const AssetID& asset_id) const;
|
|
|
|
// Written while mods and texture packs load, read by the loader threads: a lock-free map
|
|
// keyed by the string's bytes, each value swapped whole.
|
|
atomic_value_map_t* m_asset_id_to_asset_map_path; // AssetMapValue
|
|
};
|
|
} // namespace VideoCommon
|