From 6b133b437c8bb31a7a439d849941b3ce5259cc20 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 19 May 2022 14:55:06 +0100 Subject: [PATCH] Account for specified struct padding in final root struct --- qrenderdoc/Code/BufferFormatter.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Code/BufferFormatter.cpp b/qrenderdoc/Code/BufferFormatter.cpp index 758b3e919..4cbb1fbdf 100644 --- a/qrenderdoc/Code/BufferFormatter.cpp +++ b/qrenderdoc/Code/BufferFormatter.cpp @@ -1883,10 +1883,21 @@ ParsedFormat BufferFormatter::ParseFormatString(const QString &formatString, uin // if we succeeded parsing but didn't get any root elements, use the last defined struct as the // definition if(success && root.structDef.type.members.isEmpty() && !lastStruct.isEmpty()) + { root = structelems[lastStruct]; + // only pad up to the stride, not down + if(root.paddedStride >= root.offset) + root.offset = cur->paddedStride; + } + fixed = root.structDef; - fixed.type.arrayByteStride = AlignUp(root.offset, GetAlignment(pack, fixed)); + uint32_t end = root.offset; + if(!fixed.type.members.isEmpty()) + end = qMax( + end, fixed.type.members.back().byteOffset + fixed.type.members.back().type.arrayByteStride); + + fixed.type.arrayByteStride = AlignUp(end, GetAlignment(pack, fixed)); if(!fixed.type.members.isEmpty() && fixed.type.members.back().type.elements == ~0U) {