Blender V5.0
compositor_parallel_reduction_infos.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)
9PUSH_CONSTANT(bool, is_initial_reduction)
10SAMPLER(0, sampler2D, input_tx)
11COMPUTE_SOURCE("compositor_parallel_reduction.glsl")
13
14/* --------------------------------------------------------------------
15 * Sum Reductions.
16 */
17
18GPU_SHADER_CREATE_INFO(compositor_sum_shared)
19ADDITIONAL_INFO(compositor_parallel_reduction_shared)
20DEFINE_VALUE("REDUCE(lhs, rhs)", "lhs + rhs")
22
23GPU_SHADER_CREATE_INFO(compositor_sum_float_shared)
24ADDITIONAL_INFO(compositor_sum_shared)
25IMAGE(0, SFLOAT_32, write, image2D, output_img)
26DEFINE_VALUE("TYPE", "float")
27DEFINE_VALUE("IDENTITY", "0.0f")
28DEFINE_VALUE("LOAD(value)", "value.x")
30
31GPU_SHADER_CREATE_INFO(compositor_sum_red)
32ADDITIONAL_INFO(compositor_sum_float_shared)
33DEFINE_VALUE("INITIALIZE(value)", "value.r")
36
37GPU_SHADER_CREATE_INFO(compositor_sum_green)
38ADDITIONAL_INFO(compositor_sum_float_shared)
39DEFINE_VALUE("INITIALIZE(value)", "value.g")
42
43GPU_SHADER_CREATE_INFO(compositor_sum_blue)
44ADDITIONAL_INFO(compositor_sum_float_shared)
45DEFINE_VALUE("INITIALIZE(value)", "value.b")
48
49GPU_SHADER_CREATE_INFO(compositor_sum_luminance)
50ADDITIONAL_INFO(compositor_sum_float_shared)
51PUSH_CONSTANT(float3, luminance_coefficients)
52DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
55
56GPU_SHADER_CREATE_INFO(compositor_sum_log_luminance)
57ADDITIONAL_INFO(compositor_sum_float_shared)
58PUSH_CONSTANT(float3, luminance_coefficients)
59DEFINE_VALUE("INITIALIZE(value)", "log(max(dot(value.rgb, luminance_coefficients), 1e-5f))")
62
63GPU_SHADER_CREATE_INFO(compositor_sum_color)
64ADDITIONAL_INFO(compositor_sum_shared)
65IMAGE(0, SFLOAT_32_32_32_32, write, image2D, output_img)
66DEFINE_VALUE("TYPE", "vec4")
67DEFINE_VALUE("IDENTITY", "vec4(0.0f)")
68DEFINE_VALUE("INITIALIZE(value)", "value")
69DEFINE_VALUE("LOAD(value)", "value")
72
73/* --------------------------------------------------------------------
74 * Sum Of Squared Difference Reductions.
75 */
76
77GPU_SHADER_CREATE_INFO(compositor_sum_squared_difference_float_shared)
78ADDITIONAL_INFO(compositor_parallel_reduction_shared)
79IMAGE(0, SFLOAT_32, write, image2D, output_img)
80PUSH_CONSTANT(float, subtrahend)
81DEFINE_VALUE("TYPE", "float")
82DEFINE_VALUE("IDENTITY", "0.0f")
83DEFINE_VALUE("LOAD(value)", "value.x")
84DEFINE_VALUE("REDUCE(lhs, rhs)", "lhs + rhs")
86
87GPU_SHADER_CREATE_INFO(compositor_sum_red_squared_difference)
88ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared)
89DEFINE_VALUE("INITIALIZE(value)", "pow(value.r - subtrahend, 2.0f)")
92
93GPU_SHADER_CREATE_INFO(compositor_sum_green_squared_difference)
94ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared)
95DEFINE_VALUE("INITIALIZE(value)", "pow(value.g - subtrahend, 2.0f)")
98
99GPU_SHADER_CREATE_INFO(compositor_sum_blue_squared_difference)
100ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared)
101DEFINE_VALUE("INITIALIZE(value)", "pow(value.b - subtrahend, 2.0f)")
104
105GPU_SHADER_CREATE_INFO(compositor_sum_luminance_squared_difference)
106ADDITIONAL_INFO(compositor_sum_squared_difference_float_shared)
107PUSH_CONSTANT(float3, luminance_coefficients)
108DEFINE_VALUE("INITIALIZE(value)", "pow(dot(value.rgb, luminance_coefficients) - subtrahend, 2.0f)")
111
112/* --------------------------------------------------------------------
113 * Maximum Reductions.
114 */
115
116GPU_SHADER_CREATE_INFO(compositor_maximum_luminance)
117ADDITIONAL_INFO(compositor_parallel_reduction_shared)
118IMAGE(0, SFLOAT_32, write, image2D, output_img)
119PUSH_CONSTANT(float3, luminance_coefficients)
120DEFINE_VALUE("TYPE", "float")
121DEFINE_VALUE("IDENTITY", "FLT_MIN")
122DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
123DEFINE_VALUE("LOAD(value)", "value.x")
124DEFINE_VALUE("REDUCE(lhs, rhs)", "max(lhs, rhs)")
127
128GPU_SHADER_CREATE_INFO(compositor_maximum_brightness)
129ADDITIONAL_INFO(compositor_parallel_reduction_shared)
130IMAGE(0, SFLOAT_32, write, image2D, output_img)
131DEFINE_VALUE("TYPE", "float")
132DEFINE_VALUE("IDENTITY", "FLT_MIN")
133DEFINE_VALUE("INITIALIZE(value)", "reduce_max(value.rgb)")
134DEFINE_VALUE("LOAD(value)", "value.x")
135DEFINE_VALUE("REDUCE(lhs, rhs)", "max(lhs, rhs)")
138
139GPU_SHADER_CREATE_INFO(compositor_maximum_float)
140ADDITIONAL_INFO(compositor_parallel_reduction_shared)
141IMAGE(0, SFLOAT_32, write, image2D, output_img)
142DEFINE_VALUE("TYPE", "float")
143DEFINE_VALUE("IDENTITY", "FLT_MIN")
144DEFINE_VALUE("INITIALIZE(value)", "value.x")
145DEFINE_VALUE("LOAD(value)", "value.x")
146DEFINE_VALUE("REDUCE(lhs, rhs)", "max(rhs, lhs)")
149
150GPU_SHADER_CREATE_INFO(compositor_maximum_float2)
151ADDITIONAL_INFO(compositor_parallel_reduction_shared)
152IMAGE(0, SFLOAT_32_32, write, image2D, output_img)
153DEFINE_VALUE("TYPE", "vec2")
154DEFINE_VALUE("IDENTITY", "vec2(FLT_MIN)")
155DEFINE_VALUE("INITIALIZE(value)", "value.xy")
156DEFINE_VALUE("LOAD(value)", "value.xy")
157DEFINE_VALUE("REDUCE(lhs, rhs)", "max(rhs, lhs)")
158DEFINE_VALUE("WRITE(value)", "vec4(value, vec2(0.0f))")
161
162GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range)
163ADDITIONAL_INFO(compositor_parallel_reduction_shared)
164IMAGE(0, SFLOAT_32, write, image2D, output_img)
165PUSH_CONSTANT(float, lower_bound)
166PUSH_CONSTANT(float, upper_bound)
167DEFINE_VALUE("TYPE", "float")
168DEFINE_VALUE("IDENTITY", "lower_bound")
169DEFINE_VALUE("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound")
170DEFINE_VALUE("LOAD(value)", "value.x")
171DEFINE_VALUE("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs")
174
175/* --------------------------------------------------------------------
176 * Minimum Reductions.
177 */
178
179GPU_SHADER_CREATE_INFO(compositor_minimum_luminance)
180ADDITIONAL_INFO(compositor_parallel_reduction_shared)
181IMAGE(0, SFLOAT_32, write, image2D, output_img)
182PUSH_CONSTANT(float3, luminance_coefficients)
183DEFINE_VALUE("TYPE", "float")
184DEFINE_VALUE("IDENTITY", "FLT_MAX")
185DEFINE_VALUE("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
186DEFINE_VALUE("LOAD(value)", "value.x")
187DEFINE_VALUE("REDUCE(lhs, rhs)", "min(lhs, rhs)")
190
191GPU_SHADER_CREATE_INFO(compositor_minimum_float)
192ADDITIONAL_INFO(compositor_parallel_reduction_shared)
193IMAGE(0, SFLOAT_32, write, image2D, output_img)
194DEFINE_VALUE("TYPE", "float")
195DEFINE_VALUE("IDENTITY", "FLT_MAX")
196DEFINE_VALUE("INITIALIZE(value)", "value.x")
197DEFINE_VALUE("LOAD(value)", "value.x")
198DEFINE_VALUE("REDUCE(lhs, rhs)", "min(rhs, lhs)")
201
202GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range)
203ADDITIONAL_INFO(compositor_parallel_reduction_shared)
204IMAGE(0, SFLOAT_32, write, image2D, output_img)
205PUSH_CONSTANT(float, lower_bound)
206PUSH_CONSTANT(float, upper_bound)
207DEFINE_VALUE("TYPE", "float")
208DEFINE_VALUE("IDENTITY", "upper_bound")
209DEFINE_VALUE("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound")
210DEFINE_VALUE("LOAD(value)", "value.x")
211DEFINE_VALUE("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs")
214
215/* --------------------------------------------------------------------
216 * Velocity Reductions.
217 */
218
219GPU_SHADER_CREATE_INFO(compositor_max_velocity)
220LOCAL_GROUP_SIZE(32, 32)
221PUSH_CONSTANT(bool, is_initial_reduction)
222SAMPLER(0, sampler2D, input_tx)
223IMAGE(0, SFLOAT_16_16_16_16, write, image2D, output_img)
224DEFINE_VALUE("TYPE", "vec4")
225DEFINE_VALUE("IDENTITY", "vec4(0.0f)")
226DEFINE_VALUE("INITIALIZE(value)", "value")
227DEFINE_VALUE("LOAD(value)", "value")
228DEFINE_VALUE("REDUCE(lhs, rhs)",
229 "vec4(dot(lhs.xy, lhs.xy) > dot(rhs.xy, rhs.xy) ? lhs.xy : rhs.xy,"
230 " dot(lhs.zw, lhs.zw) > dot(rhs.zw, rhs.zw) ? lhs.zw : rhs.zw)")
231COMPUTE_SOURCE("compositor_parallel_reduction.glsl")
#define GPU_SHADER_CREATE_INFO(_info)
#define GPU_SHADER_CREATE_END()
#define SAMPLER(slot, type, name)
#define ADDITIONAL_INFO(info_name)
#define PUSH_CONSTANT(type, name)
#define LOCAL_GROUP_SIZE(...)
#define IMAGE(slot, format, qualifiers, type, name)
#define COMPUTE_SOURCE(filename)
#define DO_STATIC_COMPILATION()
#define DEFINE_VALUE(name, value)
ImageBase< float, 2 > image2D
SamplerBase< float, 2 > sampler2D