aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgrhisupport.cpp
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2020-10-16 10:11:17 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2020-10-16 16:32:54 +0200
commit0aa2b58b9003fa002b7727d3b1eb274c3285e555 (patch)
tree5f695e1e4efe2ecf08810cdcf996a9f3c3617d51 /src/quick/scenegraph/qsgrhisupport.cpp
parent6b20e0e08ed48982e849dbbf9fc53113a491f5e4 (diff)
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 <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp9
1 files changed, 8 insertions, 1 deletions
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<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ texture.data() }));
+ QScopedPointer<QRhiRenderBuffer> 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<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget(rtDesc));
QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
rt->setRenderPassDescriptor(rpDesc.data());
if (!rt->create()) {