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;