Blender V4.3
COM_cached_shader.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"
12
13#include "GPU_shader.hh"
14
16#include "COM_result.hh"
17
19
20/* ------------------------------------------------------------------------------------------------
21 * Cached Shader Key.
22 */
23
25 public:
26 std::string info_name;
28
30
31 uint64_t hash() const;
32};
33
34bool operator==(const CachedShaderKey &a, const CachedShaderKey &b);
35
36/* -------------------------------------------------------------------------------------------------
37 * Cached Shader.
38 *
39 * A cached resource that constructs and caches a GPU shader from the given info name with its
40 * output images' precision changed to the given precision. */
42 private:
43 GPUShader *shader_ = nullptr;
44
45 public:
46 CachedShader(const char *info_name, ResultPrecision precision);
47
49
50 GPUShader *shader() const;
51};
52
53/* ------------------------------------------------------------------------------------------------
54 * Cached Shader Container.
55 */
57 private:
59
60 public:
61 void reset() override;
62
63 /* Check if there is an available CachedShader cached resource with the given parameters in the
64 * container, if one exists, return its shader, otherwise, return the shader of a newly created
65 * one and add it to the container. In both cases, tag the cached resource as needed to keep it
66 * cached for the next evaluation. */
67 GPUShader *get(const char *info_name, ResultPrecision precision);
68};
69
70} // namespace blender::realtime_compositor
struct GPUShader GPUShader
GPUShader * get(const char *info_name, ResultPrecision precision)
CachedShaderKey(const char *info_name, ResultPrecision precision)
CachedShader(const char *info_name, ResultPrecision precision)
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