Blender V5.0
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
24struct CurveMapping;
25namespace blender::gpu {
26class Shader;
27} // namespace blender::gpu
28
29namespace blender::ocio {
30
31class Config;
32
33namespace internal {
35class GPUShaderCache;
36} // namespace internal
37
39 /* Convert from a colorspace to a display, using the view transform and look. */
44 /* Artistic controls. */
46 float scale = 1.0f;
47 float exponent = 1.0f;
48 float dither = 0.0f;
49 float temperature = 6500.0f;
50 float tint = 10.0f;
51 bool use_white_balance = false;
52 /* Divide RGB by alpha before performing the transform. */
53 bool use_predivide = false;
54 /* Composite an overlay buffer on top of the image. */
55 bool do_overlay_merge = false;
56 /* Writing to a HDR buffer. */
57 bool use_hdr_buffer = false;
58 /* Chosen display is a HDR display. */
59 bool use_hdr_display = false;
60 /* Rather than outputting colors for the specified display, output extended
61 * sRGB colors emulating the specified display. */
63};
64
66 /* Cache of shaders used for conversion to the display space. */
67 std::unique_ptr<internal::GPUShaderCache> display_cache_;
68
69 /* Cache of shaders used for conversion to scene linear space. */
70 std::unique_ptr<internal::GPUShaderCache> scene_linear_cache_;
71
72 public:
73 explicit GPUShaderBinder(const Config &config);
75
82 bool display_bind(const GPUDisplayParameters &display_parameters) const;
83
90 bool to_scene_linear_bind(StringRefNull from_colorspace, bool use_predivide) const;
91
98 void unbind() const;
99
103 void clear_caches() const;
104
105 protected:
107
113 virtual void construct_display_shader(internal::GPUDisplayShader &display_shader) const = 0;
114
119 virtual void construct_scene_linear_shader(internal::GPUDisplayShader &display_shader) const = 0;
120
125 static bool create_gpu_shader(internal::GPUDisplayShader &display_shader,
126 StringRefNull fragment_source,
127 Span<std::array<StringRefNull, 2>> additional_defines);
128};
129
130} // namespace blender::ocio
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)