From e7bbb213a4039d24b3562f1c71fd1055ec61d553 Mon Sep 17 00:00:00 2001 From: Michael Fabian 'Xaymar' Dirks Date: Thu, 14 Dec 2017 03:52:29 +0100 Subject: [PATCH] filter-blur: Fix Blur filter occasionally not rendering An earlier commit changed how Blur filter rendered and thus m_technique was no longer being initialized, resulting in the check randomly failing if the memory was just right. This also adds some more extra logging to the instance creation in case things fail and fixed one MSVC warning. Fixes #1 --- source/filter-blur.cpp | 13 +++++++++++-- source/filter-blur.h | 1 - 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/filter-blur.cpp b/source/filter-blur.cpp index ab8676c8..b8d3cea8 100644 --- a/source/filter-blur.cpp +++ b/source/filter-blur.cpp @@ -280,6 +280,15 @@ Filter::Blur::Instance::Instance(obs_data_t *data, obs_source_t *context) : m_so m_rtVertical = gs_texrender_create(GS_RGBA, GS_ZS_NONE); obs_leave_graphics(); + if (!m_primaryRT) + P_LOG_ERROR(" Instance '%s' failed to create primary rendertarget.", obs_source_get_name(m_source)); + if (!m_secondaryRT) + P_LOG_ERROR(" Instance '%s' failed to create secondary rendertarget.", obs_source_get_name(m_source)); + if (!m_rtHorizontal) + P_LOG_ERROR(" Instance '%s' failed to create horizontal rendertarget.", obs_source_get_name(m_source)); + if (!m_rtVertical) + P_LOG_ERROR(" Instance '%s' failed to create vertical rendertarget.", obs_source_get_name(m_source)); + update(data); } @@ -353,7 +362,7 @@ void Filter::Blur::Instance::video_render(gs_effect_t *effect) { obs_source_skip_video_filter(m_source); return; } - if (!m_primaryRT || !m_technique || !m_effect) { + if (!m_primaryRT || !m_effect) { if (!m_errorLogged) P_LOG_ERROR(" Instance '%s' is unable to render.", obs_source_get_name(m_source), obs_source_get_name(target)); @@ -627,7 +636,7 @@ bool Filter::Blur::Instance::apply_gaussian_param() { std::shared_ptr tex; if ((m_size - 1) < MaxKernelSize) { - tex = g_gaussianKernels[m_size - 1]; + tex = g_gaussianKernels[size_t(m_size - 1)]; result = result && gs_set_param_texture(m_effect->GetObject(), "kernel", tex->GetObject()); } diff --git a/source/filter-blur.h b/source/filter-blur.h index e1c68e35..a74d2b46 100644 --- a/source/filter-blur.h +++ b/source/filter-blur.h @@ -91,7 +91,6 @@ namespace Filter { private: obs_source_t *m_source; - gs_technique_t *m_technique; gs_texrender_t *m_primaryRT, *m_secondaryRT; gs_texrender_t *m_rtHorizontal, *m_rtVertical; std::shared_ptr m_effect;