diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2022-01-24 15:28:20 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-01-25 00:55:19 +0000 |
commit | 5bbd5e1bfe8a81dc07daa6cbef16264507d91e73 (patch) | |
tree | 4c994425927627995871500022d1195ccf9f1ac0 /tests | |
parent | 40adeb60f4cf0e59eb337c0fd34cbee8bcc629c9 (diff) |
rhi: Make sure pixelSize() to a texture rt is always up to date
This is an issue for QQuickWindow in practice, although it is not hit
by our current tests.
Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
(cherry picked from commit 406bb6ae20471cf9bba6d910256b416792c99322)
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.cpp | 66 |
1 files changed, 42 insertions, 24 deletions
diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp index 89c02322dd..51767cd23a 100644 --- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -3783,33 +3783,51 @@ void tst_QRhi::textureRenderTargetAutoRebuild() if (!rhi) QSKIP("QRhi could not be created, skipping testing rendering"); - QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget)); - QVERIFY(texture->create()); - QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ { texture.data() } })); - QScopedPointer<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor()); - rt->setRenderPassDescriptor(rp.data()); - QVERIFY(rt->create()); + // case 1: beginPass's implicit create() + { + QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget)); + QVERIFY(texture->create()); + QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ { texture.data() } })); + QScopedPointer<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor()); + rt->setRenderPassDescriptor(rp.data()); + QVERIFY(rt->create()); - QRhiCommandBuffer *cb = nullptr; - QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess); - QVERIFY(cb); - cb->beginPass(rt.data(), Qt::red, { 1.0f, 0 }); - cb->endPass(); - rhi->endOffscreenFrame(); + QRhiCommandBuffer *cb = nullptr; + QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess); + QVERIFY(cb); + cb->beginPass(rt.data(), Qt::red, { 1.0f, 0 }); + cb->endPass(); + rhi->endOffscreenFrame(); - texture->setPixelSize(QSize(256, 256)); - QVERIFY(texture->create()); - QCOMPARE(texture->pixelSize(), QSize(256, 256)); - // rt still has the old size and knows nothing about texture's underlying native texture resource possibly changing - QCOMPARE(rt->pixelSize(), QSize(512, 512)); + texture->setPixelSize(QSize(256, 256)); + QVERIFY(texture->create()); + QCOMPARE(texture->pixelSize(), QSize(256, 256)); - QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess); - QVERIFY(cb); - // no rt->create() but beginPass() does it implicitly for us - cb->beginPass(rt.data(), Qt::red, { 1.0f, 0 }); - QCOMPARE(rt->pixelSize(), QSize(256, 256)); - cb->endPass(); - rhi->endOffscreenFrame(); + QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess); + QVERIFY(cb); + // no rt->create() but beginPass() does it implicitly for us + cb->beginPass(rt.data(), Qt::red, { 1.0f, 0 }); + QCOMPARE(rt->pixelSize(), QSize(256, 256)); + cb->endPass(); + rhi->endOffscreenFrame(); + } + + // case 2: pixelSize's implicit create() + { + QSize sz(512, 512); + QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, sz, 1, QRhiTexture::RenderTarget)); + QVERIFY(texture->create()); + QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ { texture.data() } })); + QScopedPointer<QRhiRenderPassDescriptor> rp(rt->newCompatibleRenderPassDescriptor()); + rt->setRenderPassDescriptor(rp.data()); + QVERIFY(rt->create()); + QCOMPARE(rt->pixelSize(), sz); + + sz = QSize(256, 256); + texture->setPixelSize(sz); + QVERIFY(texture->create()); + QCOMPARE(rt->pixelSize(), sz); + } } void tst_QRhi::srbLayoutCompatibility_data() |