diff options
Diffstat (limited to 'src/gui/rhi/qrhi_p.h')
-rw-r--r-- | src/gui/rhi/qrhi_p.h | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/gui/rhi/qrhi_p.h b/src/gui/rhi/qrhi_p.h index 8c3e0fdfb2..81b00cd07f 100644 --- a/src/gui/rhi/qrhi_p.h +++ b/src/gui/rhi/qrhi_p.h @@ -411,11 +411,34 @@ public: StorageImageData simage; StorageBufferData sbuf; } u; + + template<typename Output> + void serialize(Output dst) const + { + // must write out exactly LAYOUT_DESC_ENTRIES_PER_BINDING elements here + *dst++ = quint32(binding); + *dst++ = quint32(stage); + *dst++ = quint32(type); + *dst++ = quint32(type == QRhiShaderResourceBinding::SampledTexture ? u.stex.count : 1); + } }; Data *data() { return &d; } const Data *data() const { return &d; } + static const int LAYOUT_DESC_ENTRIES_PER_BINDING = 4; + + template<typename Output> + static void serializeLayoutDescription(const QRhiShaderResourceBinding *first, + const QRhiShaderResourceBinding *last, + Output dst) + { + while (first != last) { + first->data()->serialize(dst); + ++first; + } + } + private: Data d; }; @@ -1037,7 +1060,7 @@ public: bool isLayoutCompatible(const QRhiShaderResourceBindings *other) const; - QVector<uint> serializedLayoutDescription() const { return m_layoutDesc; } + QVector<quint32> serializedLayoutDescription() const { return m_layoutDesc; } virtual bool create() = 0; @@ -1050,14 +1073,13 @@ public: protected: static const int BINDING_PREALLOC = 12; - static const int LAYOUT_DESC_FIELD_COUNT = 4; QRhiShaderResourceBindings(QRhiImplementation *rhi); QVarLengthArray<QRhiShaderResourceBinding, BINDING_PREALLOC> m_bindings; - uint m_layoutDescHash = 0; + size_t m_layoutDescHash = 0; // Intentionally not using QVLA for m_layoutDesc: clients like Qt Quick are much // better served with an implicitly shared container here, because they will likely // throw this directly into structs serving as cache keys. - QVector<uint> m_layoutDesc; + QVector<quint32> m_layoutDesc; friend class QRhiImplementation; #ifndef QT_NO_DEBUG_STREAM friend Q_GUI_EXPORT QDebug operator<<(QDebug, const QRhiShaderResourceBindings &); |