From d2c557a1ae3a97759478c2d2439ab469869b9df3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 18 May 2022 12:58:03 +0100 Subject: [PATCH] Pick better packing defaults for APIs where we know what is expected * For vulkan any packing can be legal so we don't pick a default, but at least for D3D and GL the type of buffer implies a packing. --- qrenderdoc/Code/BufferFormatter.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/qrenderdoc/Code/BufferFormatter.cpp b/qrenderdoc/Code/BufferFormatter.cpp index 03fe0885c..21014f03b 100644 --- a/qrenderdoc/Code/BufferFormatter.cpp +++ b/qrenderdoc/Code/BufferFormatter.cpp @@ -538,10 +538,29 @@ ParsedFormat BufferFormatter::ParseFormatString(const QString &formatString, uin }; // default to scalar (tight packing) if nothing else is specified at all. The expectation is - // anything that needs a better default will insert that into the format string for the user + // anything that needs a better default will insert that into the format string for the user, + // or be picked up below Packing::Rules &pack = ret.packing; pack = Packing::Scalar; + // for D3D and GL we default to the only valid packing for cbuffers and UAVs. The user can still + // override this if they really wish with a #pack, but this makes sense as a sensible default + if(cbuffer) + { + if(IsD3D(m_API)) + pack = Packing::D3DCB; + else if(m_API == GraphicsAPI::OpenGL) + pack = Packing::std140; + } + else + { + if(IsD3D(m_API)) + pack = Packing::D3DUAV; + else if(m_API == GraphicsAPI::OpenGL) + pack = Packing::std430; + } + // vulkan allows scalar packing in any buffer, so don't wrest control away from the user + int line = 0; QMap &errors = ret.errors;