Change VFS vector to regular vector
This commit is contained in:
parent
6f2756089d
commit
a20c81d593
@ -203,22 +203,22 @@ ShaderDiskCache::LoadPrecompiledFile(FileUtil::IOFile& file) {
|
||||
file.ReadBytes(compressed.data(), compressed.size());
|
||||
const std::vector<u8> decompressed = Common::Compression::DecompressDataZSTD(compressed);
|
||||
SaveArrayToPrecompiled(decompressed.data(), decompressed.size());
|
||||
precompiled_cache_virtual_file_offset = 0;
|
||||
decompressed_precompiled_cache_offset = 0;
|
||||
|
||||
ShaderCacheVersionHash file_hash{};
|
||||
if (!LoadArrayFromPrecompiled(file_hash.data(), file_hash.size())) {
|
||||
precompiled_cache_virtual_file_offset = 0;
|
||||
decompressed_precompiled_cache_offset = 0;
|
||||
return {};
|
||||
}
|
||||
if (GetShaderCacheVersionHash() != file_hash) {
|
||||
LOG_INFO(Render_OpenGL, "Precompiled cache is from another version of the emulator");
|
||||
precompiled_cache_virtual_file_offset = 0;
|
||||
decompressed_precompiled_cache_offset = 0;
|
||||
return {};
|
||||
}
|
||||
|
||||
std::unordered_map<u64, ShaderDiskCacheDecompiled> decompiled;
|
||||
ShaderDumpsMap dumps;
|
||||
while (precompiled_cache_virtual_file_offset < precompiled_cache_virtual_file.GetSize()) {
|
||||
while (decompressed_precompiled_cache_offset < decompressed_precompiled_cache.size()) {
|
||||
PrecompiledEntryKind kind{};
|
||||
if (!LoadObjectFromPrecompiled(kind)) {
|
||||
return {};
|
||||
@ -308,7 +308,7 @@ void ShaderDiskCache::InvalidateTransferable() {
|
||||
|
||||
void ShaderDiskCache::InvalidatePrecompiled() {
|
||||
// Clear virtaul precompiled cache file
|
||||
precompiled_cache_virtual_file.Resize(0);
|
||||
decompressed_precompiled_cache.resize(0);
|
||||
|
||||
if (!FileUtil::Delete(GetPrecompiledPath())) {
|
||||
LOG_ERROR(Render_OpenGL, "Failed to invalidate precompiled file={}", GetPrecompiledPath());
|
||||
@ -342,7 +342,7 @@ void ShaderDiskCache::SaveDecompiled(u64 unique_identifier,
|
||||
if (!IsUsable())
|
||||
return;
|
||||
|
||||
if (precompiled_cache_virtual_file.GetSize() == 0) {
|
||||
if (decompressed_precompiled_cache.size() == 0) {
|
||||
SavePrecompiledHeaderToVirtualPrecompiledCache();
|
||||
}
|
||||
|
||||
@ -413,10 +413,9 @@ void ShaderDiskCache::SavePrecompiledHeaderToVirtualPrecompiledCache() {
|
||||
}
|
||||
|
||||
void ShaderDiskCache::SaveVirtualPrecompiledFile() {
|
||||
precompiled_cache_virtual_file_offset = 0;
|
||||
const std::vector<u8>& uncompressed = precompiled_cache_virtual_file.ReadAllBytes();
|
||||
const std::vector<u8>& compressed =
|
||||
Common::Compression::CompressDataZSTDDefault(uncompressed.data(), uncompressed.size());
|
||||
decompressed_precompiled_cache_offset = 0;
|
||||
const std::vector<u8>& compressed = Common::Compression::CompressDataZSTDDefault(
|
||||
decompressed_precompiled_cache.data(), decompressed_precompiled_cache.size());
|
||||
|
||||
const auto precompiled_path{GetPrecompiledPath()};
|
||||
FileUtil::IOFile file(precompiled_path, "wb");
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <bitset>
|
||||
#include <optional>
|
||||
@ -18,7 +19,6 @@
|
||||
|
||||
#include "common/assert.h"
|
||||
#include "common/common_types.h"
|
||||
#include "common/vfs/vfs_vector.h"
|
||||
#include "video_core/regs.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_decompiler.h"
|
||||
#include "video_core/renderer_opengl/gl_shader_gen.h"
|
||||
@ -163,18 +163,20 @@ private:
|
||||
|
||||
template <typename T>
|
||||
bool SaveArrayToPrecompiled(const T* data, std::size_t length) {
|
||||
const std::size_t write_length = precompiled_cache_virtual_file.WriteArray(
|
||||
data, length, precompiled_cache_virtual_file_offset);
|
||||
precompiled_cache_virtual_file_offset += write_length;
|
||||
return write_length == sizeof(T) * length;
|
||||
const u8* data_view = reinterpret_cast<const u8*>(data);
|
||||
decompressed_precompiled_cache.insert(decompressed_precompiled_cache.end(), &data_view[0],
|
||||
&data_view[length * sizeof(T)]);
|
||||
decompressed_precompiled_cache_offset += length * sizeof(T);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
bool LoadArrayFromPrecompiled(T* data, std::size_t length) {
|
||||
const std::size_t read_length = precompiled_cache_virtual_file.ReadArray(
|
||||
data, length, precompiled_cache_virtual_file_offset);
|
||||
precompiled_cache_virtual_file_offset += read_length;
|
||||
return read_length == sizeof(T) * length;
|
||||
u8* data_view = reinterpret_cast<u8*>(data);
|
||||
std::copy_n(decompressed_precompiled_cache.data() + decompressed_precompiled_cache_offset,
|
||||
length * sizeof(T), data_view);
|
||||
decompressed_precompiled_cache_offset += length * sizeof(T);
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -194,9 +196,9 @@ private:
|
||||
|
||||
// Stores whole precompiled cache which will be read from or saved to the precompiled chache
|
||||
// file
|
||||
Common::VectorVfsFile precompiled_cache_virtual_file;
|
||||
std::vector<u8> decompressed_precompiled_cache;
|
||||
// Stores the current offset of the precompiled cache file for IO purposes
|
||||
std::size_t precompiled_cache_virtual_file_offset = 0;
|
||||
std::size_t decompressed_precompiled_cache_offset = 0;
|
||||
|
||||
// Stored transferable shaders
|
||||
std::unordered_map<u64, ShaderDiskCacheRaw> transferable;
|
||||
|
Loading…
Reference in New Issue
Block a user