summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_cache.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-01-21 20:38:23 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-02-07 02:23:40 +0100
commiteb7324743372d3b94db9a915a5508d8293d45ecb (patch)
tree085261558efeb2b47ce5316b52314980005b3e5c /src/video_core/renderer_opengl/gl_shader_cache.cpp
parentgl_shader_cache: Set GL_PROGRAM_SEPARABLE to dumped shaders (diff)
downloadyuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.gz
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.bz2
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.lz
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.xz
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.tar.zst
yuzu-eb7324743372d3b94db9a915a5508d8293d45ecb.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_cache.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 7eeae082a..e0e624e6f 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -345,7 +345,8 @@ ShaderDiskCacheUsage CachedShader::GetUsage(GLenum primitive_mode,
ShaderCacheOpenGL::ShaderCacheOpenGL(RasterizerOpenGL& rasterizer, Core::System& system)
: RasterizerCache{rasterizer}, disk_cache{system} {}
-void ShaderCacheOpenGL::LoadDiskCache() {
+void ShaderCacheOpenGL::LoadDiskCache(const std::atomic_bool& stop_loading,
+ const VideoCore::DiskResourceLoadCallback& callback) {
const auto transferable = disk_cache.LoadTransferable();
if (!transferable) {
return;
@@ -355,10 +356,18 @@ void ShaderCacheOpenGL::LoadDiskCache() {
auto [decompiled, dumps] = disk_cache.LoadPrecompiled();
const auto supported_formats{GetSupportedFormats()};
- const auto unspecialized{GenerateUnspecializedShaders(raws, decompiled)};
+ const auto unspecialized{
+ GenerateUnspecializedShaders(stop_loading, callback, raws, decompiled)};
+ if (stop_loading)
+ return;
// Build shaders
+ if (callback)
+ callback(VideoCore::LoadCallbackStage::Build, 0, usages.size());
for (std::size_t i = 0; i < usages.size(); ++i) {
+ if (stop_loading)
+ return;
+
const auto& usage{usages[i]};
LOG_INFO(Render_OpenGL, "Building shader {:016x} ({} of {})", usage.unique_identifier,
i + 1, usages.size());
@@ -381,6 +390,9 @@ void ShaderCacheOpenGL::LoadDiskCache() {
usage.bindings, usage.primitive, true);
}
precompiled_programs.insert({usage, std::move(shader)});
+
+ if (callback)
+ callback(VideoCore::LoadCallbackStage::Build, i + 1, usages.size());
}
// TODO(Rodrigo): Do state tracking for transferable shaders and do a dummy draw before
@@ -420,11 +432,19 @@ CachedProgram ShaderCacheOpenGL::GeneratePrecompiledProgram(
}
std::map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecializedShaders(
+ const std::atomic_bool& stop_loading, const VideoCore::DiskResourceLoadCallback& callback,
const std::vector<ShaderDiskCacheRaw>& raws,
const std::map<u64, ShaderDiskCacheDecompiled>& decompiled) {
std::map<u64, UnspecializedShader> unspecialized;
- for (const auto& raw : raws) {
+ if (callback)
+ callback(VideoCore::LoadCallbackStage::Decompile, 0, raws.size());
+
+ for (std::size_t i = 0; i < raws.size(); ++i) {
+ if (stop_loading)
+ return {};
+
+ const auto& raw{raws[i]};
const u64 unique_identifier = raw.GetUniqueIdentifier();
const u64 calculated_hash =
GetUniqueIdentifier(raw.GetProgramType(), raw.GetProgramCode(), raw.GetProgramCodeB());
@@ -454,6 +474,9 @@ std::map<u64, UnspecializedShader> ShaderCacheOpenGL::GenerateUnspecializedShade
unspecialized.insert(
{raw.GetUniqueIdentifier(),
{std::move(result.first), std::move(result.second), raw.GetProgramType()}});
+
+ if (callback)
+ callback(VideoCore::LoadCallbackStage::Decompile, i, raws.size());
}
return unspecialized;
}