Details
-
Bug
-
Resolution: Done
-
P0: Blocker
-
5.2.0 Beta1
-
None
-
ccc0e75fb6838fe58b4b22abc87cbe684fb4623e
Description
In a customer project with some complex Qt Quick scenes we have just noticed that sometimes alpha-blended primitives are not rendered in the correct order - strictly from front to back for any given pixel.
See the output from a trimmed down test case with QSG_RENDERER_DEBUG=build set. Unfortunately I can't provide the source to the complete test case as it is customer code, but the output shows all that is needed.
In the test case the element annotated as (ICON) is sometimes covered by the icon's background (BACKGROUND) element even though in the QML scene the icon is always layered above the background in z.
The two test cases show a working version of the example and a broken version of the example. The only difference between the two is the addition of an Image {} element in a non-intersecting region of the scene.
There is an issue in the logic in the Renderer::prepareAlphaBatches() function. At present this function does not ensure that batches do not overlap in z for any given xy position. This, in turn, makes the sorting of the alpha batches (which is based upon the batch's minimum z order) unavoidably incorrect.
The prepareAlphaBatches() function needs to be modified to ensure that for any given x,y position the elements that cover that position will be rendered strictly from back to front.