Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2022-11-04 17:14:22 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-11-04 17:14:22 +0300
commit85ce4882981943b5a306090f03482bd5397c503d (patch)
treeee5c20f6a58d7688a304f4958d5466a4c707c375 /source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh
parent943d574185d784c8e4c30b50e52e11f54b11ec50 (diff)
Realtime Compositor: Implement static cache manager
This patch introduces the concept of a Cached Resource that can be cached across compositor evaluations as well as used by multiple operations in the same evaluation. Additionally, this patch implements a new structure for the realtime compositor, the Static Cache Manager, that manages all the cached resources and deletes them when they are no longer needed. This improves responsiveness while adjusting compositor node trees and also conserves memory usage. Differential Revision: https://developer.blender.org/D16357 Reviewed By: Clement Foucault
Diffstat (limited to 'source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh')
-rw-r--r--source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh53
1 files changed, 53 insertions, 0 deletions
diff --git a/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh
new file mode 100644
index 00000000000..85e75e4535d
--- /dev/null
+++ b/source/blender/compositor/realtime_compositor/cached_resources/COM_symmetric_separable_blur_weights.hh
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#pragma once
+
+#include <cstdint>
+
+#include "BLI_math_vec_types.hh"
+
+#include "GPU_shader.h"
+#include "GPU_texture.h"
+
+#include "COM_cached_resource.hh"
+
+namespace blender::realtime_compositor {
+
+/* ------------------------------------------------------------------------------------------------
+ * Symmetric Separable Blur Weights Key.
+ */
+class SymmetricSeparableBlurWeightsKey {
+ public:
+ int type;
+ float radius;
+
+ SymmetricSeparableBlurWeightsKey(int type, float radius);
+
+ uint64_t hash() const;
+};
+
+bool operator==(const SymmetricSeparableBlurWeightsKey &a,
+ const SymmetricSeparableBlurWeightsKey &b);
+
+/* -------------------------------------------------------------------------------------------------
+ * Symmetric Separable Blur Weights.
+ *
+ * A cached resource that computes and caches a 1D GPU texture containing the weights of the
+ * separable filter of the given type and radius. The filter is assumed to be symmetric, because
+ * the filter functions are all even functions. Consequently, only the positive half of the filter
+ * is computed and the shader takes that into consideration. */
+class SymmetricSeparableBlurWeights : public CachedResource {
+ private:
+ GPUTexture *texture_ = nullptr;
+
+ public:
+ SymmetricSeparableBlurWeights(int type, float radius);
+
+ ~SymmetricSeparableBlurWeights();
+
+ void bind_as_texture(GPUShader *shader, const char *texture_name) const;
+
+ void unbind_as_texture() const;
+};
+
+} // namespace blender::realtime_compositor