summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2021-03-16 16:33:27 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-19 13:05:46 +0000
commitf4110ab1e2599bff8573006e85221997ba6a1194 (patch)
tree84e9dcb0d186610747631aae4bfdabe8d69a0e8c /tests
parent67bb730beb4a120febc07e0fada398fc01e2e7b5 (diff)
rhi: Make it possible to clone a QRhiRenderPassDescriptor
Task-number: QTBUG-91888 Change-Id: Ib6d2e639e6c24f3e9a733c6563dc8a6d6da47719 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Andy Nichols <andy.nichols@qt.io> (cherry picked from commit 19384f2e8f50bad0a0775f7b2e10aff3372bcbb5) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
index ccb5f8a783..c4d1dca1bb 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -97,6 +97,8 @@ private slots:
void srbWithNoResource();
void renderPassDescriptorCompatibility_data();
void renderPassDescriptorCompatibility();
+ void renderPassDescriptorClone_data();
+ void renderPassDescriptorClone();
void renderToTextureSimple_data();
void renderToTextureSimple();
@@ -3361,7 +3363,7 @@ void tst_QRhi::renderPassDescriptorCompatibility()
QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
if (!rhi)
- QSKIP("QRhi could not be created, skipping testing texture resource updates");
+ QSKIP("QRhi could not be created, skipping testing renderpass descriptors");
// Note that checking compatibility is only relevant with backends where
// there is a concept of renderpass descriptions (Vulkan, and partially
@@ -3511,6 +3513,47 @@ void tst_QRhi::renderPassDescriptorCompatibility()
}
}
+void tst_QRhi::renderPassDescriptorClone_data()
+{
+ rhiTestData();
+}
+
+void tst_QRhi::renderPassDescriptorClone()
+{
+ QFETCH(QRhi::Implementation, impl);
+ QFETCH(QRhiInitParams *, initParams);
+
+ QScopedPointer<QRhi> rhi(QRhi::create(impl, initParams, QRhi::Flags(), nullptr));
+ if (!rhi)
+ QSKIP("QRhi could not be created, skipping testing renderpass descriptors");
+
+ // tex and tex2 have the same format
+ QScopedPointer<QRhiTexture> tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget));
+ QVERIFY(tex->create());
+ QScopedPointer<QRhiTexture> tex2(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget));
+ QVERIFY(tex2->create());
+
+ QScopedPointer<QRhiRenderBuffer> ds(rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512)));
+ QVERIFY(ds->create());
+
+ QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ tex.data() }));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc(rt->newCompatibleRenderPassDescriptor());
+ rt->setRenderPassDescriptor(rpDesc.data());
+ QVERIFY(rt->create());
+
+ QScopedPointer<QRhiRenderPassDescriptor> rpDescClone(rpDesc->newCompatibleRenderPassDescriptor());
+ QVERIFY(rpDescClone);
+ QVERIFY(rpDesc->isCompatible(rpDescClone.data()));
+
+ // rt and rt2 have the same set of attachments
+ QScopedPointer<QRhiTextureRenderTarget> rt2(rhi->newTextureRenderTarget({ tex2.data() }));
+ QScopedPointer<QRhiRenderPassDescriptor> rpDesc2(rt2->newCompatibleRenderPassDescriptor());
+ rt2->setRenderPassDescriptor(rpDesc2.data());
+ QVERIFY(rt2->create());
+
+ QVERIFY(rpDesc2->isCompatible(rpDescClone.data()));
+}
+
void tst_QRhi::pipelineCache_data()
{
rhiTestData();