From 8a58ba6843d6a701cb41c1a69ec67266dfbf1755 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 7 Dec 2020 17:42:18 +0000 Subject: [PATCH] Allow arrays of pointers in GPU buffers --- qrenderdoc/Code/BufferFormatter.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/qrenderdoc/Code/BufferFormatter.cpp b/qrenderdoc/Code/BufferFormatter.cpp index 95dcdddac..b55e3f52e 100644 --- a/qrenderdoc/Code/BufferFormatter.cpp +++ b/qrenderdoc/Code/BufferFormatter.cpp @@ -161,6 +161,17 @@ ShaderConstant BufferFormatter::ParseFormatString(const QString &formatString, u QString varName = structMatch.captured(3); + QString arrayDim = structMatch.captured(4).trimmed(); + uint32_t arrayCount = 1; + if(!arrayDim.isEmpty()) + { + arrayDim = arrayDim.mid(1, arrayDim.count() - 2); + bool ok = false; + arrayCount = arrayDim.toUInt(&ok); + if(!ok) + arrayCount = 1; + } + if(isPointer) { // if not tight packing, align up to pointer size @@ -173,23 +184,13 @@ ShaderConstant BufferFormatter::ParseFormatString(const QString &formatString, u el.type.descriptor.type = VarType::ULong; el.type.descriptor.displayAsHex = true; el.type.descriptor.arrayByteStride = 8; + el.type.descriptor.elements = arrayCount; cur->offset += 8; cur->structDef.type.members.push_back(el); } else { - QString arrayDim = structMatch.captured(4).trimmed(); - uint32_t arrayCount = 1; - if(!arrayDim.isEmpty()) - { - arrayDim = arrayDim.mid(1, arrayDim.count() - 2); - bool ok = false; - arrayCount = arrayDim.toUInt(&ok); - if(!ok) - arrayCount = 1; - } - // cbuffer packing rules, structs are always float4 base aligned if(!tightPacking) cur->offset = (cur->offset + 0xFU) & (~0xFU);