mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
make direct filter rendering optional (can be useful for certain cases)
This commit is contained in:
parent
bd47d9fe74
commit
922eb7b8e8
|
@ -968,7 +968,8 @@ static inline void render_filter_tex(texture_t tex, effect_t effect,
|
|||
}
|
||||
|
||||
void obs_source_process_filter(obs_source_t filter, texrender_t texrender,
|
||||
effect_t effect, uint32_t width, uint32_t height)
|
||||
effect_t effect, uint32_t width, uint32_t height,
|
||||
enum allow_direct_render allow_direct)
|
||||
{
|
||||
obs_source_t target = obs_filter_gettarget(filter);
|
||||
obs_source_t parent = obs_filter_getparent(filter);
|
||||
|
@ -977,19 +978,24 @@ void obs_source_process_filter(obs_source_t filter, texrender_t texrender,
|
|||
int cx = obs_source_getwidth(target);
|
||||
int cy = obs_source_getheight(target);
|
||||
bool yuv = (target_flags & SOURCE_YUV) != 0;
|
||||
bool expects_def = (parent_flags & SOURCE_DEFAULT_EFFECT) != 0;
|
||||
bool can_directly = allow_direct == ALLOW_DIRECT_RENDERING;
|
||||
|
||||
/* if the parent does not use any custom effects, and this is the last
|
||||
* filter in the chain for the parent, then render the parent directly
|
||||
* using the filter effect instead of rendering to texture to reduce
|
||||
* the total number of passes */
|
||||
if ((parent_flags & SOURCE_DEFAULT_EFFECT) != 0 && target == parent) {
|
||||
if (can_directly && expects_def && target == parent) {
|
||||
render_filter_bypass(target, effect, width, height, yuv);
|
||||
return;
|
||||
}
|
||||
|
||||
if (texrender_begin(texrender, cx, cy)) {
|
||||
gs_ortho(0.0f, (float)cx, 0.0f, (float)cy, -100.0f, 100.0f);
|
||||
obs_source_video_render(target);
|
||||
if (expects_def && parent == target)
|
||||
obs_source_default_render(parent, yuv);
|
||||
else
|
||||
obs_source_video_render(target);
|
||||
texrender_end(texrender);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,11 @@ enum order_movement {
|
|||
ORDER_MOVE_BOTTOM
|
||||
};
|
||||
|
||||
enum allow_direct_render {
|
||||
NO_DIRECT_RENDERING,
|
||||
ALLOW_DIRECT_RENDERING,
|
||||
};
|
||||
|
||||
struct obs_video_info {
|
||||
/* graphics module to use (usually "libobs-opengl" or "libobs-d3d11") */
|
||||
const char *graphics_module;
|
||||
|
@ -412,7 +417,8 @@ EXPORT void obs_source_releaseframe(obs_source_t source,
|
|||
/** Default RGB filter handler for generic effect filters */
|
||||
EXPORT void obs_source_process_filter(obs_source_t filter,
|
||||
texrender_t texrender, effect_t effect,
|
||||
uint32_t width, uint32_t height);
|
||||
uint32_t width, uint32_t height,
|
||||
enum allow_direct_render allow_direct);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
|
|
@ -56,5 +56,5 @@ void test_video_tick(struct test_filter *tf, float seconds)
|
|||
void test_video_render(struct test_filter *tf)
|
||||
{
|
||||
obs_source_process_filter(tf->source, tf->texrender, tf->whatever,
|
||||
0, 0);
|
||||
0, 0, ALLOW_DIRECT_RENDERING);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue