mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-21 21:26:12 +00:00
When opening buffer textures, auto-generate a reasonable buffer format.
This commit is contained in:
@@ -442,6 +442,84 @@ QList<FormatElement> FormatElement::ParseFormatString(const QString &formatStrin
|
||||
return elems;
|
||||
}
|
||||
|
||||
QString FormatElement::GenerateTextureBufferFormat(const TextureDescription &tex)
|
||||
{
|
||||
QString baseType;
|
||||
|
||||
QString varName = lit("pixels");
|
||||
|
||||
uint32_t w = tex.width;
|
||||
|
||||
switch(tex.format.type)
|
||||
{
|
||||
case ResourceFormatType::BC1:
|
||||
case ResourceFormatType::BC2:
|
||||
case ResourceFormatType::BC3:
|
||||
case ResourceFormatType::BC4:
|
||||
case ResourceFormatType::BC5:
|
||||
case ResourceFormatType::BC6:
|
||||
case ResourceFormatType::BC7:
|
||||
case ResourceFormatType::ETC2:
|
||||
case ResourceFormatType::EAC:
|
||||
case ResourceFormatType::ASTC:
|
||||
case ResourceFormatType::PVRTC:
|
||||
varName = lit("block");
|
||||
// display a 4x4 block at a time
|
||||
w /= 4;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(tex.format.type)
|
||||
{
|
||||
case ResourceFormatType::Regular:
|
||||
{
|
||||
if(tex.format.compByteWidth == 1)
|
||||
baseType = lit("byte");
|
||||
else if(tex.format.compByteWidth == 2)
|
||||
baseType = lit("short");
|
||||
else
|
||||
baseType = lit("int");
|
||||
|
||||
baseType = QFormatStr("rgb x%1%2").arg(baseType).arg(tex.format.compCount);
|
||||
|
||||
break;
|
||||
}
|
||||
// 2x4 byte block, for 64-bit block formats
|
||||
case ResourceFormatType::BC1:
|
||||
case ResourceFormatType::BC4:
|
||||
case ResourceFormatType::ETC2:
|
||||
case ResourceFormatType::EAC:
|
||||
case ResourceFormatType::PVRTC:
|
||||
baseType = lit("row_major xint2x1");
|
||||
break;
|
||||
// 4x4 byte block, for 128-bit block formats
|
||||
case ResourceFormatType::BC2:
|
||||
case ResourceFormatType::BC3:
|
||||
case ResourceFormatType::BC5:
|
||||
case ResourceFormatType::BC6:
|
||||
case ResourceFormatType::BC7:
|
||||
case ResourceFormatType::ASTC: baseType = lit("row_major xint4x1"); break;
|
||||
case ResourceFormatType::R10G10B10A2: baseType = lit("uintten"); break;
|
||||
case ResourceFormatType::R11G11B10: baseType = lit("rgb floateleven"); break;
|
||||
case ResourceFormatType::R5G6B5:
|
||||
case ResourceFormatType::R5G5B5A1: baseType = lit("xshort"); break;
|
||||
case ResourceFormatType::R9G9B9E5: baseType = lit("xint"); break;
|
||||
case ResourceFormatType::R4G4B4A4: baseType = lit("xbyte2"); break;
|
||||
case ResourceFormatType::R4G4: baseType = lit("xbyte"); break;
|
||||
case ResourceFormatType::D16S8:
|
||||
case ResourceFormatType::D24S8:
|
||||
case ResourceFormatType::D32S8:
|
||||
case ResourceFormatType::YUV: baseType = lit("xint4"); break;
|
||||
case ResourceFormatType::S8:
|
||||
case ResourceFormatType::Undefined: baseType = lit("xbyte"); break;
|
||||
}
|
||||
|
||||
if(tex.type == TextureType::Buffer)
|
||||
return QFormatStr("%1 %2;").arg(baseType).arg(varName);
|
||||
|
||||
return QFormatStr("%1 %2[%3];").arg(baseType).arg(varName).arg(w);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T readObj(const byte *&data, const byte *end, bool &ok)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user