Revise and adapt patch caching to be stable and robust, CPU-side only
Focus on a CPU-side solution at first, which avoids the CPU-side
data generation (commandsToPath, expandFill, expandStroke) when
possible, in a manner that is robust and active immediately, i.e.
fill(p, 123) directly followed by fill(p, 123) will immediately trigger
reusing the vertex data generated in the first fill call, it does not
need to wait until the next frame.
Changing the line width, AA, render hints are now handled more
robustly, so fill(p, 123); setLineWidth(newValue); fill(p, 123); does
regenerate the vertex data as expected, without breaking the rendering
for the first fill().
There is no GPU-side caching in this version. This means that the reused
vertex data is copied onto rhiCtx->verts just like on the uncached path,
instead of using dedicated buffers. (this avoids dealing with the
problem of one-to-many mapping between path groups/paths and buffers,
due to the state changes and the deferred nature of QRhi command
submission).
It might be possible to introduce dedicated GPU-side buffers on top,
assuming a robust enough solution can be designed. It is not clear
however what the performance benefits would be over what is implemented
here - considering that real world scenes will unlikely to contain only
QCanvasPath drawing with path groups - if there is text or any
non-groupped drawing, there is then a main vertex buffer anyway, so it
is not clear how much we can gain from switching between that and
dedicated buffers. (granted, there would be fewer memcpys since the
dedicated buffers would not need to be fed with new data for static
path groups/paths) This is to be investigated as a follow up task.
Also fixes a render flags vs. render hints problem. The engine's hints
have values that do not map to the renderer's flags.
This should solve all known path group related issues in the Lancelot
tests. There is also an enhancement, where one of the tests (testCurves)
is now run also with a >= 0 path group, exercising caching more.
The documentation is touched slightly here and there, mainly to not
talk about GPU buffers explicitly.
There are also various cleanups in the logic, mainly to simplify
and sanitize how state and arguments are handled and passed around
between functions, so that it will become possible to more easily
reason about the data flow from the point of calling fill() or
stroke() on QCanvasPainter.
Pick-to: 6.11
Task-number: QTBUG-144831
Change-Id: I83d6f341986f657e5e3081a774919b03cad64392
Reviewed-by: Kaj Grönholm <kaj.gronholm@qt.io>