I'm using the new Qt 3D API to display a 3D scene during a computationally intense calculation. This scene only changes as a response to user input. However, the default behavior of Qt 3D seems to lock the scene's frame rate to some high constant value, which consumes an unacceptable amount of resources in this case.
Is there a way to control the frame rate in Qt 3D? Ideally, I'd like to only render a new frame when changes are made to the scene, but lowering it to a smaller fixed value would also suffice. The Qt 3D documentation is sparse, and I've been unable to find a way to do either of these things.
Edit: I managed to find and apply QRenderSettings::OnDemand to my root node and frame graph, but it seemingly has no effect, although this implies that it should, as I'm using Qt 5.7. Any additional input on this would be very welcome (even if it only warrants a comment).
Edit 2: After installing Fraps and measuring the frame rate directly, it appears that the scene is, in fact, rendering frames only as needed with QRenderSettings::OnDemand applied. Without this, the frame rate remains at a steady 60fps, which happens to be my screen's refresh rate. However, the program continues to consume a large amount of CPU time while idling with Qt 3D enabled, regardless of if the 3D window is even being shown. I'm beginning to think this is a separate Qt 3D issue unrelated to frame rate, and will likely open a new question accordingly.
The most recent discussion about this might be a message from 2018 in a mailing list from qt-project.org:
Qt3D relies on your GPU vsync settings. To reach the maximum number of FPS, just disable vsync in your driver settings. If on the other hand you want to reduce FPS, call
setSwapInterval
on theQSurfaceFormat::defaultFormat
and set it before starting your Qt3D application withQSurfaceFormat::setDefaultFormat
.
The same user appears to have replied a similar question on KDAB's website years earlier.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With