From 4cde0e484c009415397430050cde389fb9b445b6 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 6 Sep 2021 18:06:33 +0200 Subject: rhi: Enable serializing a layout description without baking an srb Pick-to: 6.2 Change-Id: I66d28cc9d5417bcd5d192fa100c21f69fd42fd6b Reviewed-by: Andy Nichols --- src/gui/rhi/qrhi.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/gui/rhi/qrhi.cpp') diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 2da5959b56..acea9a780a 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -2996,7 +2996,7 @@ QRhiResource::Type QRhiTextureRenderTarget::resourceType() const QRhiShaderResourceBindings::QRhiShaderResourceBindings(QRhiImplementation *rhi) : QRhiResource(rhi) { - m_layoutDesc.reserve(BINDING_PREALLOC * LAYOUT_DESC_FIELD_COUNT); + m_layoutDesc.reserve(BINDING_PREALLOC * QRhiShaderResourceBinding::LAYOUT_DESC_ENTRIES_PER_BINDING); } /*! @@ -3047,13 +3047,12 @@ void QRhiImplementation::updateLayoutDesc(QRhiShaderResourceBindings *srb) { srb->m_layoutDescHash = 0; srb->m_layoutDesc.clear(); + auto layoutDescAppender = std::back_inserter(srb->m_layoutDesc); for (const QRhiShaderResourceBinding &b : qAsConst(srb->m_bindings)) { const QRhiShaderResourceBinding::Data *d = b.data(); - // the logic must match QRhiShaderResourceBinding::isLayoutCompatible() - const int count = d->type == QRhiShaderResourceBinding::SampledTexture ? d->u.stex.count : 1; - // the number of entries here should match LAYOUT_DESC_FIELD_COUNT - srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type) ^ uint(count); - srb->m_layoutDesc << uint(d->binding) << uint(d->stage) << uint(d->type) << uint(count); + srb->m_layoutDescHash ^= uint(d->binding) ^ uint(d->stage) ^ uint(d->type) + ^ uint(d->type == QRhiShaderResourceBinding::SampledTexture ? d->u.stex.count : 1); + d->serialize(layoutDescAppender); } } -- cgit v1.2.3