From f79502b9b0e3dd5351e6e0a78d0000a2d31295c6 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Wed, 25 Dec 2019 19:18:44 +0100 Subject: [PATCH] gfx-shader: Deal with remaining compile errors --- source/gfx/shader/gfx-shader.cpp | 21 +++++++++++---------- source/gfx/shader/gfx-shader.hpp | 16 +++++++++------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/source/gfx/shader/gfx-shader.cpp b/source/gfx/shader/gfx-shader.cpp index 3f42c326..a8c1f9ed 100644 --- a/source/gfx/shader/gfx-shader.cpp +++ b/source/gfx/shader/gfx-shader.cpp @@ -79,24 +79,23 @@ bool gfx::shader::shader::is_technique_different(const std::string& tech) bool gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech, bool& shader_dirty, bool& param_dirty) -{ +try { if (!std::filesystem::exists(file)) return false; shader_dirty = is_shader_different(file); param_dirty = is_technique_different(tech) || shader_dirty; + // Update Shader if (shader_dirty) { - try { - _shader = gs::effect(file); - _shader_file = file; - _shader_file_mt = std::filesystem::last_write_time(file); - _shader_file_sz = std::filesystem::file_size(file); - _shader_file_tick = 0; - } catch (...) { - return false; - } + _shader = gs::effect(file); + _shader_file_mt = std::filesystem::last_write_time(file); + _shader_file_sz = std::filesystem::file_size(file); + _shader_file = file; + _shader_file_tick = 0; } + + // Update Params if (param_dirty) { auto settings = std::shared_ptr(obs_source_get_settings(_self), [](obs_data_t* p) { obs_data_release(p); }); @@ -164,6 +163,8 @@ bool gfx::shader::shader::load_shader(const std::filesystem::path& file, const s } return true; +} catch (...) { + return false; } void gfx::shader::shader::properties(obs_properties_t* pr) diff --git a/source/gfx/shader/gfx-shader.hpp b/source/gfx/shader/gfx-shader.hpp index 403e5600..296ed30a 100644 --- a/source/gfx/shader/gfx-shader.hpp +++ b/source/gfx/shader/gfx-shader.hpp @@ -50,6 +50,8 @@ namespace gfx { Transition, }; + typedef std::map> shader_param_map_t; + class shader { obs_source_t* _self; @@ -61,13 +63,13 @@ namespace gfx { std::shared_ptr _input_b; // Shader - gs::effect _shader; - std::filesystem::path _shader_file; - std::string _shader_tech; - std::filesystem::file_time_type _shader_file_mt; - uintmax_t _shader_file_sz; - float_t _shader_file_tick; - std::map> _shader_params; + gs::effect _shader; + std::filesystem::path _shader_file; + std::string _shader_tech; + std::filesystem::file_time_type _shader_file_mt; + uintmax_t _shader_file_sz; + float_t _shader_file_tick; + shader_param_map_t _shader_params; // Options size_type _width_type;