Page MenuHome

Compositor: Merge equal operations
ClosedPublic

Authored by Manuel Castilla (manzanilla) on Aug 29 2021, 9:57 PM.

Details

Summary

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 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.


Only convert operations are implemented for merging right now.
And in another patch DenoiseOperation and DenoisePrefilterOperation.

Example of two denoise nodes with same parents and prefiltering. Only HDR option change.

Before mergingAfter merging (HDR equal on both)After merging (HDR different on one)

Diff Detail

Repository
rB Blender

Event Timeline

Manuel Castilla (manzanilla) requested review of this revision.Aug 29 2021, 9:57 PM
Manuel Castilla (manzanilla) created this revision.

I wasn't able to apply this patch on master. (head was missing). But code seems fine for a first iteration.
I did had some questions about the usage of size_t but that should be raised to the core team. Seems hash functions are 32 bit, but the combine is platform specific.

Only a small change for code clarity.

source/blender/compositor/intern/COM_NodeOperationBuilder.cc
480

Bit of naming confusion.

bool check_for_next_merge = true 
while (check_for_next_merge) {
  ...
  bool any_merged = false;
  ...

  check_for_next_merge = any_merged;
}
This revision is now accepted and ready to land.Aug 30 2021, 12:27 PM
This revision was automatically updated to reflect the committed changes.