Page MenuHome

Draw Manager: Optimize populate loop.
Needs ReviewPublic

Authored by Jeroen Bakker (jbakker) on Aug 27 2021, 10:38 AM.

Details

Summary

The draw manager iters over each object in the deps graph and
forward this to the enabled draw engines. There were exceptions
made for specific configurations. After a design discussion
we decided that the draw module is responsible for this optimization
but we see in the near future additional optimizations like only loop
over active objects or selected objects in a specific mode.

This patch concerns moving the logic in a separate file and change the bool to an enum value.
Additional checks added:

  • Don't loop when drawing an image editor displaying a render result/composite viewer.
  • Don't loop when drawing an image editor in masks mode
  • Don't loop when overlays are turned off.

Performance isn't tiny, but would help with huge scenes as unneeded loops are avoided.

Diff Detail

Repository
rB Blender
Branch
temp-draw-manager-object-loop-optimization (branched from master)
Build Status
Buildable 16652
Build 16652: arc lint + arc unit

Event Timeline

  • Added settings for color management and populate loop.
  • Small changes in comments and remove unused code.
Jeroen Bakker (jbakker) retitled this revision from Draw Manager: Loop Optimization to Draw Manager: Add callback for color management and populate loop..Aug 27 2021, 3:01 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) requested review of this revision.Aug 27 2021, 3:07 PM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/engines/external/external_engine.c
299 ↗(On Diff #41163)

Currently checking for v3d. In the near future this needs to be extended as external engines can update space_image directly. See D12039: Cycles X: Use GPUDisplay for non-interactive render

source/blender/draw/intern/draw_manager.c
1318

Should get a better name. It isn't an init function, but combines the settings of all enabled render engines.

2841

Remove in master it is an unused function.

Jeroen Bakker (jbakker) planned changes to this revision.Aug 31 2021, 11:17 AM

After a discussion with @Clément Foucault (fclem) we checked several designs.

  • move responsibility to render engine. Issue with image editor
  • move responsibility to caller. iter loop will be overruled, cm decision should be centralized.
  • keep responsibility in draw manager, but cleaner.

Eventually we decided:

  • Draw Manager isn't a bad location to check for the cm setting / populate loop optimizations. Other locations would need to add duality in the responsibility.
  • Current code can be cleaned up and moved to its own compile unit draw_color_management.cc, draw_populate_loop.cc

Small cleanups will be done in master.
The populate loop changes would be done as part of this patch.

New approach where the logic is owned by the draw manager. The reasoning behind it is that it is an optimization that concerns to many data (scene, render engine, space data).

Jeroen Bakker (jbakker) retitled this revision from Draw Manager: Add callback for color management and populate loop. to Draw Manager: Optimize populate loop..Aug 31 2021, 4:49 PM
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)
Jeroen Bakker (jbakker) edited the summary of this revision. (Show Details)

Changes year in copyright header.

source/blender/draw/intern/draw_manager_populate.c
16 ↗(On Diff #41280)

Incorrect year..

Updated to latest master.