Blender V5.0
COM_smaa_precomputed_textures.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 <memory>
8
9#include "GPU_shader.hh"
10#include "GPU_texture.hh"
11
13#include "COM_result.hh"
14
15namespace blender::compositor {
16
17class Context;
18
19/* -------------------------------------------------------------------------------------------------
20 * SMAA Precomputed Textures.
21 *
22 * A cached resource that caches the precomputed textures needed by the SMAA algorithm. The
23 * precomputed textures are constants, so this is a parameterless cached resource. */
25 public:
26 /* CPU storage, unused for GPU execution device. We can't store the GPU textures in the result
27 * because it requires special data types that are not supported by the Result class. */
30
31 private:
32 /* GPU storage, unused for CPU execution device. */
33 blender::gpu::Texture *search_texture_ = nullptr;
34 blender::gpu::Texture *area_texture_ = nullptr;
35
36 public:
38
40
41 void bind_search_texture(gpu::Shader *shader, const char *sampler_name) const;
42
43 void unbind_search_texture() const;
44
45 void bind_area_texture(gpu::Shader *shader, const char *sampler_name) const;
46
47 void unbind_area_texture() const;
48
49 private:
50 void compute_gpu();
51
52 void compute_cpu();
53};
54
55/* ------------------------------------------------------------------------------------------------
56 * SMAA Precomputed Textures Container.
57 */
59 private:
60 std::unique_ptr<SMAAPrecomputedTextures> textures_;
61
62 public:
63 void reset() override;
64
65 /* Check if a cached SMAA precomputed texture exists, if it does, return it, otherwise, return
66 * a newly created one and store it in the container. In both cases, tag the cached resource as
67 * needed to keep it cached for the next evaluation. */
69};
70
71} // namespace blender::compositor
void bind_area_texture(gpu::Shader *shader, const char *sampler_name) const
void bind_search_texture(gpu::Shader *shader, const char *sampler_name) const