Blender V4.3
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 "GPU_texture.hh"
15
16#include "DNA_texture_types.h"
17
19
21
22class Context;
23
24/* ------------------------------------------------------------------------------------------------
25 * Cached Texture Key.
26 */
28 public:
32
33 CachedTextureKey(int2 size, float3 offset, float3 scale);
34
35 uint64_t hash() const;
36};
37
38bool operator==(const CachedTextureKey &a, const CachedTextureKey &b);
39
40/* -------------------------------------------------------------------------------------------------
41 * Cached Texture.
42 *
43 * A cached resource that computes and caches a GPU texture containing the result of evaluating the
44 * given texture ID on a space that spans the given size, parameterized by the given parameters. */
46 private:
47 GPUTexture *color_texture_ = nullptr;
48 GPUTexture *value_texture_ = nullptr;
49
50 public:
51 CachedTexture(Context &context,
52 Tex *texture,
53 bool use_color_management,
54 int2 size,
55 float3 offset,
56 float3 scale);
57
59
60 GPUTexture *color_texture();
61
62 GPUTexture *value_texture();
63};
64
65/* ------------------------------------------------------------------------------------------------
66 * Cached Texture Container.
67 */
69 private:
71
72 public:
73 void reset() override;
74
75 /* Check if the given texture ID has changed since the last time it was retrieved through its
76 * recalculate flag, and if so, invalidate its corresponding cached textures and reset the
77 * recalculate flag to ready it to track the next change. Then, check if there is an available
78 * CachedTexture cached resource with the given parameters in the container, if one exists,
79 * return it, otherwise, return a newly created one and add it to the container. In both cases,
80 * tag the cached resource as needed to keep it cached for the next evaluation. */
81 CachedTexture &get(Context &context,
82 Tex *texture,
83 bool use_color_management,
84 int2 size,
85 float3 offset,
86 float3 scale);
87};
88
89} // namespace blender::realtime_compositor
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)
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