diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2021-09-19 10:50:17 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-09-20 11:43:54 +0000 |
commit | 1d739875054746a95d4dcf45320d48322b0dd071 (patch) | |
tree | 6856707a7cfb2ace8d287e4890d10cec94e774e7 | |
parent | 66b5885378625efd9159173c7ed55605c7601ff3 (diff) |
rhi: Remove Q_RELOCATABLE_TYPE for types with QVLA in them
QVLA itself is non-relocatable due to self references. (ptr pointing
to array[Prealloc] as long as capacity < Prealloc)
Seems we shot ourselves in the foot in multiple places with this.
Fixes: QTBUG-96619
Change-Id: I57a2ce539b671326cd352dbe57a1f3d4c46a6456
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit 481bc82d5931d5c715c2e889da6f249aa88057de)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | src/gui/rhi/qrhi_p.h | 8 | ||||
-rw-r--r-- | src/gui/rhi/qrhi_p_p.h | 3 | ||||
-rw-r--r-- | tests/auto/gui/rhi/qrhi/tst_qrhi.cpp | 46 |
3 files changed, 47 insertions, 10 deletions
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 527d72e486..c438e4c5b8 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -284,8 +284,6 @@ private: friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiVertexInputLayout &); }; -Q_DECLARE_TYPEINFO(QRhiVertexInputLayout, Q_RELOCATABLE_TYPE); - Q_GUI_EXPORT bool operator==(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept; Q_GUI_EXPORT bool operator!=(const QRhiVertexInputLayout &a, const QRhiVertexInputLayout &b) noexcept; Q_GUI_EXPORT size_t qHash(const QRhiVertexInputLayout &v, size_t seed = 0) noexcept; @@ -526,8 +524,6 @@ private: QRhiTexture *m_depthTexture = nullptr; }; -Q_DECLARE_TYPEINFO(QRhiTextureRenderTargetDescription, Q_RELOCATABLE_TYPE); - class Q_GUI_EXPORT QRhiTextureSubresourceUploadDescription { public: @@ -609,8 +605,6 @@ private: QVarLengthArray<QRhiTextureUploadEntry, 16> m_entries; }; -Q_DECLARE_TYPEINFO(QRhiTextureUploadDescription, Q_RELOCATABLE_TYPE); - class Q_GUI_EXPORT QRhiTextureCopyDescription { public: @@ -1467,7 +1461,7 @@ struct Q_GUI_EXPORT QRhiReadbackResult QRhiTexture::Format format; QSize pixelSize; QByteArray data; -}; // non-movable due to the std::function +}; struct Q_GUI_EXPORT QRhiBufferReadbackResult { diff --git a/src/gui/rhi/qrhi_p_p.h b/src/gui/rhi/qrhi_p_p.h index 89dd7b8e44..0dcb8c1f6e 100644 --- a/src/gui/rhi/qrhi_p_p.h +++ b/src/gui/rhi/qrhi_p_p.h @@ -519,9 +519,6 @@ public: static QRhiResourceUpdateBatchPrivate *get(QRhiResourceUpdateBatch *b) { return b->d; } }; -Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::BufferOp, Q_RELOCATABLE_TYPE); -Q_DECLARE_TYPEINFO(QRhiResourceUpdateBatchPrivate::TextureOp, Q_RELOCATABLE_TYPE); - template<typename T> struct QRhiBatchedBindings { diff --git a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp index 8398dac3eb..b5ec8b2756 100644 --- a/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp +++ b/tests/auto/gui/rhi/qrhi/tst_qrhi.cpp @@ -33,6 +33,7 @@ #include <QPainter> #include <QtGui/private/qrhi_p.h> +#include <QtGui/private/qrhi_p_p.h> #include <QtGui/private/qrhinull_p.h> #if QT_CONFIG(opengl) @@ -93,6 +94,8 @@ private slots: void resourceUpdateBatchRGBATextureMip(); void resourceUpdateBatchTextureRawDataStride_data(); void resourceUpdateBatchTextureRawDataStride(); + void resourceUpdateBatchLotsOfResources_data(); + void resourceUpdateBatchLotsOfResources(); void invalidPipeline_data(); void invalidPipeline(); void srbLayoutCompatibility_data(); @@ -1369,6 +1372,49 @@ void tst_QRhi::resourceUpdateBatchTextureRawDataStride() } } +void tst_QRhi::resourceUpdateBatchLotsOfResources_data() +{ + rhiTestData(); +} + +void tst_QRhi::resourceUpdateBatchLotsOfResources() +{ + 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 resource updates"); + + QImage image(128, 128, QImage::Format_RGBA8888_Premultiplied); + image.fill(Qt::red); + static const float bufferData[64] = {}; + + QRhiResourceUpdateBatch *b = rhi->nextResourceUpdateBatch(); + std::vector<std::unique_ptr<QRhiTexture>> textures; + std::vector<std::unique_ptr<QRhiBuffer>> buffers; + + // QTBUG-96619 + static const int TEXTURE_COUNT = 3 * QRhiResourceUpdateBatchPrivate::TEXTURE_OPS_STATIC_ALLOC; + static const int BUFFER_COUNT = 3 * QRhiResourceUpdateBatchPrivate::BUFFER_OPS_STATIC_ALLOC; + + for (int i = 0; i < TEXTURE_COUNT; ++i) { + std::unique_ptr<QRhiTexture> texture(rhi->newTexture(QRhiTexture::RGBA8, image.size())); + QVERIFY(texture->create()); + b->uploadTexture(texture.get(), image); + textures.push_back(std::move(texture)); + } + + for (int i = 0; i < BUFFER_COUNT; ++i) { + std::unique_ptr<QRhiBuffer> buffer(rhi->newBuffer(QRhiBuffer::Immutable, QRhiBuffer::VertexBuffer, 256)); + QVERIFY(buffer->create()); + b->uploadStaticBuffer(buffer.get(), bufferData); + buffers.push_back(std::move(buffer)); + } + + submitResourceUpdates(rhi.data(), b); +} + static QShader loadShader(const char *name) { QFile f(QString::fromUtf8(name)); |