Drawing 70k objects in QGraphicsView - lag lag lag
-
wrote on 10 May 2020, 23:03 last edited by
Hey
I'm trying to draw quite..." few" lines/reacts inside QGraphicsView I've configured
QOpenGLWidget *mGlWidget = new QOpenGLWidget();//QGLFormat(QGL::SampleBuffers)); QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGL); format.setVersion(4, 5); format.setSamples(8); mGlWidget->setFormat(format); setViewport(mGlWidget);
And went on with painting but as far as I can tell its very "slow task". Is there anything else I can do or I have to go full standalone opengl solution? I have disabled paiting (void paint(){return;}) and it was pretty slow then too so mhmhm.... ? Perhaps I can't have a lot of items in QGraphicsView?
TIA
-
wrote on 11 May 2020, 00:48 last edited by
It's probably less to do with whether it is a full openGL app, and more to do with the methods you're using to generate your scene. 70k objects? OK...nothing about rendering hardware or whether you are optimizing your scene generation?
-
wrote on 11 May 2020, 08:43 last edited by
@Kent-Dorfman Hey, hardware wise 2990wx/2080super. As to generation, its just a loop for int x=0;x<100000;++x{}, I'm not even drawing the items. Just added to scene one time and then panning around in scene.
Its my attempt at uv editor :- ) So object count can go well over 1 mil + and so on.
-
@Kent-Dorfman Hey, hardware wise 2990wx/2080super. As to generation, its just a loop for int x=0;x<100000;++x{}, I'm not even drawing the items. Just added to scene one time and then panning around in scene.
Its my attempt at uv editor :- ) So object count can go well over 1 mil + and so on.
wrote on 11 May 2020, 13:13 last edited by Asperamanca 5 Nov 2020, 13:14@Dariusz
GraphicsView is single threaded and not hardware accelerated. That said, it's relatively efficient code, so adding 70k items might take a bit of time, but it should be doable.I don't see any code what kind of items you are trying to add. The problem might lie there.
The code you posted has little to do with GraphicsView per se, so the question is a bit unclear to me.
-
wrote on 11 May 2020, 15:50 last edited by
@Asperamanca Hey, The code I added is being executed in graphicsView, it configures it to use openGL for drawing instead of CPU.
The problem is not how long it takes to add items, but how well it performs once I added them. I'm using a base QGraphicsItem as my class and then extended that. In my extension I have disabled drawing so there is 0 drawing happening. Only items added to scene and qt run its own tests on them. As far as I can tell the drawing is not the issue, but just processing 70k items.
I'm looking in to building openGL app for this as it does not look like QGraphicsView is optimized for it.
Regards
Dariusz -
@Asperamanca Hey, The code I added is being executed in graphicsView, it configures it to use openGL for drawing instead of CPU.
The problem is not how long it takes to add items, but how well it performs once I added them. I'm using a base QGraphicsItem as my class and then extended that. In my extension I have disabled drawing so there is 0 drawing happening. Only items added to scene and qt run its own tests on them. As far as I can tell the drawing is not the issue, but just processing 70k items.
I'm looking in to building openGL app for this as it does not look like QGraphicsView is optimized for it.
Regards
Dariuszwrote on 12 May 2020, 06:14 last edited by@Dariusz
If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3 -
@Dariusz
If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3wrote on 12 May 2020, 09:02 last edited by@Asperamanca said in Drawing 70k objects in QGraphicsView - lag lag lag:
@Dariusz
If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3Well I'm just trying to understand where the bottleneck is... I did drawing, I had 1 fps. So I disabled all paint functions to see if that help, that did help, but I'm still having issues... so I take graphicsView is not for very large scenes then ?
-
@Asperamanca said in Drawing 70k objects in QGraphicsView - lag lag lag:
@Dariusz
If you don't use any GraphicsView features, you probably should not use GraphicsView at all. Consider an alternative like Qt3d or QtQuick3Well I'm just trying to understand where the bottleneck is... I did drawing, I had 1 fps. So I disabled all paint functions to see if that help, that did help, but I'm still having issues... so I take graphicsView is not for very large scenes then ?
@Dariusz
Hi
I if take the 40000 sample
https://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
and double the items so it creates 80.000, its still not lagging. -
@Dariusz
Hi
I if take the 40000 sample
https://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
and double the items so it creates 80.000, its still not lagging. -
wrote on 14 May 2020, 16:34 last edited by fcarney
Why would QGraphicsView go out of its way to slow down the OpenGL implementation? Are you using modern OpengGL techniques or the old interface which is slow and outdated? Are you using shaders? If no, then it probably isn't modern OpenGL. Without showing your code you are not helping yourself sort this out.
https://learnopengl.com/Offline-book
This book helped me. It is based on post 3.3 opengl if I remember right.Edit: Also, yes, it is possible Qt is not what you need, but I don't think Qt is inherently slow at OpenGL.
-
wrote on 14 May 2020, 19:56 last edited by
@Dariusz your expression "mhmhmhmm" made me think of this all day:
https://youtu.be/Vppbdf-qtGU?list=RDEMMMZUoWkd7ELYUXXPeLGHyg&t=40 -
@mrjj Hey hmmm, I just tried that example, paning/moving seems to somewhat work, but selecting/moving and bigger action begin to lag mhmhmhmm. Darn I was really hopping to do it in qt.
@Dariusz
Ok so you could get the 40K sample to lag also ?
3/12