forked from waskord/UnleashedRecomp_Android
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvulkan_utils.cpp
More file actions
35 lines (27 loc) · 841 Bytes
/
Copy pathvulkan_utils.cpp
File metadata and controls
35 lines (27 loc) · 841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdafx.h>
#include <user/paths.h>
#include <fstream>
#include <vector>
namespace vulkan_utils {
std::filesystem::path GetPipelineCachePath() {
return GetUserPath() / "vulkan_pipeline_cache.bin";
}
std::vector<uint8_t> LoadPipelineCache() {
auto path = GetPipelineCachePath();
if (!std::filesystem::exists(path)) return {};
std::ifstream file(path, std::ios::binary | std::ios::ate);
if (!file.is_open()) return {};
size_t size = file.tellg();
file.seekg(0, std::ios::beg);
std::vector<uint8_t> data(size);
file.read((char*)data.data(), size);
return data;
}
void SavePipelineCache(const void* data, size_t size) {
auto path = GetPipelineCachePath();
std::ofstream file(path, std::ios::binary);
if (file.is_open()) {
file.write((const char*)data, size);
}
}
}