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>
This commit is contained in:
parent
4b6064aef4
commit
406bb6ae20
@ -2929,6 +2929,18 @@ QRhiResource::Type QRhiRenderTarget::resourceType() const
|
|||||||
\fn QSize QRhiRenderTarget::pixelSize() const
|
\fn QSize QRhiRenderTarget::pixelSize() const
|
||||||
|
|
||||||
\return the size in pixels.
|
\return the size in pixels.
|
||||||
|
|
||||||
|
Valid only after create() has been called successfully. Until then the
|
||||||
|
result is a default-constructed QSize.
|
||||||
|
|
||||||
|
With QRhiTextureRenderTarget the returned size is the size of the
|
||||||
|
associated attachments at the time of create(), in practice the size of the
|
||||||
|
first color attachment, or the depth/stencil buffer if there are no color
|
||||||
|
attachments. If the associated textures or renderbuffers are resized and
|
||||||
|
rebuilt afterwards, then pixelSize() performs an implicit call to create()
|
||||||
|
in order to rebuild the underlying data structures. This implicit check is
|
||||||
|
similar to what QRhiCommandBuffer::beginPass() does, and ensures that the
|
||||||
|
returned size is always up-to-date.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -3631,6 +3631,9 @@ bool QD3D11TextureRenderTarget::create()
|
|||||||
|
|
||||||
QSize QD3D11TextureRenderTarget::pixelSize() const
|
QSize QD3D11TextureRenderTarget::pixelSize() const
|
||||||
{
|
{
|
||||||
|
if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QD3D11Texture, QD3D11RenderBuffer>(m_desc, d.currentResIdList))
|
||||||
|
const_cast<QD3D11TextureRenderTarget *>(this)->create();
|
||||||
|
|
||||||
return d.pixelSize;
|
return d.pixelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5317,6 +5317,9 @@ bool QGles2TextureRenderTarget::create()
|
|||||||
|
|
||||||
QSize QGles2TextureRenderTarget::pixelSize() const
|
QSize QGles2TextureRenderTarget::pixelSize() const
|
||||||
{
|
{
|
||||||
|
if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QGles2Texture, QGles2RenderBuffer>(m_desc, d.currentResIdList))
|
||||||
|
const_cast<QGles2TextureRenderTarget *>(this)->create();
|
||||||
|
|
||||||
return d.pixelSize;
|
return d.pixelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3183,6 +3183,9 @@ bool QMetalTextureRenderTarget::create()
|
|||||||
|
|
||||||
QSize QMetalTextureRenderTarget::pixelSize() const
|
QSize QMetalTextureRenderTarget::pixelSize() const
|
||||||
{
|
{
|
||||||
|
if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QMetalTexture, QMetalRenderBuffer>(m_desc, d->currentResIdList))
|
||||||
|
const_cast<QMetalTextureRenderTarget *>(this)->create();
|
||||||
|
|
||||||
return d->pixelSize;
|
return d->pixelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -860,6 +860,9 @@ bool QNullTextureRenderTarget::create()
|
|||||||
|
|
||||||
QSize QNullTextureRenderTarget::pixelSize() const
|
QSize QNullTextureRenderTarget::pixelSize() const
|
||||||
{
|
{
|
||||||
|
if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QNullTexture, QNullRenderBuffer>(m_desc, d.currentResIdList))
|
||||||
|
const_cast<QNullTextureRenderTarget *>(this)->create();
|
||||||
|
|
||||||
return d.pixelSize;
|
return d.pixelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6637,6 +6637,9 @@ bool QVkTextureRenderTarget::create()
|
|||||||
|
|
||||||
QSize QVkTextureRenderTarget::pixelSize() const
|
QSize QVkTextureRenderTarget::pixelSize() const
|
||||||
{
|
{
|
||||||
|
if (!QRhiRenderTargetAttachmentTracker::isUpToDate<QVkTexture, QVkRenderBuffer>(m_desc, d.currentResIdList))
|
||||||
|
const_cast<QVkTextureRenderTarget *>(this)->create();
|
||||||
|
|
||||||
return d.pixelSize;
|
return d.pixelSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3828,6 +3828,8 @@ void tst_QRhi::textureRenderTargetAutoRebuild()
|
|||||||
if (!rhi)
|
if (!rhi)
|
||||||
QSKIP("QRhi could not be created, skipping testing rendering");
|
QSKIP("QRhi could not be created, skipping testing rendering");
|
||||||
|
|
||||||
|
// case 1: beginPass's implicit create()
|
||||||
|
{
|
||||||
QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget));
|
QScopedPointer<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, QSize(512, 512), 1, QRhiTexture::RenderTarget));
|
||||||
QVERIFY(texture->create());
|
QVERIFY(texture->create());
|
||||||
QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ { texture.data() } }));
|
QScopedPointer<QRhiTextureRenderTarget> rt(rhi->newTextureRenderTarget({ { texture.data() } }));
|
||||||
@ -3845,8 +3847,6 @@ void tst_QRhi::textureRenderTargetAutoRebuild()
|
|||||||
texture->setPixelSize(QSize(256, 256));
|
texture->setPixelSize(QSize(256, 256));
|
||||||
QVERIFY(texture->create());
|
QVERIFY(texture->create());
|
||||||
QCOMPARE(texture->pixelSize(), QSize(256, 256));
|
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));
|
|
||||||
|
|
||||||
QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess);
|
QVERIFY(rhi->beginOffscreenFrame(&cb) == QRhi::FrameOpSuccess);
|
||||||
QVERIFY(cb);
|
QVERIFY(cb);
|
||||||
@ -3855,6 +3855,24 @@ void tst_QRhi::textureRenderTargetAutoRebuild()
|
|||||||
QCOMPARE(rt->pixelSize(), QSize(256, 256));
|
QCOMPARE(rt->pixelSize(), QSize(256, 256));
|
||||||
cb->endPass();
|
cb->endPass();
|
||||||
rhi->endOffscreenFrame();
|
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()
|
void tst_QRhi::srbLayoutCompatibility_data()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user