QUItCoding / qnanopainter

Library for implementing OpenGL accelerated Qt (Quick) C++ UI components.
http://quitcoding.com
Other
388 stars 76 forks source link

Performance questions #6

Open jcelerier opened 8 years ago

jcelerier commented 8 years ago

In the small qnanopainter vs qpainter benchmark, I have roughly 60 fps for QPainter and 40 - 45 fps for QNanoPainter.

What could be the cause of inferior performance ?

QUItCoding commented 8 years ago

Please tell more, on what HW are you running? Built with QtCreator ’Release’ target and not ’Debug’ target? Running QPainter with default QImage rendertarget ( = CPU paint engine) or FBO rendertarget ( = OpenGL paint engine)?

QPainter+QImage could be faster on powerful PC CPU with poor integrated GPU. QPainter+FBO can also be faster with some paint methods. But in most cases based on our testing QNanoPainter is faster and provides nice antialiased output.

One example: Macbook Pro, 2.8 Core i7, AMD R9 M370X. Demo with all tests on, rendering count 8, window size ~1/2 screen:

jcelerier commented 8 years ago

My computer : i7-4770 CPU @ 3.40GHz Radeon HD 8570 / R7 240/340 OEM Arch Linux x64

My results are as follows for a half screen too (1080 * 960) (and yes, in release mode) :

QNanoPainter : always around 45 fps for test rendering count 1 -> 8 QPainter + FBO : always at 60 fps QPainter : for test rendering count 1 -> 8 values are : 62 62 60 48 48 37 28 23

QUItCoding commented 8 years ago

Thanks! Interesting that QNanoPainter stays at ~45 fps even when rendering count increases… Don’t know what could be hampering the performance when QPainter+FBO reaches 60 fps. Maybe there is something in NanoVG OpenGL / shaders that AMD HD 8570 (Linux driver) doesn’t handle well? If you can figure out or others have comparable results please share here.

NielsMayer commented 8 years ago

Im seeing similar performance issues on desktop, whereas on Android (NVidia Shield TV) I get a solid 60FPS with QNanoPainter and under 10 with QPainter. On Nexus6, 38-45fps with QNanopainter. 3fps with QPainter.

On Ubuntu Desktop, with the app displayed full-size on second 1280x1024 monitor, QNanoPainter gets 44-45fps (all other settings default), QPainter gets ~ 43-55fps. With FBO renderTarget set, QPainter indicates an unchanging 62fps.

Common with the previous reports, I'm using AMD "radeon" Linux open-source drivers on the desktop ( Ubuntu 14.04LTS + 4.3.0-040300 kernel). I don't think the proprietary drivers are available for my 'Skylake' i7 processor, as the CPU requires the newer kernel I'm running. Thus, I can only comment on the open source driver performance on a low-end AMD Radeon HD 7770 "Tahiti" card (worksforme).

My maxwell-GPU laptop is locked to 48hz (due to high resolution) and exhibits even stranger performance characteristics, with QNanoPainter vs QPainter. With the app sized to half the display-width, 1920x2043, QPainter mode gives 19-20fps w/o, and 47fps (max) with FBO. However the actual animation, with QPainter even at the claimed 47fps, is a fraction of the visually observed animation rate seen in QNanoPainter mode at the same maximum "47fps."

Bottom line is that the FPS indicator in qnanopainter is a bad summary of the actual perceived rate of animation observed, when using a GTX960m and proprietary drivers. The observed rate is at least twice, if not four times greater than seen on either NVidia Shield, Nexus 6, AMD Desktop -- even if the indicated frame-rate shows higher. QNanoPainter on GTX960m shows the "number corkscrew" really flying along at an incredible rate, smoothly. It is impressive looking!

The rate of animation is not nearly as fast, even at 60fps indicated, on platforms like the NVidia Shield TV, Linux desktop with AMD Radeon open-source drivers, or Nexus 6.

Is there a way to show the "rate of animation" rather than the FPS, and is there a way to lock the rate of animation to a clock so that different displays exhibit same application performance, with lower performance platforms just showing a jerkier, lower-fps display?

Corollary: I'm not sure if the significantly faster observed animation rate on GTX960m/proprietary is a bug or a feature. However the vastly different observed animation rates versus similar FPS results appears to be a bug. Alternately, the oddball locked-to-48hz rate on my laptop display may be triggering an entirely different bug that cranks up the animation rate unexpectedly??

PS: QNanoPainter is awesome. Thanks for making it available.

jcelerier commented 8 years ago

Im seeing similar performance issues on desktop, whereas on Android (NVidia Shield TV) I get a solid 60FPS with QNanoPainter and under 10 with QPainter.

Maybe it would be worth to investigate GLES vs desktop OpenGL ?

NielsMayer commented 8 years ago

On NVIDIA shield: https://www.youtube.com/watch?v=5MVX-c6zwJI

QUItCoding commented 8 years ago

Thanks Niels!

Good point about Fps indicator, it only shows fps the indicator can animate at. This simple approach has served us quite well in other places but it’s very possible that depending on platform QNanoPainter item animates at different pace and fps indicator gives wrong results.

One thing you could try is to enable QNANO_DEBUG in libqnanopainter/include.pri and rebuild. That will show some debug information at the bottom of item, like draw call count and how many triangles are used for filling, stroking and text. TIME shows how much CPU time (in ms) QNanoPainter uses for synchronize() and paint(). It doesn’t tell that much as GPU is mostly the limiting factor, but I’d like to get this debug improved as an easy way to get an overview what’s going on any QNanoPainter item.

qnanopainter_debug

QUItCoding commented 8 years ago

Did a bit testing regarding this now. At least on my Linux PC with Mesa, Qt scene graph uses ”basic” render loop by default. This caused showing those < 60 fps numbers even with low load. To use threaded render loop instead, set 'QSG_RENDER_LOOP=threaded' in the environment. See http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html

Now with the above threaded render loop I did some testing on Linux. Demo with all tests on, default window size, adjusting rendering count.

Ubuntu 14.04, i5-2500K@3.3GHz, integrated HD3000 GPU, Qt 5.5.1:

:point_right: QNanoPainter ~4 times faster than QPainter with comparable antialiased output (QImage) and ~2 times faster than non-antialiased QPainter+FBO.

Ubuntu 12.04, i7-2640M@2.8GHz, NVIDIA Quadro 2000M with proprietary drivers, Qt 5.5.1:

:point_right: This Nvidia card supports GL_EXT_framebuffer_multisample and GL_EXT_framebuffer_blit so both QPainter+QImage and QPainter+FBO can render high-quality antialiased output, comparable to QNanoPainter. :point_right: QNanoPainter ~10 times faster than QPainter+QImage and ~5 times faster than QPainter+FBO.

jcelerier commented 8 years ago

awesome !

NielsMayer commented 8 years ago

On Linux Desktop, Using envvar "QSG_INFO=1" and "QSG_RENDER_LOOP=threaded" suggested in http://doc.qt.io/qt-5/qtquick-visualcanvas-scenegraph.html -- note output when switching to QNanoPainter mode in qnanopainter_vs_qpainter_demo:

qt.scenegraph.info: animation driver switched to vsync mode (and fixed at 59fps)

In QPainter mode, the following is output:

qt.scenegraph.info: animation driver switched to timer mode (and 34-40fps)

In QPainter mode, Switching the Advanced->FBO Render Target (QPainter) outputs:

qt.scenegraph.info: animation driver switched to vsync mode (and fixed at 59fps).

Without QSG_RENDER_LOOP=threaded the demo outputs:

qt.scenegraph.info: QSG: basic render loop

QNanoPainter: 44-49fps QPainter: 36-44fps QPainter with FBO Render Target option: 62fps

See output from QSG_INFO with different render loops: qnanopainter-threaded-render-loop.txt qnanopainter-basic-render-loop.txt