mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-30 02:32:46 +01:00
Merge pull request #2954 from ReinUsesLisp/fix-invalidation
gl_shader_disk_cache: Properly ignore existing cache
This commit is contained in:
commit
8f407adeeb
2 changed files with 17 additions and 16 deletions
|
@ -112,14 +112,15 @@ std::optional<std::pair<std::vector<ShaderDiskCacheRaw>, std::vector<ShaderDiskC
|
||||||
ShaderDiskCacheOpenGL::LoadTransferable() {
|
ShaderDiskCacheOpenGL::LoadTransferable() {
|
||||||
// Skip games without title id
|
// Skip games without title id
|
||||||
const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0;
|
const bool has_title_id = system.CurrentProcess()->GetTitleID() != 0;
|
||||||
if (!Settings::values.use_disk_shader_cache || !has_title_id)
|
if (!Settings::values.use_disk_shader_cache || !has_title_id) {
|
||||||
return {};
|
return {};
|
||||||
tried_to_load = true;
|
}
|
||||||
|
|
||||||
FileUtil::IOFile file(GetTransferablePath(), "rb");
|
FileUtil::IOFile file(GetTransferablePath(), "rb");
|
||||||
if (!file.IsOpen()) {
|
if (!file.IsOpen()) {
|
||||||
LOG_INFO(Render_OpenGL, "No transferable shader cache found for game with title id={}",
|
LOG_INFO(Render_OpenGL, "No transferable shader cache found for game with title id={}",
|
||||||
GetTitleID());
|
GetTitleID());
|
||||||
|
is_usable = true;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,6 +136,7 @@ ShaderDiskCacheOpenGL::LoadTransferable() {
|
||||||
LOG_INFO(Render_OpenGL, "Transferable shader cache is old - removing");
|
LOG_INFO(Render_OpenGL, "Transferable shader cache is old - removing");
|
||||||
file.Close();
|
file.Close();
|
||||||
InvalidateTransferable();
|
InvalidateTransferable();
|
||||||
|
is_usable = true;
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
if (version > NativeVersion) {
|
if (version > NativeVersion) {
|
||||||
|
@ -180,13 +182,15 @@ ShaderDiskCacheOpenGL::LoadTransferable() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {{raws, usages}};
|
is_usable = true;
|
||||||
|
return {{std::move(raws), std::move(usages)}};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap>
|
std::pair<std::unordered_map<u64, ShaderDiskCacheDecompiled>, ShaderDumpsMap>
|
||||||
ShaderDiskCacheOpenGL::LoadPrecompiled() {
|
ShaderDiskCacheOpenGL::LoadPrecompiled() {
|
||||||
if (!IsUsable())
|
if (!is_usable) {
|
||||||
return {};
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
FileUtil::IOFile file(GetPrecompiledPath(), "rb");
|
FileUtil::IOFile file(GetPrecompiledPath(), "rb");
|
||||||
if (!file.IsOpen()) {
|
if (!file.IsOpen()) {
|
||||||
|
@ -479,8 +483,9 @@ void ShaderDiskCacheOpenGL::InvalidatePrecompiled() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) {
|
void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) {
|
||||||
if (!IsUsable())
|
if (!is_usable) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const u64 id = entry.GetUniqueIdentifier();
|
const u64 id = entry.GetUniqueIdentifier();
|
||||||
if (transferable.find(id) != transferable.end()) {
|
if (transferable.find(id) != transferable.end()) {
|
||||||
|
@ -501,8 +506,9 @@ void ShaderDiskCacheOpenGL::SaveRaw(const ShaderDiskCacheRaw& entry) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) {
|
void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) {
|
||||||
if (!IsUsable())
|
if (!is_usable) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const auto it = transferable.find(usage.unique_identifier);
|
const auto it = transferable.find(usage.unique_identifier);
|
||||||
ASSERT_MSG(it != transferable.end(), "Saving shader usage without storing raw previously");
|
ASSERT_MSG(it != transferable.end(), "Saving shader usage without storing raw previously");
|
||||||
|
@ -528,8 +534,9 @@ void ShaderDiskCacheOpenGL::SaveUsage(const ShaderDiskCacheUsage& usage) {
|
||||||
|
|
||||||
void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::string& code,
|
void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::string& code,
|
||||||
const GLShader::ShaderEntries& entries) {
|
const GLShader::ShaderEntries& entries) {
|
||||||
if (!IsUsable())
|
if (!is_usable) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (precompiled_cache_virtual_file.GetSize() == 0) {
|
if (precompiled_cache_virtual_file.GetSize() == 0) {
|
||||||
SavePrecompiledHeaderToVirtualPrecompiledCache();
|
SavePrecompiledHeaderToVirtualPrecompiledCache();
|
||||||
|
@ -543,8 +550,9 @@ void ShaderDiskCacheOpenGL::SaveDecompiled(u64 unique_identifier, const std::str
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint program) {
|
void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint program) {
|
||||||
if (!IsUsable())
|
if (!is_usable) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
GLint binary_length{};
|
GLint binary_length{};
|
||||||
glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length);
|
glGetProgramiv(program, GL_PROGRAM_BINARY_LENGTH, &binary_length);
|
||||||
|
@ -565,10 +573,6 @@ void ShaderDiskCacheOpenGL::SaveDump(const ShaderDiskCacheUsage& usage, GLuint p
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ShaderDiskCacheOpenGL::IsUsable() const {
|
|
||||||
return tried_to_load && Settings::values.use_disk_shader_cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const {
|
FileUtil::IOFile ShaderDiskCacheOpenGL::AppendTransferableFile() const {
|
||||||
if (!EnsureDirectories())
|
if (!EnsureDirectories())
|
||||||
return {};
|
return {};
|
||||||
|
|
|
@ -224,9 +224,6 @@ private:
|
||||||
bool SaveDecompiledFile(u64 unique_identifier, const std::string& code,
|
bool SaveDecompiledFile(u64 unique_identifier, const std::string& code,
|
||||||
const GLShader::ShaderEntries& entries);
|
const GLShader::ShaderEntries& entries);
|
||||||
|
|
||||||
/// Returns if the cache can be used
|
|
||||||
bool IsUsable() const;
|
|
||||||
|
|
||||||
/// Opens current game's transferable file and write it's header if it doesn't exist
|
/// Opens current game's transferable file and write it's header if it doesn't exist
|
||||||
FileUtil::IOFile AppendTransferableFile() const;
|
FileUtil::IOFile AppendTransferableFile() const;
|
||||||
|
|
||||||
|
@ -297,7 +294,7 @@ private:
|
||||||
std::unordered_map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable;
|
std::unordered_map<u64, std::unordered_set<ShaderDiskCacheUsage>> transferable;
|
||||||
|
|
||||||
// The cache has been loaded at boot
|
// The cache has been loaded at boot
|
||||||
bool tried_to_load{};
|
bool is_usable{};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace OpenGL
|
} // namespace OpenGL
|
||||||
|
|
Loading…
Reference in a new issue