diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-05 18:10:30 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2020-06-09 21:13:21 +0200 |
commit | 22d8db1e115b120ce2f62896eb7fea452348941e (patch) | |
tree | beb189edc62ce1a5bee433827415f0dd95fe7272 /src/quick/items/qquickwindow.cpp | |
parent | 84b53c165e9d492a547c04499450007d2c293bc8 (diff) |
Add perspective 3D plane render mode
One can now do rc->createRenderer(QSGRenderContext::RenderMode3D) in Quick3D.
By default nothing changes, both QQuickWindow and QSGRhiLayer default to
either RenderMode2D or RenderMode2DNoDepthBuffer, depending on
QSG_NO_DEPTH_BUFFER. (the environment variable handling is moved out of
qsgbatchrenderer.cpp however, leaving it up to whoever is creating the
renderer to passing the appropriate flag)
The RenderMode3D mode is a modified version of the QSG_NO_DEPTH_BUFFER case:
only alpha batches are used, which are then rendered back to front. The
difference is that this is done with depth test on (no write), so the
2D content gets depth tested against whatever is already in the depth buffer.
Then, there's an additional depth "post pass" to fill the depth buffer with the
2D content. This must be separate from the color-write enabled stage because
otherwise unavoidable Z fighting would occur. By filling the depth buffer,
other 3D or 2D content, that is rendered afterwards, can depth test correctly
against the 2D elements rendered here.
customRenderMode and related functions are renamed to visualization
(because that's what it is about), in order to prevent confusing name
clashes.
Change-Id: I0d43b273e0a8020af05a652a236c0ad5fb150685
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquickwindow.cpp')
-rw-r--r-- | src/quick/items/qquickwindow.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index 7fe5325f5b..02fc8a959b 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -582,7 +582,10 @@ void QQuickWindowPrivate::syncSceneGraph() QSGRootNode *rootNode = new QSGRootNode; rootNode->appendChildNode(QQuickItemPrivate::get(contentItem)->itemNode()); - renderer = context->createRenderer(); + static const bool useDepth = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER"); + static const QSGRenderContext::RenderMode renderMode = useDepth ? QSGRenderContext::RenderMode2D + : QSGRenderContext::RenderMode2DNoDepthBuffer; + renderer = context->createRenderer(renderMode); renderer->setRootNode(rootNode); } @@ -597,7 +600,7 @@ void QQuickWindowPrivate::syncSceneGraph() mode |= QSGAbstractRenderer::ClearColorBuffer; renderer->setClearMode(mode); - renderer->setCustomRenderMode(customRenderMode); + renderer->setVisualizationMode(visualizationMode); emit q->afterSynchronizing(); runAndClearJobs(&afterSynchronizingJobs); @@ -712,7 +715,7 @@ void QQuickWindowPrivate::renderSceneGraph(const QSize &size, const QSize &surfa else context->endNextFrame(renderer); - if (renderer && renderer->hasCustomRenderModeWithContinuousUpdate()) { + if (renderer && renderer->hasVisualizationModeWithContinuousUpdate()) { // For the overdraw visualizer. This update is not urgent so avoid a // direct update() call, this is only here to keep the overdraw // visualization box rotating even when the scene is static. @@ -783,7 +786,7 @@ void QQuickWindowPrivate::init(QQuickWindow *c, QQuickRenderControl *control) contentItemPrivate->flags |= QQuickItem::ItemIsFocusScope; contentItem->setSize(q->size()); - customRenderMode = qgetenv("QSG_VISUALIZE"); + visualizationMode = qgetenv("QSG_VISUALIZE"); renderControl = control; if (renderControl) QQuickRenderControlPrivate::get(renderControl)->window = q; |