Page MenuHome

DrawManager: Cycles+GPencil
ClosedPublic

Authored by Jeroen Bakker (jbakker) on May 28 2019, 9:24 AM.

Details

Summary

Fix for GPencil and Cycles Render draw type. GPencil objects were only
shown when overlays were turned on. The cause of this is an
optimization we did some to not populate any draw engine when an
external renderer was used without overlays turned off.

This will check if there is any visible GPencil object in the scene. if
so it will still perform the loop.

In the future we might want to think about having DEG statistics to
remove the additional loop. For now we reduced this second loop under
several checks so it will only be done in exceptional cases.

Diff Detail

Repository
rB Blender

Event Timeline

Jeroen Bakker (jbakker) planned changes to this revision.May 28 2019, 12:12 PM

We would like the depsgraph to be able to detect the type of objects that are visible. Will need to check with @Sergey Sharybin (sergey) how to solve this in the current design.

@jbacker, but dependency graph would like to stay away from such ill-formed queries:

  • Visibility might be driven, so if anything, such query can only run after the entire graph evaluation.
  • Visibility depends on your interaction intent: object might be visible for the viewport drawing, but might be invisible for the selection buffer drawing pass.
  • Visibility depends on whether you are interested in objects coming from duplication system.
  • Visibility depends on duplicator settings.

While things above are technically known by dependency graph, there are various things which dependency graph does not (and should not) be worried about:

  • Visibility depends on viewport settings.
  • Visibility depends on render engine.

I can not think of a clear API which will be generic enough to be justified to be done as a core part of dependency graph, which will also be giving reliable results without slowing down evaluation for every other case.

Can only think of some utility function in dependency graph query API which will facilitate your goal but will still require having you doing some preliminary check:

  • You check for obvious early outputs, like viewport and render engine settings
  • Dependency graph cans store a map of ID types which are in the graph (simple array, indexed by an an ID type). This is super easy to control.
  • Introduce some function in query API which will return whether ID of a given type is reachable via DEG_OBJECT_ITER_BEGIN with a given flags.
  • This function can do early output check if the ID is not in the graph at all.
  • Otherwise, it's doomed to do the DEG_OBJECT_ITER_BEGIN() with the given flag and do pretty much what you're doing here.

@Jeroen Bakker (jbakker) I have tested and your solution works, but I'm not sure if this is the way to fix or not... The decission is for @Clément Foucault (fclem) and @Brecht Van Lommel (brecht)

Jeroen Bakker (jbakker) retitled this revision from DrawManager: Cycles+GPencil to DrawManager: Cycles+GPencil (WIP).May 28 2019, 4:26 PM
Jeroen Bakker (jbakker) retitled this revision from DrawManager: Cycles+GPencil (WIP) to DrawManager: Cycles+GPencil.

Depsgraph query

Brecht Van Lommel (brecht) requested changes to this revision.May 28 2019, 6:36 PM

I think it would be enough if there was an efficient query to check, does a grease pencil datablock exist in the dependency graph? This is for an

source/blender/draw/intern/draw_manager.c
1569–1578

I don't think we need to do this loop, just always set do_populate_loop = true if there is some grease pencil object in the depsgraph seems enough to avoid the common cases. Looping can be expensive in big scenes so would not want to slow down those cases.

This revision now requires changes to proceed.May 28 2019, 6:36 PM

Removed GPObjects loop when doing interactive rendering.
Added early exist for scene rendering.
Use DEG_OBJECT_ITER_FOR_RENDER_ENGINE_BEGIN

Jeroen Bakker (jbakker) marked an inline comment as done.May 29 2019, 9:08 AM
Jeroen Bakker (jbakker) added inline comments.
source/blender/draw/intern/draw_manager.c
1425

!exclude_gpencil_rendering

This revision is now accepted and ready to land.May 29 2019, 1:35 PM
This revision was automatically updated to reflect the committed changes.