Blender V4.3
COM_symmetric_blur_weights.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 <cstdint>
8#include <memory>
9
10#include "BLI_map.hh"
12
13#include "GPU_shader.hh"
14#include "GPU_texture.hh"
15
17
19
20class Context;
21
22/* ------------------------------------------------------------------------------------------------
23 * Symmetric Blur Weights Key.
24 */
26 public:
27 int type;
29
30 SymmetricBlurWeightsKey(int type, float2 radius);
31
32 uint64_t hash() const;
33};
34
36
37/* -------------------------------------------------------------------------------------------------
38 * Symmetric Blur Weights.
39 *
40 * A cached resource that computes and caches a 2D GPU texture containing the weights of the filter
41 * of the given type and radius. The filter is assumed to be symmetric, because the filter
42 * functions are evaluated on the normalized distance to the center. Consequently, only the upper
43 * right quadrant are computed and the shader takes that into consideration. */
45 private:
46 GPUTexture *texture_ = nullptr;
47
48 public:
49 SymmetricBlurWeights(Context &context, int type, float2 radius);
50
52
53 void bind_as_texture(GPUShader *shader, const char *texture_name) const;
54
55 void unbind_as_texture() const;
56};
57
58/* ------------------------------------------------------------------------------------------------
59 * Symmetric Blur Weights Container.
60 */
62 private:
64
65 public:
66 void reset() override;
67
68 /* Check if there is an available SymmetricBlurWeights cached resource with the given parameters
69 * in the container, if one exists, return it, otherwise, return a newly created one and add it
70 * to the container. In both cases, tag the cached resource as needed to keep it cached for the
71 * next evaluation. */
72 SymmetricBlurWeights &get(Context &context, int type, float2 radius);
73};
74
75} // namespace blender::realtime_compositor
struct GPUShader GPUShader
SymmetricBlurWeights & get(Context &context, int type, float2 radius)
SymmetricBlurWeights(Context &context, int type, float2 radius)
void bind_as_texture(GPUShader *shader, const char *texture_name) const
local_group_size(16, 16) .push_constant(Type b
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
unsigned __int64 uint64_t
Definition stdint.h:90