From 19384f2e8f50bad0a0775f7b2e10aff3372bcbb5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 16 Mar 2021 16:33:27 +0100 Subject: rhi: Make it possible to clone a QRhiRenderPassDescriptor Pick-to: 6.1 Task-number: QTBUG-91888 Change-Id: Ib6d2e639e6c24f3e9a733c6563dc8a6d6da47719 Reviewed-by: Qt CI Bot Reviewed-by: Andy Nichols --- tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 45 +++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) (limited to 'tests/auto/gui/rhi') 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 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 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 tex(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget)); + QVERIFY(tex->create()); + QScopedPointer tex2(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget)); + QVERIFY(tex2->create()); + + QScopedPointer ds(rhi->newRenderBuffer(QRhiRenderBuffer::DepthStencil, QSize(512, 512))); + QVERIFY(ds->create()); + + QScopedPointer rt(rhi->newTextureRenderTarget({ tex.data() })); + QScopedPointer rpDesc(rt->newCompatibleRenderPassDescriptor()); + rt->setRenderPassDescriptor(rpDesc.data()); + QVERIFY(rt->create()); + + QScopedPointer rpDescClone(rpDesc->newCompatibleRenderPassDescriptor()); + QVERIFY(rpDescClone); + QVERIFY(rpDesc->isCompatible(rpDescClone.data())); + + // rt and rt2 have the same set of attachments + QScopedPointer rt2(rhi->newTextureRenderTarget({ tex2.data() })); + QScopedPointer rpDesc2(rt2->newCompatibleRenderPassDescriptor()); + rt2->setRenderPassDescriptor(rpDesc2.data()); + QVERIFY(rt2->create()); + + QVERIFY(rpDesc2->isCompatible(rpDescClone.data())); +} + void tst_QRhi::pipelineCache_data() { rhiTestData(); -- cgit v1.2.3