mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-16 12:09:07 +00:00
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* Initial implementation * Fix for crash caused by stale stages data; cosmetics applied * Someone mentioned the assert * Async blob writer * Fix for memory leak * Remain stuff * Async changed to `packaged_task`
51 lines
1.2 KiB
C++
51 lines
1.2 KiB
C++
// SPDX-FileCopyrightText: Copyright 2025 shadPS4 Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include "common/path_util.h"
|
|
#include "common/singleton.h"
|
|
#include "common/types.h"
|
|
|
|
#include <functional>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
namespace Storage {
|
|
|
|
enum class BlobType : u32 {
|
|
ShaderMeta,
|
|
ShaderBinary,
|
|
PipelineKey,
|
|
ShaderProfile,
|
|
};
|
|
|
|
class DataBase {
|
|
public:
|
|
static DataBase& Instance() {
|
|
return *Common::Singleton<DataBase>::Instance();
|
|
}
|
|
|
|
void Open();
|
|
void Close();
|
|
[[nodiscard]] bool IsOpened() const {
|
|
return opened;
|
|
}
|
|
void FinishPreload();
|
|
|
|
bool Save(BlobType type, const std::string& name, std::vector<u8>&& data);
|
|
bool Save(BlobType type, const std::string& name, std::vector<u32>&& data);
|
|
|
|
void Load(BlobType type, const std::string& name, std::vector<u8>& data);
|
|
void Load(BlobType type, const std::string& name, std::vector<u32>& data);
|
|
|
|
void ForEachBlob(BlobType type, const std::function<void(std::vector<u8>&& data)>& func);
|
|
|
|
private:
|
|
std::jthread io_worker{};
|
|
std::filesystem::path cache_path{};
|
|
bool opened{};
|
|
};
|
|
|
|
} // namespace Storage
|