From 4715128213625df75be2cbbf5c1fd6b911b34901 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 23 Sep 2021 09:11:09 +0200 Subject: rhi: vk: Fix invalid index for unused attachments Pick-to: 6.2 Change-Id: I8140de4eeb1a8a490fcffd10370c29a49d677fed Reviewed-by: Andy Nichols --- src/gui/rhi/qrhivulkan.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index 7180545678..9757cc6997 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -6236,33 +6236,35 @@ void QVkRenderPassDescriptor::updateSerializedFormat() *p++ = resolveRefs.count(); *p++ = hasDepthStencil; - auto serializeAttachmentData = [&p](const VkAttachmentDescription &a, bool used) { - *p++ = used ? a.format : 0; - *p++ = used ? a.samples : 0; - *p++ = used ? a.loadOp : 0; - *p++ = used ? a.storeOp : 0; - *p++ = used ? a.stencilLoadOp : 0; - *p++ = used ? a.stencilStoreOp : 0; - *p++ = used ? a.initialLayout : 0; - *p++ = used ? a.finalLayout : 0; + auto serializeAttachmentData = [this, &p](uint32_t attIdx) { + const bool used = attIdx != VK_ATTACHMENT_UNUSED; + const VkAttachmentDescription *a = used ? &attDescs[attIdx] : nullptr; + *p++ = used ? a->format : 0; + *p++ = used ? a->samples : 0; + *p++ = used ? a->loadOp : 0; + *p++ = used ? a->storeOp : 0; + *p++ = used ? a->stencilLoadOp : 0; + *p++ = used ? a->stencilStoreOp : 0; + *p++ = used ? a->initialLayout : 0; + *p++ = used ? a->finalLayout : 0; }; for (int i = 0, ie = colorRefs.count(); i != ie; ++i) { const uint32_t attIdx = colorRefs[i].attachment; *p++ = attIdx; - serializeAttachmentData(attDescs[attIdx], attIdx != VK_ATTACHMENT_UNUSED); + serializeAttachmentData(attIdx); } if (hasDepthStencil) { const uint32_t attIdx = dsRef.attachment; *p++ = attIdx; - serializeAttachmentData(attDescs[attIdx], attIdx != VK_ATTACHMENT_UNUSED); + serializeAttachmentData(attIdx); } for (int i = 0, ie = resolveRefs.count(); i != ie; ++i) { const uint32_t attIdx = resolveRefs[i].attachment; *p++ = attIdx; - serializeAttachmentData(attDescs[attIdx], attIdx != VK_ATTACHMENT_UNUSED); + serializeAttachmentData(attIdx); } } -- cgit v1.2.3