Skip to content

scene: Rework surface damage handling

Vlad Zahorodnii requested to merge work/zzag/render-layer-damage into master

It's not possible to get the surface damage before calling Scene::paint(), which is a big problem because it blocks proper surface damage and buffer damage calculation when walking render layer tree.

This change reworks the scene compositing stages to allow getting the next surface damage before calling Scene::paint().

The main challenge is that the effects can expand the surface damage. We have to call prePaintWindow() and prePaintScreen() before actually starting painting. However, prePaintWindow() is called after starting rendering.

This change makes Scene call prePaintWindow() and prePaintScreen() so it's possible to know the surface damage beforehand. Unfortunately, it's also a breaking change. Some fullscreen effects will have to adapt to the new Scene paint order. Paint hooks will be invoked in the following order:

  • prePaintScreen() once per frame
  • prePaintWindow() once per frame
  • paintScreen() can be called multiple times
  • paintWindow() can be called as many times as paintScreen()
  • postPaintWindow() once per frame
  • postPaintScreen() once per frame

After walking the render layer tree, the Compositor will poke the render backend for the back buffer repair region and combine it with the surface damage to get the buffer damage, which can be passed to the render backend (in order to optimize performance with tiled gpus) and Scene::paint(), which will determine what parts of the scene have to repainted based on the buffer damage.


Next steps:

  • Get this merged, it's a very intrusive change
  • Clean up render target abstractions and coordinate systems used with render layers

#72

Edited by Vlad Zahorodnii

Merge request reports