Blender V5.3
OCIO_gpu_shader_binder.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
14
15#pragma once
16
17#include <memory>
18#include <string>
19
20#include "BLI_array.hh"
21#include "BLI_span.hh"
22#include "BLI_string_ref.hh"
23
24namespace blender {
25
26struct CurveMapping;
27namespace gpu {
28class Shader;
29} // namespace gpu
30
31namespace ocio {
32
33class Config;
34
35namespace internal {
37class GPUShaderCache;
38} // namespace internal
39
41 /* Convert from a colorspace to a display, using the view transform and look. */
46 /* Artistic controls. */
48 float scale = 1.0f;
49 float exponent = 1.0f;
50 float dither = 0.0f;
51 float temperature = 6500.0f;
52 float tint = 10.0f;
53 float opacity = 1.0f;
54 bool use_white_balance = false;
55 /* Divide RGB by alpha before performing the transform. */
56 bool use_predivide = false;
57 /* Composite an overlay buffer on top of the image. */
58 bool do_overlay_merge = false;
59 /* Writing to a HDR buffer. */
60 bool use_hdr_buffer = false;
61 /* Chosen display is a HDR display. */
62 bool use_hdr_display = false;
63 /* Rather than outputting colors for the specified display, output extended
64 * sRGB colors emulating the specified display. */
66 /* Rather than outputting native display colors, output in a color space
67 * suitable for plotting SDR or HDR scopes. */
68 bool use_scope_space = false;
69};
70
72 /* Cache of shaders used for conversion to the display space. */
73 std::unique_ptr<internal::GPUShaderCache> display_cache_;
74
75 /* Cache of shaders used for conversion to scene linear space. */
76 std::unique_ptr<internal::GPUShaderCache> scene_linear_cache_;
77
78 public:
79 explicit GPUShaderBinder(const Config &config);
81
88 bool display_bind(const GPUDisplayParameters &display_parameters) const;
89
96 bool to_scene_linear_bind(StringRefNull from_colorspace, bool use_predivide) const;
97
104 void unbind() const;
105
109 void clear_caches() const;
110
111 protected:
113
119 virtual void construct_display_shader(internal::GPUDisplayShader &display_shader) const = 0;
120
125 virtual void construct_scene_linear_shader(internal::GPUDisplayShader &display_shader) const = 0;
126
131 static bool create_gpu_shader(internal::GPUDisplayShader &display_shader,
132 StringRefNull fragment_source,
133 Span<std::array<StringRefNull, 2>> additional_defines);
134};
135
136} // namespace ocio
137} // namespace blender
virtual void construct_display_shader(internal::GPUDisplayShader &display_shader) const =0
static bool create_gpu_shader(internal::GPUDisplayShader &display_shader, StringRefNull fragment_source, Span< std::array< StringRefNull, 2 > > additional_defines)
bool to_scene_linear_bind(StringRefNull from_colorspace, bool use_predivide) const
bool display_bind(const GPUDisplayParameters &display_parameters) const
virtual void construct_scene_linear_shader(internal::GPUDisplayShader &display_shader) const =0
GPUShaderBinder(const Config &config)
BMesh Iterators.