filters/shader: Fix occasional invisibility problem
This commit is contained in:
parent
8fc9b5cf1f
commit
9562d84221
|
|
@ -31,7 +31,6 @@ shader_instance::shader_instance(obs_data_t* data, obs_source_t* self) : obs::so
|
||||||
{
|
{
|
||||||
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Filter);
|
_fx = std::make_shared<gfx::shader::shader>(self, gfx::shader::shader_mode::Filter);
|
||||||
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
_rt = std::make_shared<gs::rendertarget>(GS_RGBA, GS_ZS_NONE);
|
||||||
update(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_instance::~shader_instance() {}
|
shader_instance::~shader_instance() {}
|
||||||
|
|
@ -80,9 +79,9 @@ void shader_instance::video_tick(float_t sec_since_last)
|
||||||
|
|
||||||
void shader_instance::video_render(gs_effect_t* effect)
|
void shader_instance::video_render(gs_effect_t* effect)
|
||||||
{
|
{
|
||||||
if (!_fx || !_fx->width() || !_fx->height()) {
|
try {
|
||||||
obs_source_skip_video_filter(_self);
|
if (!_fx || !_fx->base_width() || !_fx->base_height()) {
|
||||||
return;
|
throw std::runtime_error("No effect, or invalid base size.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_PROFILING
|
#ifdef ENABLE_PROFILING
|
||||||
|
|
@ -99,15 +98,12 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
gs_ortho(0, 1, 0, 1, -1, 1);
|
gs_ortho(0, 1, 0, 1, -1, 1);
|
||||||
|
|
||||||
vec4 clear_color = {0, 0, 0, 0};
|
|
||||||
gs_clear(GS_CLEAR_COLOR | GS_CLEAR_DEPTH, &clear_color, 0, 0);
|
|
||||||
|
|
||||||
/// Render original source
|
/// Render original source
|
||||||
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
|
if (obs_source_process_filter_begin(_self, GS_RGBA, OBS_NO_DIRECT_RENDERING)) {
|
||||||
gs_blend_state_push();
|
gs_blend_state_push();
|
||||||
gs_reset_blend_state();
|
gs_reset_blend_state();
|
||||||
gs_enable_blending(false);
|
|
||||||
gs_blend_function_separate(GS_BLEND_ONE, GS_BLEND_ZERO, GS_BLEND_SRCALPHA, GS_BLEND_ZERO);
|
gs_blend_function_separate(GS_BLEND_ONE, GS_BLEND_ZERO, GS_BLEND_SRCALPHA, GS_BLEND_ZERO);
|
||||||
|
gs_enable_blending(false);
|
||||||
gs_enable_depth_test(false);
|
gs_enable_depth_test(false);
|
||||||
gs_enable_stencil_test(false);
|
gs_enable_stencil_test(false);
|
||||||
gs_enable_stencil_write(false);
|
gs_enable_stencil_write(false);
|
||||||
|
|
@ -118,8 +114,7 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
|
|
||||||
gs_blend_state_pop();
|
gs_blend_state_pop();
|
||||||
} else {
|
} else {
|
||||||
obs_source_skip_video_filter(_self);
|
throw std::runtime_error("Failed to render previous source.");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,6 +127,10 @@ void shader_instance::video_render(gs_effect_t* effect)
|
||||||
_fx->set_input_a(_rt->get_texture());
|
_fx->set_input_a(_rt->get_texture());
|
||||||
_fx->render();
|
_fx->render();
|
||||||
}
|
}
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
obs_source_skip_video_filter(_self);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shader_factory::shader_factory()
|
shader_factory::shader_factory()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue