Files
test/source/blender/compositor/intern/static_cache_manager.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

39 lines
923 B
C++
Raw Normal View History

/* SPDX-FileCopyrightText: 2023 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "COM_static_cache_manager.hh"
namespace blender::compositor {
void StaticCacheManager::reset()
{
if (should_skip_next_reset_) {
should_skip_next_reset_ = false;
return;
}
symmetric_blur_weights.reset();
symmetric_separable_blur_weights.reset();
morphological_distance_feather_weights.reset();
cached_masks.reset();
smaa_precomputed_textures.reset();
ocio_color_space_conversion_shaders.reset();
distortion_grids.reset();
keying_screens.reset();
Realtime Compositor: Support full precision compositing This patch adds support for full precision compositing for the Realtime Compositor. A new precision option was added to the compositor to change between half and full precision compositing, where the Auto option uses half for the viewport compositor and the interactive render compositor, while full is used for final renders. The compositor context now need to implement the get_precision() method to indicate its preferred precision. Intermediate results will be stored using the context's precision, with a number of exceptions that can use a different precision regardless of the context's precision. For instance, summed area tables are always stored in full float results even if the context specified half float. Conversely, jump flooding tables are always stored in half integer results even if the context specified full. The former requires full float while the latter has no use for it. Since shaders are created for a specific precision, we need two variants of each compositor shader to account for the context's possible precision. However, to avoid doubling the shader info count and reduce boilerplate code and development time, an automated mechanism was employed. A single shader info of whatever precision needs to be added, then, at runtime, the shader info can be adjusted to change the precision of the outputs. That shader variant is then cached in the static cache manager for future processing-free shader retrieval. Therefore, the shader manager was removed in favor of a cached shader container in the static cache manager. A number of utilities were added to make the creation of results as well as the retrieval of shader with the target precision easier. Further, a number of precision-specific shaders were removed in favor of more generic ones that utilizes the aforementioned shader retrieval mechanism. Pull Request: https://projects.blender.org/blender/blender/pulls/113476
2023-11-08 08:32:00 +01:00
cached_shaders.reset();
bokeh_kernels.reset();
cached_images.reset();
Realtime Compositor: Implement Fast Gaussian blur This patch implements the Fast Gaussian blur mode for the Realtime Compositor. This is a faster but less accurate implementation of Gaussian blur. This is implemented as a recursive Gaussian blur algorithm based on the general method outlined in the following paper: Hale, Dave. "Recursive gaussian filters." CWP-546 (2006). In particular, based on the table in Section 5 Conclusion, for very low radius blur, we use a direct separable Gaussian convolution. For medium blur radius, we use the fourth order IIR Deriche filter based on the following paper: Deriche, Rachid. Recursively implementating the Gaussian and its derivatives. Diss. INRIA, 1993. For high radius blur, we use the fourth order IIR Van Vliet filter based on the following paper: Van Vliet, Lucas J., Ian T. Young, and Piet W. Verbeek. "Recursive Gaussian derivative filters." Proceedings. Fourteenth International Conference on Pattern Recognition (Cat. No. 98EX170). Vol. 1. IEEE, 1998. That's because direct convolution is faster and more accurate for very low radius, while the Deriche filter is more accurate for medium blur radius, while Van Vliet is more accurate for high blur radius. The criteria suggested by the paper is a sigma value threshold of 3 and 32 for the Deriche and Van Vliet filters respectively, which we apply on the larger of the two dimensions. Both the Deriche and Van Vliet filters are numerically unstable for high blur radius. So we decompose the Van Vliet filter into a parallel bank of smaller second order filters based on the method of partial fractions discussed in the book: Oppenheim, Alan V. Discrete-time signal processing. Pearson Education India, 1999. We leave the Deriche filter as is since it is only used for low radii anyways. Compared to the CPU implementation, this implementation is more accurate, but less numerically stable, since CPU uses doubles, which is not feasible for the GPU. The only change of behavior between CPU and this implementation is that this implementation uses the same radius, so Fast Gaussian will match normal Gaussian, while the CPU implementation has a radius that is 1.5x the size of normal Gaussian. A patch to change the CPU behavior #121211. Pull Request: https://projects.blender.org/blender/blender/pulls/120431
2024-05-01 09:57:30 +02:00
deriche_gaussian_coefficients.reset();
van_vliet_gaussian_coefficients.reset();
fog_glow_kernels.reset();
image_coordinates.reset();
}
void StaticCacheManager::skip_next_reset()
{
should_skip_next_reset_ = true;
}
} // namespace blender::compositor