filter-shader: Fix some crashes

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2020-03-31 22:26:50 +02:00
parent bb2f43a629
commit d5dffbbe03
2 changed files with 13 additions and 13 deletions

View file

@ -68,8 +68,11 @@ void filter::shader::shader_instance::video_tick(float_t sec_since_last)
obs_data_release(data);
}
obs_source_t* tgt = obs_filter_get_target(_self);
_fx->set_size(obs_source_get_width(tgt), obs_source_get_height(tgt));
if (obs_source_t* tgt = obs_filter_get_target(_self); tgt != nullptr) {
_fx->set_size(obs_source_get_width(tgt), obs_source_get_height(tgt));
} else if (obs_source* src = obs_filter_get_parent(_self); src != nullptr) {
_fx->set_size(obs_source_get_base_width(src), obs_source_get_base_height(src));
}
}
void filter::shader::shader_instance::video_render(gs_effect_t* effect)
@ -80,7 +83,7 @@ void filter::shader::shader_instance::video_render(gs_effect_t* effect)
}
{
gs::debug_marker _marker_cache{gs::debug_color_cache, "%s Cache"};
gs::debug_marker _marker_cache{gs::debug_color_source, "%s: Capture", obs_source_get_name(_self)};
auto op = _rt->render(_fx->width(), _fx->height());
gs_ortho(0, static_cast<float_t>(_fx->width()), 0, static_cast<float_t>(_fx->height()), -1, 1);
@ -109,15 +112,15 @@ void filter::shader::shader_instance::video_render(gs_effect_t* effect)
}
}
_fx->prepare_render();
_fx->set_input_a(_rt->get_texture());
_fx->render();
{
gs::debug_marker _marker_cache{gs::debug_color_render, "%s: Render", obs_source_get_name(_self)};
_fx->prepare_render();
_fx->set_input_a(_rt->get_texture());
_fx->render();
}
}
void filter::shader::shader_instance::transition_start() {}
void filter::shader::shader_instance::transition_stop() {}
std::shared_ptr<filter::shader::shader_factory> filter::shader::shader_factory::factory_instance = nullptr;
filter::shader::shader_factory::shader_factory()

View file

@ -47,9 +47,6 @@ namespace filter::shader {
virtual void video_tick(float_t sec_since_last) override;
virtual void video_render(gs_effect_t* effect) override;
virtual void transition_start() override;
virtual void transition_stop() override;
};
class shader_factory : public obs::source_factory<filter::shader::shader_factory, filter::shader::shader_instance> {