From 03c002ee2a4fa37283209be3d4723c4e5f87143b Mon Sep 17 00:00:00 2001 From: gal20 <71563441+gal20@users.noreply.github.com> Date: Sat, 14 Nov 2020 19:58:12 +0200 Subject: [PATCH 1/3] make result not optional This fixes crash when hardware shader is enabled in the flatpak version --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index f0ca01b27..acd6a6503 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -254,7 +254,7 @@ public: explicit ShaderDoubleCache(bool separable) : separable(separable) {} std::tuple> Get( const KeyConfigType& key, const Pica::Shader::ShaderSetup& setup) { - std::optional result{}; + ShaderDecompiler::ProgramResult result{}; auto map_it = shader_map.find(key); if (map_it == shader_map.end()) { auto program_opt = CodeGenerator(setup, key, separable); @@ -267,7 +267,7 @@ public: auto [iter, new_shader] = shader_cache.emplace(program, OGLShaderStage{separable}); OGLShaderStage& cached_shader = iter->second; if (new_shader) { - result->code = program; + result.code = program; cached_shader.Create(program.c_str(), ShaderType); } shader_map[key] = &cached_shader; From 5055212063c831e109d94bc3487e111c37cef6b3 Mon Sep 17 00:00:00 2001 From: gal20 <71563441+gal20@users.noreply.github.com> Date: Sat, 14 Nov 2020 21:45:30 +0200 Subject: [PATCH 2/3] Update src/video_core/renderer_opengl/gl_shader_manager.cpp Co-authored-by: Marshall Mohror --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index acd6a6503..b037f7f09 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -267,7 +267,8 @@ public: auto [iter, new_shader] = shader_cache.emplace(program, OGLShaderStage{separable}); OGLShaderStage& cached_shader = iter->second; if (new_shader) { - result.code = program; + result.emplace(); + result->code = program; cached_shader.Create(program.c_str(), ShaderType); } shader_map[key] = &cached_shader; From 8b82a228f0235b0fde6ed1832c821abd4d026529 Mon Sep 17 00:00:00 2001 From: gal20 <71563441+gal20@users.noreply.github.com> Date: Sat, 14 Nov 2020 21:46:29 +0200 Subject: [PATCH 3/3] change result back to std::optional --- src/video_core/renderer_opengl/gl_shader_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index b037f7f09..51ed235de 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp @@ -254,7 +254,7 @@ public: explicit ShaderDoubleCache(bool separable) : separable(separable) {} std::tuple> Get( const KeyConfigType& key, const Pica::Shader::ShaderSetup& setup) { - ShaderDecompiler::ProgramResult result{}; + std::optional result{}; auto map_it = shader_map.find(key); if (map_it == shader_map.end()) { auto program_opt = CodeGenerator(setup, key, separable);