Blender V4.5
COM_static_cache_manager.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
7#include "COM_bokeh_kernel.hh"
8#include "COM_cached_image.hh"
9#include "COM_cached_mask.hh"
10#include "COM_cached_shader.hh"
11#include "COM_cached_texture.hh"
16#include "COM_keying_screen.hh"
23
24namespace blender::compositor {
25
26/* -------------------------------------------------------------------------------------------------
27 * Static Cache Manager
28 *
29 * A static cache manager is a collection of cached resources that can be retrieved when needed and
30 * created if not already available. In particular, each cached resource type has its own instance
31 * of a container derived from the CachedResourceContainer type in the class. All instances of that
32 * cached resource type are stored and tracked in the container. See the CachedResource and
33 * CachedResourceContainer classes for more information.
34 *
35 * The manager deletes the cached resources that are no longer needed. A cached resource is said to
36 * be not needed when it was not used in the previous evaluation. This is done through the
37 * following mechanism:
38 *
39 * - Before every evaluation, do the following:
40 * 1. All resources whose CachedResource::needed flag is false are deleted.
41 * 2. The CachedResource::needed flag of all remaining resources is set to false.
42 * - During evaluation, when retrieving any cached resource, set its CachedResource::needed flag to
43 * true.
44 *
45 * In effect, any resource that was used in the previous evaluation but was not used in the current
46 * evaluation will be deleted before the next evaluation. This mechanism is implemented in the
47 * reset() method of the class, which should be called before every evaluation. The reset for the
48 * next evaluation can be skipped by calling the skip_next_reset() method, see its description for
49 * more information. */
51 public:
68
69 private:
70 /* The cache manager should skip the next reset. See the skip_next_reset() method for more
71 * information. */
72 bool should_skip_next_reset_ = false;
73
74 public:
75 /* Reset the cache manager by deleting the cached resources that are no longer needed because
76 * they weren't used in the last evaluation and prepare the remaining cached resources to track
77 * their needed status in the next evaluation. See the class description for more information.
78 * This should be called before every evaluation. */
79 void reset();
80
81 /* Specifies that the cache manager should skip the next reset. This is useful for instance when
82 * the evaluation gets canceled before it was fully done, in that case, we wouldn't want to
83 * invalidate the cache because not all operations that use cached resources got the chance to
84 * mark their used resources as still in use. So we wait until a full evaluation happen before we
85 * decide that some resources are no longer needed. */
86 void skip_next_reset();
87};
88
89} // namespace blender::compositor
SMAAPrecomputedTexturesContainer smaa_precomputed_textures
OCIOColorSpaceConversionShaderContainer ocio_color_space_conversion_shaders
MorphologicalDistanceFeatherWeightsContainer morphological_distance_feather_weights
SymmetricSeparableBlurWeightsContainer symmetric_separable_blur_weights
VanVlietGaussianCoefficientsContainer van_vliet_gaussian_coefficients
SymmetricBlurWeightsContainer symmetric_blur_weights
DericheGaussianCoefficientsContainer deriche_gaussian_coefficients