From 0aa2b58b9003fa002b7727d3b1eb274c3285e555 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Fri, 16 Oct 2020 10:11:17 +0200 Subject: Have a depth buffer when doing the heavy offscreen readback The opaque pass will rely on it (by default at least). Not having a depth buffer will almost certainly lead to rendering errors, albeit silently since technically it's not an error not to have one. Just make sure there is one. The assumption is that the Z order problem mentioned in the comments in the referenced bug is caused by this. Task-number: QTBUG-87399 Change-Id: Ifbf5564848f17e7ce3498190d663c1ec693e86c9 Reviewed-by: Andy Nichols --- src/quick/scenegraph/qsgrhisupport.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index 6a66906ca1..8a7274f947 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -741,7 +741,14 @@ QImage QSGRhiSupport::grabOffscreen(QQuickWindow *window) qWarning("Failed to build texture for offscreen readback"); return QImage(); } - QScopedPointer rt(rhi->newTextureRenderTarget({ texture.data() })); + QScopedPointer depthStencil(rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, pixelSize, 1)); + if (!depthStencil->create()) { + qWarning("Failed to create depth/stencil buffer for offscreen readback"); + return QImage(); + } + QRhiTextureRenderTargetDescription rtDesc(texture.data()); + rtDesc.setDepthStencilBuffer(depthStencil.data()); + QScopedPointer rt(rhi->newTextureRenderTarget(rtDesc)); QScopedPointer rpDesc(rt->newCompatibleRenderPassDescriptor()); rt->setRenderPassDescriptor(rpDesc.data()); if (!rt->create()) { -- cgit v1.2.3