summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2022-01-24 15:28:20 +0100
committerLaszlo Agocs <laszlo.agocs@qt.io>2022-01-25 01:04:07 +0100
commit406bb6ae20471cf9bba6d910256b416792c99322 (patch)
tree39c7e88a17f715ec1d2dafb090f77ee2caae4d4f /tests
parent4b6064aef434baf7e382b3994f046a2f96fa7111 (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. Pick-to: 6.3 Change-Id: Ia73704c1af6a82b2689ce7b844d3b0eb9a17ec18 Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/rhi/qrhi/tst_qrhi.cpp66
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 e71e7a9a2f..db2ee58aae 100644
--- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
+++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp
@@ -3828,33 +3828,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()