diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-03-16 16:33:27 +0100 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-03-19 10:46:23 +0000 |
commit | 19384f2e8f50bad0a0775f7b2e10aff3372bcbb5 (patch) | |
tree | dbf1589023f98726177a7a92dcc20a46778589ff /tests/auto/gui/rhi | |
parent | 969337bcfd6af6d91b988e4b412703274a0b5877 (diff) |
rhi: Make it possible to clone a QRhiRenderPassDescriptor
Pick-to: 6.1
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>
Diffstat (limited to 'tests/auto/gui/rhi')
-rw-r--r-- | tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 45 |
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(); |