From 57ee54fb4770b618b0bbd06b069682b5cd11fc9f Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 12 Apr 2021 11:53:25 +0200 Subject: 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 --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp') 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) -- cgit v1.2.3 From c7c2512a6736ff9fff7d3ed1b90fb6d57a656bcb Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 29 Mar 2021 13:36:27 +0200 Subject: Do not batch lines with > 1 width in alpha pass Cannot possibly do reasonable overlap checks when we have no idea how such lines are rasterized, meaning we do not know the real bounds of the geometry. Fixes: QTBUG-91749 Change-Id: Ia444232330da2f1d29841589f0e65bb52822c4ae Reviewed-by: Eskil Abrahamsen Blomfeldt (cherry picked from commit 74c458f9fdf0639cd68684b5184bf561166e14cb) Reviewed-by: Qt Cherry-pick Bot --- src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp') diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 913533b389..024c0d68ef 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -1958,7 +1958,11 @@ void Renderer::prepareAlphaBatches() if (gni->clipList() == gnj->clipList() && gni->geometry()->drawingMode() == gnj->geometry()->drawingMode() - && (gni->geometry()->drawingMode() != QSGGeometry::DrawLines || gni->geometry()->lineWidth() == gnj->geometry()->lineWidth()) + && (gni->geometry()->drawingMode() != QSGGeometry::DrawLines + || (gni->geometry()->lineWidth() == gnj->geometry()->lineWidth() + // Must not do overlap checks when the line width is not 1, + // we have no knowledge how such lines are rasterized. + && gni->geometry()->lineWidth() == 1.0f)) && gni->geometry()->attributes() == gnj->geometry()->attributes() && gni->inheritedOpacity() == gnj->inheritedOpacity() && gni->activeMaterial()->type() == gnj->activeMaterial()->type() -- cgit v1.2.3