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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Castilla <manzanillawork@gmail.com>2021-09-04 17:59:02 +0300
committerManuel Castilla <manzanillawork@gmail.com>2021-09-04 18:09:59 +0300
commitb225a7c4705104245c2267101adec2f2ee2fe20a (patch)
treea147d04b821a23e143dd63abc42b1eb514592aed /source/blender/compositor/operations
parentd84c79a218e63d0d752d918e2c1cbcc2f90fd35e (diff)
Compositor: Merge equal operations
Some operations can take a lot of time to execute and any duplication should be avoided. This patch implements a compile step that detects operations with the same type, inputs and parameters that produce the same result and merge them. Now operations can generate a hash that represents their output result. They only need to implement `hash_output_params` and hash any parameter that affects the output result. Reviewed By: jbakker Differential Revision: https://developer.blender.org/D12341
Diffstat (limited to 'source/blender/compositor/operations')
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.cc16
-rw-r--r--source/blender/compositor/operations/COM_ConvertOperation.h3
2 files changed, 19 insertions, 0 deletions
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.cc b/source/blender/compositor/operations/COM_ConvertOperation.cc
index d377903efea..9a3733dda5b 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.cc
+++ b/source/blender/compositor/operations/COM_ConvertOperation.cc
@@ -40,6 +40,10 @@ void ConvertBaseOperation::deinitExecution()
this->m_inputOperation = nullptr;
}
+void ConvertBaseOperation::hash_output_params()
+{
+}
+
void ConvertBaseOperation::update_memory_buffer_partial(MemoryBuffer *output,
const rcti &area,
Span<MemoryBuffer *> inputs)
@@ -269,6 +273,12 @@ void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
output[3] = inputColor[3];
}
+void ConvertRGBToYCCOperation::hash_output_params()
+{
+ ConvertBaseOperation::hash_output_params();
+ hash_param(m_mode);
+}
+
void ConvertRGBToYCCOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
{
for (; !it.is_end(); ++it) {
@@ -327,6 +337,12 @@ void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
output[3] = inputColor[3];
}
+void ConvertYCCToRGBOperation::hash_output_params()
+{
+ ConvertBaseOperation::hash_output_params();
+ hash_param(m_mode);
+}
+
void ConvertYCCToRGBOperation::update_memory_buffer_partial(BuffersIterator<float> &it)
{
for (; !it.is_end(); ++it) {
diff --git a/source/blender/compositor/operations/COM_ConvertOperation.h b/source/blender/compositor/operations/COM_ConvertOperation.h
index 0334959ae7e..72864b3c5e2 100644
--- a/source/blender/compositor/operations/COM_ConvertOperation.h
+++ b/source/blender/compositor/operations/COM_ConvertOperation.h
@@ -37,6 +37,7 @@ class ConvertBaseOperation : public MultiThreadedOperation {
Span<MemoryBuffer *> inputs) final;
protected:
+ virtual void hash_output_params() override;
virtual void update_memory_buffer_partial(BuffersIterator<float> &it) = 0;
};
@@ -124,6 +125,7 @@ class ConvertRGBToYCCOperation : public ConvertBaseOperation {
void setMode(int mode);
protected:
+ void hash_output_params() override;
void update_memory_buffer_partial(BuffersIterator<float> &it) override;
};
@@ -141,6 +143,7 @@ class ConvertYCCToRGBOperation : public ConvertBaseOperation {
void setMode(int mode);
protected:
+ void hash_output_params() override;
void update_memory_buffer_partial(BuffersIterator<float> &it) override;
};