Details
-
Task
-
Resolution: Out of scope
-
P3: Somewhat important
-
None
-
None
Description
The vetecies we pass through the vertex shader to OpenGL need to be transformed by the QPainter's current transform. There are three ways options on how this can be done:
1) CPU-side transforms
3) Attribute value PMV matrix in vertex shader
2) Uniform PMV matrix in vertex shader
The problem is that the QPainter transform changes very often, especially for QML where each item in the scene graph will incur a transform change. So we can't just optimize for pure vertex throughput, but also have to be careful that changing the matrix doesn't cause an expensive GL state change.
The option we choose is therefore a balance between vertex throughput and GL state change expense. Clearly, the option which has the lowest GL state change is to transform all the vertecies on the CPU, before we submit them to GL. The vertex shader doesn't need to transform them so changing the transformation matrix doesn't involve GL and is therefore free. Sadly however, doing the transformation on the CPU is the slowest in terms of throughput. On the other side, using a Uniform matrix provides the fastest throughput, however it is also very expensive to change a uniform value. The compromise between state changes and throughput is to use attribute values. They are cheaper to modify than uniforms but incur some cost to setup in the vertex shader.
It would be nice for the paint engine to be free to switch between the different options depending upon the number of vertecies it is about to render. For things like drawPixmap, where there's only 4 vertecies, CPU transformation is probably the best way to go. For something like drawStaticText which could be rendering 1000s of vertecies, it's probably better to take the state change hit and use a uniform.
Attachments
Issue Links
- is required for
-
QTBUG-9522 OpenGL2 paint engine crashes with invalid shader combination in examples/styles demo
- Closed