gfx-shader: Deal with remaining compile errors

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2019-12-25 19:18:44 +01:00
parent 731a22e1ea
commit f79502b9b0
2 changed files with 20 additions and 17 deletions

View file

@ -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 gfx::shader::shader::load_shader(const std::filesystem::path& file, const std::string& tech, bool& shader_dirty,
bool& param_dirty) bool& param_dirty)
{ try {
if (!std::filesystem::exists(file)) if (!std::filesystem::exists(file))
return false; return false;
shader_dirty = is_shader_different(file); shader_dirty = is_shader_different(file);
param_dirty = is_technique_different(tech) || shader_dirty; param_dirty = is_technique_different(tech) || shader_dirty;
// Update Shader
if (shader_dirty) { if (shader_dirty) {
try { _shader = gs::effect(file);
_shader = gs::effect(file); _shader_file_mt = std::filesystem::last_write_time(file);
_shader_file = file; _shader_file_sz = std::filesystem::file_size(file);
_shader_file_mt = std::filesystem::last_write_time(file); _shader_file = file;
_shader_file_sz = std::filesystem::file_size(file); _shader_file_tick = 0;
_shader_file_tick = 0;
} catch (...) {
return false;
}
} }
// Update Params
if (param_dirty) { if (param_dirty) {
auto settings = auto settings =
std::shared_ptr<obs_data_t>(obs_source_get_settings(_self), [](obs_data_t* p) { obs_data_release(p); }); std::shared_ptr<obs_data_t>(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; return true;
} catch (...) {
return false;
} }
void gfx::shader::shader::properties(obs_properties_t* pr) void gfx::shader::shader::properties(obs_properties_t* pr)

View file

@ -50,6 +50,8 @@ namespace gfx {
Transition, Transition,
}; };
typedef std::map<std::string, std::shared_ptr<parameter>> shader_param_map_t;
class shader { class shader {
obs_source_t* _self; obs_source_t* _self;
@ -61,13 +63,13 @@ namespace gfx {
std::shared_ptr<gs::texture> _input_b; std::shared_ptr<gs::texture> _input_b;
// Shader // Shader
gs::effect _shader; gs::effect _shader;
std::filesystem::path _shader_file; std::filesystem::path _shader_file;
std::string _shader_tech; std::string _shader_tech;
std::filesystem::file_time_type _shader_file_mt; std::filesystem::file_time_type _shader_file_mt;
uintmax_t _shader_file_sz; uintmax_t _shader_file_sz;
float_t _shader_file_tick; float_t _shader_file_tick;
std::map<std::string, std::shared_ptr<parameter>> _shader_params; shader_param_map_t _shader_params;
// Options // Options
size_type _width_type; size_type _width_type;