Blender V4.5
COM_cached_texture.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#include <string>
10
11#include "BLI_map.hh"
13
14#include "DNA_texture_types.h"
15
17#include "COM_result.hh"
18
19namespace blender::compositor {
20
21class Context;
22
23/* ------------------------------------------------------------------------------------------------
24 * Cached Texture Key.
25 */
36
37bool operator==(const CachedTextureKey &a, const CachedTextureKey &b);
38
39/* -------------------------------------------------------------------------------------------------
40 * Cached Texture.
41 *
42 * A cached resource that computes and caches a GPU texture containing the result of evaluating the
43 * given texture ID on a space that spans the given size, parameterized by the given parameters. */
45 private:
46 Array<float4> color_pixels_;
47 Array<float> value_pixels_;
48
49 public:
52
53 CachedTexture(Context &context,
54 Tex *texture,
55 bool use_color_management,
56 int2 size,
57 float3 offset,
58 float3 scale);
59
61};
62
63/* ------------------------------------------------------------------------------------------------
64 * Cached Texture Container.
65 */
67 private:
69
70 /* A map that stores the update counts of the textures at the moment they were cached. */
71 Map<std::string, uint64_t> update_counts_;
72
73 public:
74 void reset() override;
75
76 /* Check if the given texture ID has changed since the last time it was retrieved through its
77 * recalculate flag, and if so, invalidate its corresponding cached textures and reset the
78 * recalculate flag to ready it to track the next change. Then, check if there is an available
79 * CachedTexture cached resource with the given parameters in the container, if one exists,
80 * return it, otherwise, return a newly created one and add it to the container. In both cases,
81 * tag the cached resource as needed to keep it cached for the next evaluation. */
82 CachedTexture &get(Context &context,
83 Tex *texture,
84 bool use_color_management,
85 int2 size,
86 float3 offset,
87 float3 scale);
88};
89
90} // namespace blender::compositor
unsigned long long int uint64_t
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
CachedTexture & get(Context &context, Tex *texture, bool use_color_management, int2 size, float3 offset, float3 scale)
CachedTextureKey(int2 size, float3 offset, float3 scale)
CachedTexture(Context &context, Tex *texture, bool use_color_management, int2 size, float3 offset, float3 scale)
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
bool operator==(const BokehKernelKey &a, const BokehKernelKey &b)
VecBase< int32_t, 2 > int2
VecBase< float, 3 > float3