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.
This commit is contained in:
baldurk
2022-05-18 12:58:03 +01:00
parent 31feedd16d
commit d2c557a1ae
+20 -1
View File
@@ -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<int, QString> &errors = ret.errors;