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