Blender V5.3
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#include "opencolorio.hh"
24
25namespace blender {
26
27struct CurveMapping;
28namespace gpu {
29class Shader;
30class UniformBuf;
31class Texture;
32} // namespace gpu
33
34namespace 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 OCIO_NAMESPACE::GpuShaderDesc::UniformData data;
71};
72
74 public:
76
77 /* Dummy in case of no overlay. */
78 gpu::Texture *dummy = nullptr;
79
80 /* Uniforms */
83
85
92 bool initialize_common();
93};
94
96 public:
97 int lut_size = 0;
98 float *lut = nullptr;
99
102 size_t cache_id = 0;
103
105
109 void rasterize(CurveMapping &curve_mapping);
110
119 bool initialize_common(bool use_curve_mapping);
120};
121
123 public:
124 /* Cached display parameters. */
125 std::string from_colorspace;
126 std::string view;
127 std::string display;
128 std::string look;
129 bool use_curve_mapping = false;
130 bool use_hdr_buffer = false;
131 bool use_hdr_display = false;
133 bool use_scope_space = false;
134
135 /* The shader is valid and can be bound.
136 * Note that the cache might contain invalid shaders to prevent Blender from attempting to keep
137 * re-trying to build the same failing shader. */
138 bool is_valid = false;
139
140 gpu::Shader *shader = nullptr;
141
142 /* Uniform parameters. */
145
148
150
151 bool matches(const GPUDisplayParameters &display_parameters) const;
152
162 bool initialize_common();
163};
164
166 /* The maximum number of cached shaders. */
167 static constexpr int MAX_SIZE = 4;
168
169 public:
171
176 GPUDisplayShader *get(const GPUDisplayParameters &display_parameters);
177
183
187 void clear();
188
189 private:
190 std::list<GPUDisplayShader> cache_;
191};
192
193} // namespace internal
194} // namespace ocio
195} // namespace blender
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)
BMesh Iterators.
OCIO_NAMESPACE::GpuShaderDesc::UniformData data