summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_cache.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2021-06-20 07:23:50 +0200
committerameerj <52414509+ameerj@users.noreply.github.com>2021-07-23 03:51:39 +0200
commitf5db8c74405c93b52efbdef318790bd9ec4661c7 (patch)
treeb95c6eab579ef403c6c3cd454461decc4ec9e4d6 /src/video_core/renderer_opengl/gl_shader_cache.cpp
parentgl_graphics_pipeline: Port optimizations from Vulkan pipelines (diff)
downloadyuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar.gz
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar.bz2
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar.lz
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar.xz
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.tar.zst
yuzu-f5db8c74405c93b52efbdef318790bd9ec4661c7.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 8aaadccc4..c36b0d8cf 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -298,6 +298,7 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading,
GraphicsPipeline* ShaderCache::CurrentGraphicsPipeline() {
if (!RefreshStages(graphics_key.unique_hashes)) {
+ current_pipeline = nullptr;
return nullptr;
}
const auto& regs{maxwell3d.regs};
@@ -313,15 +314,23 @@ GraphicsPipeline* ShaderCache::CurrentGraphicsPipeline() {
if (graphics_key.xfb_enabled) {
SetXfbState(graphics_key.xfb_state, regs);
}
+ if (current_pipeline && graphics_key == current_pipeline->Key()) {
+ return current_pipeline->IsBuilt() ? current_pipeline : nullptr;
+ }
+ return CurrentGraphicsPipelineSlowPath();
+}
+
+GraphicsPipeline* ShaderCache::CurrentGraphicsPipelineSlowPath() {
const auto [pair, is_new]{graphics_cache.try_emplace(graphics_key)};
- auto& program{pair->second};
+ auto& pipeline{pair->second};
if (is_new) {
- program = CreateGraphicsPipeline();
+ pipeline = CreateGraphicsPipeline();
}
- if (!program || !program->IsBuilt()) {
+ current_pipeline = pipeline.get();
+ if (!pipeline || !pipeline->IsBuilt()) {
return nullptr;
}
- return program.get();
+ return pipeline.get();
}
ComputePipeline* ShaderCache::CurrentComputePipeline() {
@@ -432,8 +441,7 @@ std::unique_ptr<GraphicsPipeline> ShaderCache::CreateGraphicsPipeline(
auto* const thread_worker{build_in_parallel ? workers.get() : nullptr};
return std::make_unique<GraphicsPipeline>(device, texture_cache, buffer_cache, gpu_memory,
maxwell3d, program_manager, state_tracker,
- thread_worker, &shader_notify, sources, infos,
- key.xfb_enabled != 0 ? &key.xfb_state : nullptr);
+ thread_worker, &shader_notify, sources, infos, key);
} catch (Shader::Exception& exception) {
LOG_ERROR(Render_OpenGL, "{}", exception.what());