]> git.sesse.net Git - movit/commit
Collapse passes more aggressively in the face of size changes.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 2 Sep 2015 23:46:58 +0000 (01:46 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 2 Sep 2015 23:46:58 +0000 (01:46 +0200)
commitb564238fa1293c01c77bcabe7b2de267f146ab24
treefa2bcb2ed9aa4def54425891a22ba0922b4ca555
parent7878253d0d7b5aaa6b701499e588b31f2c5edca2
Collapse passes more aggressively in the face of size changes.

The motivating chain for this change was a case where we had
a SinglePassResampleEffect (the second half of a ResampleEffect)
feeding into a PaddingEffect, feeding into an OverlayEffect.
Currently, since the two former change output size, we'd bounce
to a temporary texture twice (output size changes would always
cause bounces).

However, this is needlessly conservative. The reason for bouncing
when changing output size is really if you want to get rid of
data by downscaling and then later upsampling, e.g. for a blur.
(It could also be useful for cropping, but we don't really use
that right now; PaddingEffect, which does crop, explicitly checks
the borders anyway to set the border color manually.) But in this case,
we are not downscaling at all, so we could just drop the bounce,
saving tons of texture bandwidth.

Thus, we add yet more parameters that effects can specify; first,
that an effect uses _one-to-one_ sampling; that is, that it
 will only use its input as-is without sampling
between texels or outside the border (so the different
interpolation and border behavior will be irrelevant).
(Actually, almost all of our effects fall into this category.)
Second, a flag saying that even if an effect changes size,
it doesn't use virtual sizes (otherwise even a one-to-one effect
would de-facto be sampling between texels). If these flags
are set on the input and the output respectively, we can avoid
the bounce, at least unless there's an effect that's _not_
one-to-one further up the chain.

For my motivating case, this folded eight phases into four,
changing ~16.0 ms into ~10.6 ms rendering time. Seemingly
memory bandwidth is a really precious resource on my laptop's
GPU.
28 files changed:
alpha_division_effect.h
alpha_multiplication_effect.h
blur_effect.h
colorspace_conversion_effect.h
complex_modulate_effect.h
diffusion_effect.h
dither_effect.h
effect.h
effect_chain.cpp
effect_chain.h
effect_chain_test.cpp
fft_pass_effect.h
gamma_compression_effect.h
gamma_expansion_effect.h
glow_effect.h
lift_gamma_gain_effect.h
luma_mix_effect.h
mirror_effect.h
mix_effect.h
multiply_effect.h
overlay_effect.h
padding_effect.h
resample_effect.h
resize_effect.h
saturation_effect.h
slice_effect.h
vignette_effect.h
white_balance_effect.h