summaryrefslogtreecommitdiffstats
path: root/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp
diff options
context:
space:
mode:
authorPaul Lemire <paul.lemire@kdab.com>2019-07-05 09:06:35 +0200
committerPaul Lemire <paul.lemire@kdab.com>2019-08-07 12:08:32 +0200
commit6631bf0983250e1a86cb9d27628c44b6e607609b (patch)
tree5ea8ee81d2119df25b0f2a87532f7d7d2dcf03a8 /src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp
parentda2c94c13c163922467e6d88e19442fc12aea523 (diff)
Make Scene3D rendering use the Manual Qt3D drive mode
This now makes Scene3D rendering fully synchronous and blocking: - All Qt3D jobs have to be executed before we can render the GL commands This makes the blocking mode that could be activated with SCENE3D_BLOCKING_RENDERMODE the default behavior now and therefore we could remove references to it in the code. This now means that Qt3D and QtQuick will be rendering at the same refresh rate, which in most cases won't be noticeable and will ensure that content from Qt3D scenes matches content from QtQuick scenes. The only downside is if the Qt3D rendering takes longer than the time expected by QtQuick, the whole QtQuick rendering will be slowed down. Previously the QtQuick rendering might have still run at 60fps while the Qt3D rendering at a lower fps. Now the QtQuick fps would be the same as the Qt3D fps. That being said, the old behavior also meant that if Qt3D didn't catch up, the delay between QtQuick and Qt3D would only increase frame after frame. This change allow to simplify the internals by making Scene3D and regular Qt3D use the same code paths internally. Please note that Scene3D relies on QQuickWindow::afterAnimating being called each frame. When using a QQuickRenderControl this means you might have to call it manually as part of your rendering code. Task-number: QTBUG-72385 Change-Id: I887daf6df632e296a892b844e738a67e973fee7f Reviewed-by: Mike Krus <mike.krus@kdab.com>
Diffstat (limited to 'src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp')
-rw-r--r--src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp b/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp
index 3fab345e1..d25c6a7f7 100644
--- a/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp
+++ b/src/quick3d/imports/scene3d/scene3dsgmaterialshader.cpp
@@ -154,21 +154,23 @@ void Scene3DSGMaterialShader::updateState(const RenderState &state, QSGMaterial
QSGTexture *t = tx->texture();
- bool npotSupported = const_cast<QOpenGLContext *>(state.context())
- ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
- if (!npotSupported) {
- QSize size = t->textureSize();
- const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
- if (isNpot) {
- t->setHorizontalWrapMode(QSGTexture::ClampToEdge);
- t->setVerticalWrapMode(QSGTexture::ClampToEdge);
+ if (t != nullptr) {
+ bool npotSupported = const_cast<QOpenGLContext *>(state.context())
+ ->functions()->hasOpenGLFeature(QOpenGLFunctions::NPOTTextureRepeat);
+ if (!npotSupported) {
+ QSize size = t->textureSize();
+ const bool isNpot = !isPowerOfTwo(size.width()) || !isPowerOfTwo(size.height());
+ if (isNpot) {
+ t->setHorizontalWrapMode(QSGTexture::ClampToEdge);
+ t->setVerticalWrapMode(QSGTexture::ClampToEdge);
+ }
}
- }
- if (oldTx == 0 || oldTx->texture()->textureId() != t->textureId())
- t->bind();
- else
- t->updateBindOptions();
+ if (oldTx == 0 || oldTx->texture()->textureId() != t->textureId())
+ t->bind();
+ else
+ t->updateBindOptions();
+ }
if (state.isMatrixDirty())
program()->setUniformValue(m_matrixId, state.combinedMatrix());