Blender V5.0
gpu_shader_binder_internal.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#pragma once
14
15#include <list>
16
17#include "BLI_string_ref.hh"
18#include "BLI_utility_mixins.hh"
19#include "BLI_vector.hh"
20
21#include "ocio_shader_shared.hh"
22
23#if defined(WITH_OPENCOLORIO)
24# include "opencolorio.hh"
25#endif
26
27struct CurveMapping;
28namespace blender::gpu {
29class Shader;
30class UniformBuf;
31class Texture;
32} // namespace blender::gpu
33
34namespace blender::ocio {
35
37
38namespace internal {
39
40/* Namespaces mnemonic index for texture slot that can be passed as integer argument. */
42 enum {
43 IMAGE = 0,
47 };
48};
49
50/* Namespaces mnemonic index for uniform buffer slot that can be passed as integer argument. */
52 enum {
55 LUTS = 2,
56 };
57};
58
61 std::string sampler_name;
62};
63
64struct GPUUniform {
65 std::string name;
66
67 /* They are only required for processors generated by the OpenColorIO. For the simplicity of the
68 * internal API use OpenColorIO type (avoiding making extra copies of the data coming from the
69 * OpenColorIO library). */
70#if defined(WITH_OPENCOLORIO)
71 OCIO_NAMESPACE::GpuShaderDesc::UniformData data;
72#endif
73};
74
76 public:
78
79 /* Dummy in case of no overlay. */
81
82 /* Uniforms */
85
87
94 bool initialize_common();
95};
96
98 public:
99 int lut_size = 0;
100 float *lut = nullptr;
101
104 size_t cache_id = 0;
105
107
111 void rasterize(CurveMapping &curve_mapping);
112
121 bool initialize_common(bool use_curve_mapping);
122};
123
125 public:
126 /* Cached display parameters. */
127 std::string from_colorspace;
128 std::string view;
129 std::string display;
130 std::string look;
131 bool use_curve_mapping = false;
132 bool use_hdr_buffer = false;
133 bool use_hdr_display = false;
135
136 /* The shader is valid and can be bound.
137 * Note that the cache might contain invalid shaders to prevent Blender from attempting to keep
138 * re-trying to build the same failing shader. */
139 bool is_valid = false;
140
141 gpu::Shader *shader = nullptr;
142
143 /* Uniform parameters. */
146
149
151
152 bool matches(const GPUDisplayParameters &display_parameters) const;
153
163 bool initialize_common();
164};
165
167 /* The maximum number of cached shaders. */
168 static constexpr int MAX_SIZE = 4;
169
170 public:
172
177 GPUDisplayShader *get(const GPUDisplayParameters &display_parameters);
178
184
188 void clear();
189
190 private:
191 std::list<GPUDisplayShader> cache_;
192};
193
194} // namespace internal
195} // namespace blender::ocio
BMesh const char void * data
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
void rasterize(CurveMapping &curve_mapping)
bool initialize_common(bool use_curve_mapping)
bool matches(const GPUDisplayParameters &display_parameters) const
GPUDisplayShader * get(const GPUDisplayParameters &display_parameters)