[Interest] Antialiasing possible on QSGGeometry?
Gunnar.Sletta at digia.com
Mon Jun 10 09:53:59 CEST 2013
On Jun 8, 2013, at 10:41 AM, Sean Harmer <sean.harmer at kdab.com> wrote:
> On 07/06/2013 07:12, Sletta Gunnar wrote:
>> You need to set the surface format of your QQuickView.
>> QQuickView view;
>> QSurfaceFormat format = view.format();
>> If your graphics hardware supports multisample antialiasing, you will now have antialiased geometry.
>> As the scene graph might require depth/stencil buffer for its renderer, it is a bit important that you inherit the original surface format from the view instead of creating a new one from scratch.
>> qmlscene supports this out of the box by passing --multisample as a command line option.
> Another, but more complex, option is to do like the Rectangle does and
> to implement antialiasing via the vertex shader used in the material for
> that item type. That provides edge antialiasing. If you need
> antialiasing of the contents of the item then using MSAA as Gunnar
> suggested is easiest but be aware that it comes at a cost. 16xMSAA
> should be fine on modern desktop cards but will likely be prohibitively
> expensive on embedded at the moment.
Using multisampling on embedded is not guaranteed to be a problem. In fact on several hardware types it can be a great benefit.
Many embedded graphics chips, being tile-based renderers, can do per-tile multisampling with a much lower impact than desktop chips. ARM Mali-400 considers 4x multisampling negligible for instance (http://infocenter.arm.com/help/topic/com.arm.doc.dui0555a/DUI0555A_mali_optimization_guide.pdf) and on several other chips I've played around with, MSAA comes at a 10-15% added performance cost.
However, there is an upside to using MSAA, which is that most primitives are now opaque and the scenegraph can sort them front-to-back, which means we can get z-culling it can make use of "early-z" checks such as the PowerVR chips implement (http://www.imgtec.com/powervr/insider/docs/POWERVR%20Series5%20Graphics.SGX%20architecture%20guide%20for%20developers.1.0.8.External.pdf)
Edge antialiasing typically implies that the primitive is blended which, on embedded, usually comes at a much higher cost than on desktop.
> Lower the MSAA factor to say 4x
> will give you some AA for lower cost. Play around with it and see what
> works for you.
This is always the best recommendation when it comes to performance. Try different things and see what works the best :)
>> On Jun 7, 2013, at 12:12 AM, Mark <markg85 at gmail.com> wrote:
>>> Another day, another question :)
>>> Don't worry, i plan on making a big blog about everything. This
>>> information won't get lost.
>>> So today i'm trying to draw a custom shape by setting vertices. More
>>> specifically a GL_QUAD_STRIP.
>>> It looks like this (obviously just testing data)
>>> QSGGeometry *geometry = new
>>> QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 8);
>>> geometry->vertexDataAsPoint2D().set(0, 100);
>>> geometry->vertexDataAsPoint2D().set(0, height());
>>> geometry->vertexDataAsPoint2D().set(width() / 4, 80);
>>> geometry->vertexDataAsPoint2D().set(width() / 4, height());
>>> geometry->vertexDataAsPoint2D().set(width() / 2, 110);
>>> geometry->vertexDataAsPoint2D().set(width() / 2, height());
>>> geometry->vertexDataAsPoint2D().set(width(), 150);
>>> geometry->vertexDataAsPoint2D().set(width(), height());
>>> QSGFlatColorMaterial *material = new QSGFlatColorMaterial;
>>> material->setColor(QColor(255, 0, 0, 128));
>>> QSGGeometryNode *n = new QSGGeometryNode;
>>> So roughly the same as the example  only with a quad strip.
>>> However, this ends up looking a bit aliased.. So the question is: How
>>> do i get this anti-aliased?
>>> I did read something about multisampling and setting the number of
>>> samples, but i can't find such a function in any of the used classes..
>>> Kind regards,
>>>  http://qt-project.org/doc/qt-5.0/qtquick/qsggeometrynode.html
>>> Interest mailing list
>>> Interest at qt-project.org
>> Interest mailing list
>> Interest at qt-project.org
> Dr Sean Harmer | sean.harmer at kdab.com | Senior Software Engineer
> Klarälvdalens Datakonsult AB, a KDAB Group company
> Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
> KDAB - Qt Experts - Platform-independent software solutions
> Interest mailing list
> Interest at qt-project.org
More information about the Interest