diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-04-12 11:53:25 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-04-12 16:04:03 +0200 |
commit | 57ee54fb4770b618b0bbd06b069682b5cd11fc9f (patch) | |
tree | f6e16ee3caeedc6a0c6260f1e295cd45eadefb99 | |
parent | 4a5b989755cc7e92a3d9045c37d272ee114c702a (diff) |
Fix incorrect depth test state with QSGRenderNode::DepthAwareRendering
Not applicable to Qt 6. But in Qt 5 GL_DEPTH_TEST must be re-enabled
after the QSGRenderNode has done with its work, and the rendernode
specified DepthAwareRendering. For rendernodes without this flag
everything is fine, but when the flag is set, the usage of the
depth buffer, and so depth testing in the alpha pass, stays enabled,
which means leaving GL_DEPTH_TEST as disabled will lead to incorrect
rendering with semi-transparent nodes that come after the rendernode.
Fixes: QTBUG-92036
Change-Id: Ide9e862e3504ded31eba5ee2a4caf804b69812e3
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
-rw-r--r-- | src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index c34327bb41..913533b389 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -4444,6 +4444,9 @@ void Renderer::renderRenderNode(Batch *batch) // legacy (GL-only) opacity = opacity->parent(); } + // having DepthAwareRendering leaves depth test on in the alpha pass + const bool depthTestWasEnabled = m_useDepthBuffer; + glDisable(GL_STENCIL_TEST); glDisable(GL_SCISSOR_TEST); glDisable(GL_DEPTH_TEST); @@ -4478,7 +4481,9 @@ void Renderer::renderRenderNode(Batch *batch) // legacy (GL-only) m_currentClipType = ClipState::NoClip; } - if (changes & QSGRenderNode::DepthState) + if (depthTestWasEnabled) + glEnable(GL_DEPTH_TEST); + else if (changes & QSGRenderNode::DepthState) glDisable(GL_DEPTH_TEST); if (changes & QSGRenderNode::ColorState) |