Welcome to mirror list, hosted at ThFree Co, Russian Federation.

compositor_parallel_reduction_info.hh « infos « compositor « shaders « gpu « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e2252b1475846896ac3e765523e307d6e69b47bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* SPDX-License-Identifier: GPL-2.0-or-later */

#include "gpu_shader_create_info.hh"

GPU_SHADER_CREATE_INFO(compositor_parallel_reduction_shared)
    .local_group_size(16, 16)
    .push_constant(Type::BOOL, "is_initial_reduction")
    .sampler(0, ImageType::FLOAT_2D, "input_tx")
    .compute_source("compositor_parallel_reduction.glsl");

/* --------------------------------------------------------------------
 * Sum Reductions.
 */

GPU_SHADER_CREATE_INFO(compositor_sum_shared)
    .additional_info("compositor_parallel_reduction_shared")
    .define("IDENTITY", "vec4(0.0)")
    .define("REDUCE(lhs, rhs)", "lhs + rhs");

GPU_SHADER_CREATE_INFO(compositor_sum_float_shared)
    .additional_info("compositor_sum_shared")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .define("TYPE", "float")
    .define("LOAD(value)", "value.x");

GPU_SHADER_CREATE_INFO(compositor_sum_red)
    .additional_info("compositor_sum_float_shared")
    .define("INITIALIZE(value)", "value.r")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_green)
    .additional_info("compositor_sum_float_shared")
    .define("INITIALIZE(value)", "value.g")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_blue)
    .additional_info("compositor_sum_float_shared")
    .define("INITIALIZE(value)", "value.b")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_luminance)
    .additional_info("compositor_sum_float_shared")
    .push_constant(Type::VEC3, "luminance_coefficients")
    .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_log_luminance)
    .additional_info("compositor_sum_float_shared")
    .push_constant(Type::VEC3, "luminance_coefficients")
    .define("INITIALIZE(value)", "log(max(dot(value.rgb, luminance_coefficients), 1e-5))")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_color)
    .additional_info("compositor_sum_shared")
    .image(0, GPU_RGBA32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .define("TYPE", "vec4")
    .define("INITIALIZE(value)", "value")
    .define("LOAD(value)", "value")
    .do_static_compilation(true);

/* --------------------------------------------------------------------
 * Sum Of Squared Difference Reductions.
 */

GPU_SHADER_CREATE_INFO(compositor_sum_squared_difference_float_shared)
    .additional_info("compositor_parallel_reduction_shared")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .push_constant(Type::FLOAT, "subtrahend")
    .define("TYPE", "float")
    .define("IDENTITY", "vec4(subtrahend)")
    .define("LOAD(value)", "value.x")
    .define("REDUCE(lhs, rhs)", "lhs + rhs");

GPU_SHADER_CREATE_INFO(compositor_sum_red_squared_difference)
    .additional_info("compositor_sum_squared_difference_float_shared")
    .define("INITIALIZE(value)", "pow(value.r - subtrahend, 2.0)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_green_squared_difference)
    .additional_info("compositor_sum_squared_difference_float_shared")
    .define("INITIALIZE(value)", "pow(value.g - subtrahend, 2.0)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_blue_squared_difference)
    .additional_info("compositor_sum_squared_difference_float_shared")
    .define("INITIALIZE(value)", "pow(value.b - subtrahend, 2.0)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_sum_luminance_squared_difference)
    .additional_info("compositor_sum_squared_difference_float_shared")
    .push_constant(Type::VEC3, "luminance_coefficients")
    .define("INITIALIZE(value)", "pow(dot(value.rgb, luminance_coefficients) - subtrahend, 2.0)")
    .do_static_compilation(true);

/* --------------------------------------------------------------------
 * Maximum Reductions.
 */

GPU_SHADER_CREATE_INFO(compositor_maximum_luminance)
    .additional_info("compositor_parallel_reduction_shared")
    .typedef_source("common_math_lib.glsl")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .push_constant(Type::VEC3, "luminance_coefficients")
    .define("TYPE", "float")
    .define("IDENTITY", "vec4(FLT_MIN)")
    .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
    .define("LOAD(value)", "value.x")
    .define("REDUCE(lhs, rhs)", "max(lhs, rhs)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_maximum_float_in_range)
    .additional_info("compositor_parallel_reduction_shared")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .push_constant(Type::FLOAT, "lower_bound")
    .push_constant(Type::FLOAT, "upper_bound")
    .define("TYPE", "float")
    .define("IDENTITY", "vec4(lower_bound)")
    .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : lower_bound")
    .define("LOAD(value)", "value.x")
    .define("REDUCE(lhs, rhs)", "((rhs > lhs) && (rhs <= upper_bound)) ? rhs : lhs")
    .do_static_compilation(true);

/* --------------------------------------------------------------------
 * Minimum Reductions.
 */

GPU_SHADER_CREATE_INFO(compositor_minimum_luminance)
    .additional_info("compositor_parallel_reduction_shared")
    .typedef_source("common_math_lib.glsl")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .push_constant(Type::VEC3, "luminance_coefficients")
    .define("TYPE", "float")
    .define("IDENTITY", "vec4(FLT_MAX)")
    .define("INITIALIZE(value)", "dot(value.rgb, luminance_coefficients)")
    .define("LOAD(value)", "value.x")
    .define("REDUCE(lhs, rhs)", "min(lhs, rhs)")
    .do_static_compilation(true);

GPU_SHADER_CREATE_INFO(compositor_minimum_float_in_range)
    .additional_info("compositor_parallel_reduction_shared")
    .image(0, GPU_R32F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
    .push_constant(Type::FLOAT, "lower_bound")
    .push_constant(Type::FLOAT, "upper_bound")
    .define("TYPE", "float")
    .define("IDENTITY", "vec4(upper_bound)")
    .define("INITIALIZE(v)", "((v.x <= upper_bound) && (v.x >= lower_bound)) ? v.x : upper_bound")
    .define("LOAD(value)", "value.x")
    .define("REDUCE(lhs, rhs)", "((rhs < lhs) && (rhs >= lower_bound)) ? rhs : lhs")
    .do_static_compilation(true);