libobs: Allow filters to specify technique

This commit is contained in:
John Bradley 2015-05-22 13:01:00 -05:00 committed by jp9000
parent 9e15e3d8fd
commit 310f390e1e
2 changed files with 43 additions and 6 deletions

View file

@ -2592,9 +2592,9 @@ const char *obs_source_get_id(const obs_source_t *source)
}
static inline void render_filter_bypass(obs_source_t *target,
gs_effect_t *effect)
gs_effect_t *effect, const char *tech_name)
{
gs_technique_t *tech = gs_effect_get_technique(effect, "Draw");
gs_technique_t *tech = gs_effect_get_technique(effect, tech_name);
size_t passes, i;
passes = gs_technique_begin(tech);
@ -2607,9 +2607,9 @@ static inline void render_filter_bypass(obs_source_t *target,
}
static inline void render_filter_tex(gs_texture_t *tex, gs_effect_t *effect,
uint32_t width, uint32_t height)
uint32_t width, uint32_t height, const char *tech_name)
{
gs_technique_t *tech = gs_effect_get_technique(effect, "Draw");
gs_technique_t *tech = gs_effect_get_technique(effect, tech_name);
gs_eparam_t *image = gs_effect_get_param_by_name(effect, "image");
size_t passes, i;
@ -2694,6 +2694,31 @@ void obs_source_process_filter_begin(obs_source_t *filter,
gs_blend_state_pop();
}
void obs_source_process_filter_tech_end(obs_source_t *filter, gs_effect_t *effect,
uint32_t width, uint32_t height, const char *tech_name)
{
obs_source_t *target, *parent;
gs_texture_t *texture;
uint32_t target_flags, parent_flags;
if (!filter) return;
target = obs_filter_get_target(filter);
parent = obs_filter_get_parent(filter);
target_flags = target->info.output_flags;
parent_flags = parent->info.output_flags;
const char *tech = tech_name ? tech_name : "Draw";
if (can_bypass(target, parent, parent_flags, filter->allow_direct)) {
render_filter_bypass(target, effect, tech);
} else {
texture = gs_texrender_get_texture(filter->filter_texrender);
render_filter_tex(texture, effect, width, height, tech);
}
}
void obs_source_process_filter_end(obs_source_t *filter, gs_effect_t *effect,
uint32_t width, uint32_t height)
{
@ -2710,11 +2735,12 @@ void obs_source_process_filter_end(obs_source_t *filter, gs_effect_t *effect,
parent_flags = parent->info.output_flags;
if (can_bypass(target, parent, parent_flags, filter->allow_direct)) {
render_filter_bypass(target, effect);
render_filter_bypass(target, effect, "Draw");
} else {
texture = gs_texrender_get_texture(filter->filter_texrender);
if (texture)
render_filter_tex(texture, effect, width, height);
render_filter_tex(texture, effect, width, height,
"Draw");
}
}

View file

@ -954,6 +954,17 @@ EXPORT void obs_source_process_filter_begin(obs_source_t *filter,
EXPORT void obs_source_process_filter_end(obs_source_t *filter,
gs_effect_t *effect, uint32_t width, uint32_t height);
/**
* Draws the filter with a specific technique.
*
* Before calling this function, first call obs_source_process_filter_begin and
* then set the effect parameters, and then call this function to finalize the
* filter.
*/
EXPORT void obs_source_process_filter_tech_end(obs_source_t *filter,
gs_effect_t *effect, uint32_t width, uint32_t height,
const char *tech_name);
/** Skips the filter if the filter is invalid and cannot be rendered */
EXPORT void obs_source_skip_video_filter(obs_source_t *filter);