Blender V4.3
compositor_parallel_reduction_info.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
6
7GPU_SHADER_CREATE_INFO(compositor_parallel_reduction_shared)
8 .local_group_size(16, 16)
9 .push_constant(Type::BOOL, "is_initial_reduction")
10 .sampler(0, ImageType::FLOAT_2D, "input_tx")
11 .compute_source("compositor_parallel_reduction.glsl");
12
13/* --------------------------------------------------------------------
14 * Sum Reductions.
15 */
16
17GPU_SHADER_CREATE_INFO(compositor_sum_shared)
18 .additional_info("compositor_parallel_reduction_shared")
19 .define("REDUCE(lhs, rhs)", "lhs + rhs");
20
21GPU_SHADER_CREATE_INFO(compositor_sum_float_shared)
22 .additional_info("compositor_sum_shared")
23 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
24 .define("TYPE", "float")
25 .define("IDENTITY", "0.0")
26 .define("LOAD(value)", "value.x");
27
28GPU_SHADER_CREATE_INFO(compositor_sum_red)
29 .additional_info("compositor_sum_float_shared")
30 .define("INITIALIZE(value)", "value.r")
31 .do_static_compilation(true);
32
33GPU_SHADER_CREATE_INFO(compositor_sum_green)
34 .additional_info("compositor_sum_float_shared")
35 .define("INITIALIZE(value)", "value.g")
36 .do_static_compilation(true);
37
38GPU_SHADER_CREATE_INFO(compositor_sum_blue)
39 .additional_info("compositor_sum_float_shared")
40 .define("INITIALIZE(value)", "value.b")
41 .do_static_compilation(true);
42
43GPU_SHADER_CREATE_INFO(compositor_sum_luminance)
44 .additional_info("compositor_sum_float_shared")
45 .push_constant(Type::VEC3, "luminance_coefficients")
46 .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
47 .do_static_compilation(true);
48
49GPU_SHADER_CREATE_INFO(compositor_sum_log_luminance)
50 .additional_info("compositor_sum_float_shared")
51 .push_constant(Type::VEC3, "luminance_coefficients")
52 .define("INITIALIZE(value)", "log(max(dot(value.rgb, luminance_coefficients), 1e-5))")
53 .do_static_compilation(true);
54
55GPU_SHADER_CREATE_INFO(compositor_sum_color)
56 .additional_info("compositor_sum_shared")
57 .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
58 .define("TYPE", "vec4")
59 .define("IDENTITY", "vec4(0.0)")
60 .define("INITIALIZE(value)", "value")
61 .define("LOAD(value)", "value")
62 .do_static_compilation(true);
63
64/* --------------------------------------------------------------------
65 * Sum Of Squared Difference Reductions.
66 */
67
68GPU_SHADER_CREATE_INFO(compositor_sum_squared_difference_float_shared)
69 .additional_info("compositor_parallel_reduction_shared")
70 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
71 .push_constant(Type::FLOAT, "subtrahend")
72 .define("TYPE", "float")
73 .define("IDENTITY", "0.0")
74 .define("LOAD(value)", "value.x")
75 .define("REDUCE(lhs, rhs)", "lhs + rhs");
76
77GPU_SHADER_CREATE_INFO(compositor_sum_red_squared_difference)
78 .additional_info("compositor_sum_squared_difference_float_shared")
79 .define("INITIALIZE(value)", "pow(value.r - subtrahend, 2.0)")
80 .do_static_compilation(true);
81
82GPU_SHADER_CREATE_INFO(compositor_sum_green_squared_difference)
83 .additional_info("compositor_sum_squared_difference_float_shared")
84 .define("INITIALIZE(value)", "pow(value.g - subtrahend, 2.0)")
85 .do_static_compilation(true);
86
87GPU_SHADER_CREATE_INFO(compositor_sum_blue_squared_difference)
88 .additional_info("compositor_sum_squared_difference_float_shared")
89 .define("INITIALIZE(value)", "pow(value.b - subtrahend, 2.0)")
90 .do_static_compilation(true);
91
92GPU_SHADER_CREATE_INFO(compositor_sum_luminance_squared_difference)
93 .additional_info("compositor_sum_squared_difference_float_shared")
94 .push_constant(Type::VEC3, "luminance_coefficients")
95 .define("INITIALIZE(value)", "pow(dot(value.rgb, luminance_coefficients) - subtrahend, 2.0)")
96 .do_static_compilation(true);
97
98/* --------------------------------------------------------------------
99 * Maximum Reductions.
100 */
101
102GPU_SHADER_CREATE_INFO(compositor_maximum_luminance)
103 .additional_info("compositor_parallel_reduction_shared")
104 .typedef_source("common_math_lib.glsl")
105 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
106 .push_constant(Type::VEC3, "luminance_coefficients")
107 .define("TYPE", "float")
108 .define("IDENTITY", "FLT_MIN")
109 .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
110 .define("LOAD(value)", "value.x")
111 .define("REDUCE(lhs, rhs)", "max(lhs, rhs)")
112 .do_static_compilation(true);
113
114GPU_SHADER_CREATE_INFO(compositor_maximum_float)
115 .additional_info("compositor_parallel_reduction_shared")
116 .typedef_source("common_math_lib.glsl")
117 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
118 .define("TYPE", "float")
119 .define("IDENTITY", "FLT_MIN")
120 .define("INITIALIZE(value)", "value.x")
121 .define("LOAD(value)", "value.x")
122 .define("REDUCE(lhs, rhs)", "max(rhs, lhs)")
123 .do_static_compilation(true);
124
125GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range)
126 .additional_info("compositor_parallel_reduction_shared")
127 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
128 .push_constant(Type::FLOAT, "lower_bound")
129 .push_constant(Type::FLOAT, "upper_bound")
130 .define("TYPE", "float")
131 .define("IDENTITY", "lower_bound")
132 .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound")
133 .define("LOAD(value)", "value.x")
134 .define("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs")
135 .do_static_compilation(true);
136
137/* --------------------------------------------------------------------
138 * Minimum Reductions.
139 */
140
141GPU_SHADER_CREATE_INFO(compositor_minimum_luminance)
142 .additional_info("compositor_parallel_reduction_shared")
143 .typedef_source("common_math_lib.glsl")
144 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
145 .push_constant(Type::VEC3, "luminance_coefficients")
146 .define("TYPE", "float")
147 .define("IDENTITY", "FLT_MAX")
148 .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
149 .define("LOAD(value)", "value.x")
150 .define("REDUCE(lhs, rhs)", "min(lhs, rhs)")
151 .do_static_compilation(true);
152
153GPU_SHADER_CREATE_INFO(compositor_minimum_float)
154 .additional_info("compositor_parallel_reduction_shared")
155 .typedef_source("common_math_lib.glsl")
156 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
157 .define("TYPE", "float")
158 .define("IDENTITY", "FLT_MAX")
159 .define("INITIALIZE(value)", "value.x")
160 .define("LOAD(value)", "value.x")
161 .define("REDUCE(lhs, rhs)", "min(rhs, lhs)")
162 .do_static_compilation(true);
163
164GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range)
165 .additional_info("compositor_parallel_reduction_shared")
166 .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
167 .push_constant(Type::FLOAT, "lower_bound")
168 .push_constant(Type::FLOAT, "upper_bound")
169 .define("TYPE", "float")
170 .define("IDENTITY", "upper_bound")
171 .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound")
172 .define("LOAD(value)", "value.x")
173 .define("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs")
174 .do_static_compilation(true);
175
176/* --------------------------------------------------------------------
177 * Velocity Reductions.
178 */
179
180GPU_SHADER_CREATE_INFO(compositor_max_velocity)
181 .local_group_size(32, 32)
182 .push_constant(Type::BOOL, "is_initial_reduction")
183 .sampler(0, ImageType::FLOAT_2D, "input_tx")
184 .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
185 .define("TYPE", "vec4")
186 .define("IDENTITY", "vec4(0.0)")
187 .define("INITIALIZE(value)", "value")
188 .define("LOAD(value)", "value")
189 .define("REDUCE(lhs, rhs)",
190 "vec4(dot(lhs.xy, lhs.xy) > dot(rhs.xy, rhs.xy) ? lhs.xy : rhs.xy,"
191 " dot(lhs.zw, lhs.zw) > dot(rhs.zw, rhs.zw) ? lhs.zw : rhs.zw)")
192 .compute_source("compositor_parallel_reduction.glsl")
193 .do_static_compilation(true);
additional_info("compositor_sum_float_shared") .push_constant(Type additional_info("compositor_sum_float_shared") .push_constant(Type GPU_RGBA32F
#define GPU_SHADER_CREATE_INFO(_info)