Scene3DItem: fix screen flickering when using OnDemand


When using OnDemand, we detect whether Qt3D actually needs to render or
not. Based on that we set a flag on the Scene3DRenderer to tell it whether
it should render or not.

The subtlety lies in the fact that depending on that flag value, we will
still call Qt3D render but not at the same moment. We need to call render
to unlock the Qt3D render loop for next frame.
Therefore when we should skip a frame, we call render in
Scene3DRender::beforeSynchronize (updatePaintNode) and return early
while in the other case beforeSynchronize doesn't call render and it gets
called later in beforeRenderPassRecording. We know that the render call
in the skip frame case won't render anything.

To work correctly, we must obviously set the skip frame flag before
beforeSynchronize / beforeRenderPassRecording is called which
wasn't the case. This therefore resulted in random screen flashing as we
would end up having beforeSynchronize rely on the skip frame value for the
previous frame. This means we would end up issuing a render call in
beforeSynchronize using assuming it wouldn't render anything when it actually
did (no FBO would be bound and Qt3D would render straight to the window
...)

Also update the number of frames to render before skipping to 3 to match
Qt 5.15 and ensure we have something visible for the first time
Scene3D is launched.

Pick-to: 6.4 6.5
Change-Id: Icc34b62a0af2ff44232b39c694a4702488a890a2
Reviewed-by: Mike Krus <mike.krus@kdab.com>
commite2aac33d04804c3c8f4f554c206a8cb9dd14611e
parent6b6465032f103a084e416cbddf03f8e83191aea2
authorPaul Lemire <paul.lemire@kdab.com>
committerPaul Lemire <paul.lemire@kdab.com>
commit timeMon, 19 Dec 2022 11:01:51 +0100