Cleanup: Generalise input reading in compositor
This patch generalises the pass reading shaders into input reading shaders. This is done make future development easier.
This commit is contained in:
@@ -171,7 +171,7 @@ set(GLSL_SRC
|
||||
shaders/compositor_plane_deform.glsl
|
||||
shaders/compositor_plane_deform_motion_blur.glsl
|
||||
shaders/compositor_projector_lens_distortion.glsl
|
||||
shaders/compositor_read_pass.glsl
|
||||
shaders/compositor_read_input.glsl
|
||||
shaders/compositor_realize_on_domain.glsl
|
||||
shaders/compositor_screen_lens_distortion.glsl
|
||||
shaders/compositor_smaa_blending_weight_calculation.glsl
|
||||
@@ -287,7 +287,7 @@ set(SRC_SHADER_CREATE_INFOS
|
||||
shaders/infos/compositor_plane_deform_info.hh
|
||||
shaders/infos/compositor_plane_deform_motion_blur_info.hh
|
||||
shaders/infos/compositor_projector_lens_distortion_info.hh
|
||||
shaders/infos/compositor_read_pass_info.hh
|
||||
shaders/infos/compositor_read_input_info.hh
|
||||
shaders/infos/compositor_realize_on_domain_info.hh
|
||||
shaders/infos/compositor_screen_lens_distortion_info.hh
|
||||
shaders/infos/compositor_smaa_info.hh
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
void main()
|
||||
{
|
||||
ivec2 texel = ivec2(gl_GlobalInvocationID.xy);
|
||||
vec4 pass_color = texture_load(input_tx, texel + compositing_region_lower_bound);
|
||||
imageStore(output_img, texel, READ_EXPRESSION(pass_color));
|
||||
vec4 input_color = texture_load(input_tx, texel + lower_bound);
|
||||
imageStore(output_img, texel, READ_EXPRESSION(input_color));
|
||||
}
|
||||
@@ -14,5 +14,5 @@ void main()
|
||||
#endif
|
||||
vec4 color = condition ? texture_load(first_image_tx, texel) :
|
||||
texture_load(second_image_tx, texel);
|
||||
imageStore(output_img, texel + compositing_region_lower_bound, color);
|
||||
imageStore(output_img, texel + lower_bound, color);
|
||||
}
|
||||
|
||||
@@ -18,5 +18,5 @@ void main()
|
||||
vec4 output_color = vec4(input_color.rgb, alpha);
|
||||
#endif
|
||||
|
||||
imageStore(output_img, texel + compositing_region_lower_bound, output_color);
|
||||
imageStore(output_img, texel + lower_bound, output_color);
|
||||
}
|
||||
|
||||
@@ -45,21 +45,3 @@ GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_color)
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("CONVERT_EXPRESSION(value)", "vec4_from_vec3(value.xyz)")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_extract_alpha_from_color)
|
||||
.additional_info("compositor_convert_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("CONVERT_EXPRESSION(value)", "vec4(value.a, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_convert_color_to_half_color)
|
||||
.additional_info("compositor_convert_shared")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("CONVERT_EXPRESSION(value)", "value")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_convert_float_to_half_float)
|
||||
.additional_info("compositor_convert_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("CONVERT_EXPRESSION(value)", "vec4(value.r, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_input_shared)
|
||||
.local_group_size(16, 16)
|
||||
.push_constant(Type::IVEC2, "lower_bound")
|
||||
.sampler(0, ImageType::FLOAT_2D, "input_tx")
|
||||
.compute_source("compositor_read_input.glsl");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_input_float)
|
||||
.additional_info("compositor_read_input_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(input_color)", "vec4(input_color.r, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_input_vector)
|
||||
.additional_info("compositor_read_input_shared")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(input_color)", "input_color")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_input_color)
|
||||
.additional_info("compositor_read_input_shared")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(input_color)", "input_color")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_input_alpha)
|
||||
.additional_info("compositor_read_input_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(input_color)", "vec4(input_color.a, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
@@ -1,35 +0,0 @@
|
||||
/* SPDX-FileCopyrightText: 2023 Blender Authors
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0-or-later */
|
||||
|
||||
#include "gpu_shader_create_info.hh"
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_pass_shared)
|
||||
.local_group_size(16, 16)
|
||||
.push_constant(Type::IVEC2, "compositing_region_lower_bound")
|
||||
.sampler(0, ImageType::FLOAT_2D, "input_tx")
|
||||
.compute_source("compositor_read_pass.glsl");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_pass_float)
|
||||
.additional_info("compositor_read_pass_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(pass_color)", "vec4(pass_color.r, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_pass_vector)
|
||||
.additional_info("compositor_read_pass_shared")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(pass_color)", "pass_color")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_pass_color)
|
||||
.additional_info("compositor_read_pass_shared")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(pass_color)", "pass_color")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_read_pass_alpha)
|
||||
.additional_info("compositor_read_pass_shared")
|
||||
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.define("READ_EXPRESSION(pass_color)", "vec4(pass_color.a, vec3(0.0))")
|
||||
.do_static_compilation(true);
|
||||
@@ -8,7 +8,7 @@ GPU_SHADER_CREATE_INFO(compositor_split_viewer_shared)
|
||||
.local_group_size(16, 16)
|
||||
.push_constant(Type::FLOAT, "split_ratio")
|
||||
.push_constant(Type::IVEC2, "view_size")
|
||||
.push_constant(Type::IVEC2, "compositing_region_lower_bound")
|
||||
.push_constant(Type::IVEC2, "lower_bound")
|
||||
.sampler(0, ImageType::FLOAT_2D, "first_image_tx")
|
||||
.sampler(1, ImageType::FLOAT_2D, "second_image_tx")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
GPU_SHADER_CREATE_INFO(compositor_write_output_shared)
|
||||
.local_group_size(16, 16)
|
||||
.push_constant(Type::IVEC2, "compositing_region_lower_bound")
|
||||
.push_constant(Type::IVEC2, "lower_bound")
|
||||
.sampler(0, ImageType::FLOAT_2D, "input_tx")
|
||||
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_img")
|
||||
.compute_source("compositor_write_output.glsl");
|
||||
|
||||
@@ -88,7 +88,7 @@ class CompositeOperation : public NodeOperation {
|
||||
* that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
@@ -116,7 +116,7 @@ class CompositeOperation : public NodeOperation {
|
||||
* that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
@@ -143,7 +143,7 @@ class CompositeOperation : public NodeOperation {
|
||||
* that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
|
||||
@@ -516,6 +516,9 @@ class ImageOperation : public NodeOperation {
|
||||
GPUShader *shader = shader_manager().get(get_shader_name(identifier));
|
||||
GPU_shader_bind(shader);
|
||||
|
||||
const int2 lower_bound = int2(0);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
|
||||
GPU_texture_bind(image_texture, input_unit);
|
||||
|
||||
@@ -557,13 +560,13 @@ class ImageOperation : public NodeOperation {
|
||||
const char *get_shader_name(StringRef identifier)
|
||||
{
|
||||
if (identifier == "Alpha") {
|
||||
return "compositor_extract_alpha_from_color";
|
||||
return "compositor_read_input_alpha";
|
||||
}
|
||||
else if (get_result(identifier).type() == ResultType::Color) {
|
||||
return "compositor_convert_color_to_half_color";
|
||||
return "compositor_read_input_color";
|
||||
}
|
||||
else {
|
||||
return "compositor_convert_float_to_half_float";
|
||||
return "compositor_read_input_float";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -830,10 +833,10 @@ class RenderLayerOperation : public NodeOperation {
|
||||
GPUTexture *combined_texture = context().get_input_texture(
|
||||
scene, view_layer, RE_PASSNAME_COMBINED);
|
||||
if (image_result.should_compute()) {
|
||||
execute_pass(image_result, combined_texture, "compositor_read_pass_color");
|
||||
execute_pass(image_result, combined_texture, "compositor_read_input_color");
|
||||
}
|
||||
if (alpha_result.should_compute()) {
|
||||
execute_pass(alpha_result, combined_texture, "compositor_read_pass_alpha");
|
||||
execute_pass(alpha_result, combined_texture, "compositor_read_input_alpha");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -851,13 +854,13 @@ class RenderLayerOperation : public NodeOperation {
|
||||
GPUTexture *pass_texture = context().get_input_texture(
|
||||
scene, view_layer, output->identifier);
|
||||
if (output->type == SOCK_FLOAT) {
|
||||
execute_pass(result, pass_texture, "compositor_read_pass_float");
|
||||
execute_pass(result, pass_texture, "compositor_read_input_float");
|
||||
}
|
||||
else if (output->type == SOCK_VECTOR) {
|
||||
execute_pass(result, pass_texture, "compositor_read_pass_vector");
|
||||
execute_pass(result, pass_texture, "compositor_read_input_vector");
|
||||
}
|
||||
else if (output->type == SOCK_RGBA) {
|
||||
execute_pass(result, pass_texture, "compositor_read_pass_color");
|
||||
execute_pass(result, pass_texture, "compositor_read_input_color");
|
||||
}
|
||||
else {
|
||||
BLI_assert_unreachable();
|
||||
@@ -881,7 +884,7 @@ class RenderLayerOperation : public NodeOperation {
|
||||
* compositing region into an appropriately sized texture. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const int input_unit = GPU_shader_get_sampler_binding(shader, "input_tx");
|
||||
GPU_texture_bind(pass_texture, input_unit);
|
||||
|
||||
@@ -65,7 +65,7 @@ class ViewerOperation : public NodeOperation {
|
||||
* that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
GPU_shader_uniform_1f(shader, "split_ratio", get_split_ratio());
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ class ViewerOperation : public NodeOperation {
|
||||
* write into that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
@@ -146,7 +146,7 @@ class ViewerOperation : public NodeOperation {
|
||||
* write into that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
@@ -173,7 +173,7 @@ class ViewerOperation : public NodeOperation {
|
||||
* write into that compositing region. */
|
||||
const rcti compositing_region = context().get_compositing_region();
|
||||
const int2 lower_bound = int2(compositing_region.xmin, compositing_region.ymin);
|
||||
GPU_shader_uniform_2iv(shader, "compositing_region_lower_bound", lower_bound);
|
||||
GPU_shader_uniform_2iv(shader, "lower_bound", lower_bound);
|
||||
|
||||
const Result &image = get_input("Image");
|
||||
image.bind_as_texture(shader, "input_tx");
|
||||
|
||||
Reference in New Issue
Block a user