[Bf-blender-cvs] [74e9cad0827] temp-viewport-compositor-compiler: Viewport Compositor: Do eager evaluation (Part 2)
Omar Emara
noreply at git.blender.org
Thu Apr 14 15:30:08 CEST 2022
Commit: 74e9cad08276ba01a2360846d7cf26cfa03e7ece
Author: Omar Emara
Date: Thu Apr 14 15:27:56 2022 +0200
Branches: temp-viewport-compositor-compiler
https://developer.blender.org/rB74e9cad08276ba01a2360846d7cf26cfa03e7ece
Viewport Compositor: Do eager evaluation (Part 2)
===================================================================
M source/blender/gpu/shaders/compositor/infos/compositor_convert_info.hh
M source/blender/viewport_compositor/VPC_compile_state.hh
M source/blender/viewport_compositor/VPC_conversion_processor_operation.hh
M source/blender/viewport_compositor/VPC_domain.hh
M source/blender/viewport_compositor/VPC_evaluator.hh
M source/blender/viewport_compositor/VPC_node_operation.hh
M source/blender/viewport_compositor/VPC_operation.hh
M source/blender/viewport_compositor/VPC_processor_operation.hh
M source/blender/viewport_compositor/VPC_realize_on_domain_processor_operation.hh
M source/blender/viewport_compositor/VPC_reduce_to_single_value_processor_operation.hh
M source/blender/viewport_compositor/intern/conversion_processor_operation.cc
M source/blender/viewport_compositor/intern/operation.cc
M source/blender/viewport_compositor/intern/processor_operation.cc
M source/blender/viewport_compositor/intern/realize_on_domain_processor_operation.cc
M source/blender/viewport_compositor/intern/reduce_to_single_value_processor_operation.cc
===================================================================
diff --git a/source/blender/gpu/shaders/compositor/infos/compositor_convert_info.hh b/source/blender/gpu/shaders/compositor/infos/compositor_convert_info.hh
index a0e02a3d087..f8512f414cc 100644
--- a/source/blender/gpu/shaders/compositor/infos/compositor_convert_info.hh
+++ b/source/blender/gpu/shaders/compositor/infos/compositor_convert_info.hh
@@ -9,16 +9,34 @@ GPU_SHADER_CREATE_INFO(compositor_convert_shared)
.typedef_source("gpu_shader_compositor_type_conversion.glsl")
.compute_source("compositor_convert.glsl");
+GPU_SHADER_CREATE_INFO(compositor_convert_float_to_vector)
+ .additional_info("compositor_convert_shared")
+ .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_image")
+ .define("CONVERT_EXPRESSION", "vec4(vec3_from_float(texel.x), 0.0)")
+ .do_static_compilation(true);
+
+GPU_SHADER_CREATE_INFO(compositor_convert_float_to_color)
+ .additional_info("compositor_convert_shared")
+ .image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_image")
+ .define("CONVERT_EXPRESSION", "vec4_from_float(texel.x)")
+ .do_static_compilation(true);
+
GPU_SHADER_CREATE_INFO(compositor_convert_color_to_float)
.additional_info("compositor_convert_shared")
.image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_image")
.define("CONVERT_EXPRESSION", "vec4(float_from_vec4(texel))")
.do_static_compilation(true);
-GPU_SHADER_CREATE_INFO(compositor_convert_float_to_color)
+GPU_SHADER_CREATE_INFO(compositor_convert_color_to_vector)
.additional_info("compositor_convert_shared")
.image(0, GPU_RGBA16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_image")
- .define("CONVERT_EXPRESSION", "vec4_from_float(texel.x)")
+ .define("CONVERT_EXPRESSION", "vec4(vec3_from_vec4(texel), 0.0)")
+ .do_static_compilation(true);
+
+GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_float)
+ .additional_info("compositor_convert_shared")
+ .image(0, GPU_R16F, Qualifier::WRITE, ImageType::FLOAT_2D, "output_image")
+ .define("CONVERT_EXPRESSION", "vec4(float_from_vec3(texel.xyz))")
.do_static_compilation(true);
GPU_SHADER_CREATE_INFO(compositor_convert_vector_to_color)
diff --git a/source/blender/viewport_compositor/VPC_compile_state.hh b/source/blender/viewport_compositor/VPC_compile_state.hh
index 952fdbd4bbc..02c744f5ee6 100644
--- a/source/blender/viewport_compositor/VPC_compile_state.hh
+++ b/source/blender/viewport_compositor/VPC_compile_state.hh
@@ -51,7 +51,7 @@ using namespace nodes::derived_node_tree_types;
* Second, it stores the GPU material compile group as well as its domain. One should first go over
* the discussion in VPC_evaluator.hh for a high level description of the mechanism of the compile
* group. The one important detail in this class is the should_compile_gpu_material_compile_group
- * method, which implements the criteria of whether the compile group should be compiled taking the
+ * method, which implements the criteria of whether the compile group should be compiled given the
* node currently being processed as an argument. Those criteria are described as follows. If the
* compile group is empty as is the case when processing nodes 1, 2, and 3, then it plainly
* shouldn't be compiled. If the given node is not a GPU material node, then it can't be added to
diff --git a/source/blender/viewport_compositor/VPC_conversion_processor_operation.hh b/source/blender/viewport_compositor/VPC_conversion_processor_operation.hh
index 64fb24e955b..f7832e2cfeb 100644
--- a/source/blender/viewport_compositor/VPC_conversion_processor_operation.hh
+++ b/source/blender/viewport_compositor/VPC_conversion_processor_operation.hh
@@ -6,46 +6,44 @@
#include "GPU_shader.h"
#include "VPC_context.hh"
+#include "VPC_input_descriptor.hh"
#include "VPC_processor_operation.hh"
#include "VPC_result.hh"
namespace blender::viewport_compositor {
-/* --------------------------------------------------------------------
+/* -------------------------------------------------------------------------------------------------
* Conversion Processor Operation.
- */
-
-/* A conversion processor is a processor that converts a result from a certain type to another. See
- the derived classes for more details. */
+ *
+ * A processor that converts a result from a certain type to another. See the derived classes for
+ * more details. */
class ConversionProcessorOperation : public ProcessorOperation {
- public:
- /* The name of the input sampler in the conversion shader.
- * This is constant for all operations. */
- static const char *shader_input_sampler_name;
- /* The name of the output image in the conversion shader.
- * This is constant for all operations. */
- static const char *shader_output_image_name;
-
public:
using ProcessorOperation::ProcessorOperation;
+ /* If the input result is a single value, execute_single is called. Otherwise, the shader
+ * provided by get_conversion_shader is dispatched. */
void execute() override;
+ /* Determine if a conversion processor operation is needed for the input with the given result
+ * and descriptor. If it is not needed, return a null pointer. If it is needed, return an
+ * instance of the appropriate conversion processor. */
+ static ProcessorOperation *construct_if_needed(Context &context,
+ const Result &input_result,
+ const InputDescriptor &input_descriptor);
+
protected:
/* Convert the input single value result to the output single value result. */
virtual void execute_single(const Result &input, Result &output) = 0;
- /* Get the shader the will be used for conversion. It should have an input sampler called
- * shader_input_sampler_name and an output image of an appropriate type called
- * shader_output_image_name. */
+ /* Get the shader the will be used for conversion. */
virtual GPUShader *get_conversion_shader() const = 0;
};
-/* --------------------------------------------------------------------
+/* -------------------------------------------------------------------------------------------------
* Convert Float To Vector Processor Operation.
- */
-
-/* Takes a float result and outputs a vector result. All three components of the output are filled
+ *
+ * Takes a float result and outputs a vector result. All three components of the output are filled
* with the input float. */
class ConvertFloatToVectorProcessorOperation : public ConversionProcessorOperation {
public:
@@ -56,11 +54,10 @@ class ConvertFloatToVectorProcessorOperation : public ConversionProcessorOperati
GPUShader *get_conversion_shader() const override;
};
-/* --------------------------------------------------------------------
+/* -------------------------------------------------------------------------------------------------
* Convert Float To Color Processor Operation.
- */
-
-/* Takes a float result and outputs a color result. All three color channels of the output are
+ *
+ * Takes a float result and outputs a color result. All three color channels of the output are
* filled with the input float and the alpha channel is set to 1. */
class ConvertFloatToColorProcessorOperation : public ConversionProcessorOperation {
public:
@@ -71,11 +68,10 @@ class ConvertFloatToColorProcessorOperation : public ConversionProcessorOperatio
GPUShader *get_conversion_shader() const override;
};
-/* --------------------------------------------------------------------
+/* -------------------------------------------------------------------------------------------------
* Convert Color To Float Processor Operation.
- */
-
-/* Takes a color result and outputs a float result. The output is the average of the three color
+ *
+ * Takes a color result and outputs a float result. The output is the average of the three color
* channels, the alpha channel is ignored. */
class ConvertColorToFloatProcessorOperation : public ConversionProcessorOperation {
public:
@@ -86,11 +82,24 @@ class ConvertColorToFloatProcessorOperation : public ConversionProcessorOperatio
GPUShader *get_conversion_shader() const override;
};
-/* --------------------------------------------------------------------
- * Convert Vector To Float Processor Operation.
- */
+/* -------------------------------------------------------------------------------------------------
+ * Convert Color To Vector Processor Operation.
+ *
+ * Takes a color result and outputs a vector result. The output is a copy of the three color
+ * channels to the three vector components. */
+class ConvertColorToVectorProcessorOperation : public ConversionProcessorOperation {
+ public:
+ ConvertColorToVectorProcessorOperation(Context &context);
+
+ void execute_single(const Result &input, Result &output) override;
+
+ GPUShader *get_conversion_shader() const override;
+};
-/* Takes a vector result and outputs a float result. The output is the average of the three
+/* -------------------------------------------------------------------------------------------------
+ * Convert Vector To Float Processor Operation.
+ *
+ * Takes a vector result and outputs a float result. The output is the average of the three
* components. */
class ConvertVectorToFloatProcessorOperation : public ConversionProcessorOperation {
public:
@@ -101,11 +110,10 @@ class ConvertVectorToFloatProcessorOperation : public ConversionProcessorOperati
GPUShader *get_conversion_shader() const override;
};
-/* --------------------------------------------------------------------
+/* -------------------------------------------------------------------------------------------------
* Convert Vector To Color Processor Operation.
- */
-
-/* Takes a vector result and outputs a color result. The output is a copy of the three vector
+ *
+ * Takes a vector result and outputs a color result. The output is a copy of the three vector
* components to the three color channels with the alpha channel set to 1. */
class ConvertVectorToColorProcessorOperation : public ConversionProcessorOperation {
public:
diff --git a/source/blender/viewport_compositor/V
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list