mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 13:20:54 +00:00
Combine 'special' with 'specialFormat' as single resource format type
* There was no good reason to have a flag indicating if the special format was valid or not. Now it's a single enum, with a value 'Regular' indicating that the compCount/compWidth/compType fully describe the format itself. * This makes code patterns easier as you no longer need to check for special then check for specialFormat, you can just test the type directly.
This commit is contained in:
@@ -334,24 +334,21 @@ QList<FormatElement> FormatElement::ParseFormatString(const QString &formatStrin
|
||||
fmt.compType = CompType::UInt;
|
||||
fmt.compCount = 4 * count;
|
||||
fmt.compByteWidth = 1;
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = SpecialFormat::R10G10B10A2;
|
||||
fmt.type = ResourceFormatType::R10G10B10A2;
|
||||
}
|
||||
else if(basetype == lit("unormten"))
|
||||
{
|
||||
fmt.compType = CompType::UInt;
|
||||
fmt.compCount = 4 * count;
|
||||
fmt.compByteWidth = 1;
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = SpecialFormat::R10G10B10A2;
|
||||
fmt.type = ResourceFormatType::R10G10B10A2;
|
||||
}
|
||||
else if(basetype == lit("floateleven"))
|
||||
{
|
||||
fmt.compType = CompType::Float;
|
||||
fmt.compCount = 3 * count;
|
||||
fmt.compByteWidth = 1;
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = SpecialFormat::R11G11B10;
|
||||
fmt.type = ResourceFormatType::R11G11B10;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -467,7 +464,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
|
||||
bool ok = true;
|
||||
|
||||
if(format.special && format.specialFormat == SpecialFormat::R5G5B5A1)
|
||||
if(format.type == ResourceFormatType::R5G5B5A1)
|
||||
{
|
||||
uint16_t packed = readObj<uint16_t>(data, end, ok);
|
||||
|
||||
@@ -483,7 +480,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
ret[0] = tmp;
|
||||
}
|
||||
}
|
||||
else if(format.special && format.specialFormat == SpecialFormat::R5G6B5)
|
||||
else if(format.type == ResourceFormatType::R5G6B5)
|
||||
{
|
||||
uint16_t packed = readObj<uint16_t>(data, end, ok);
|
||||
|
||||
@@ -498,7 +495,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
ret[0] = tmp;
|
||||
}
|
||||
}
|
||||
else if(format.special && format.specialFormat == SpecialFormat::R4G4B4A4)
|
||||
else if(format.type == ResourceFormatType::R4G4B4A4)
|
||||
{
|
||||
uint16_t packed = readObj<uint16_t>(data, end, ok);
|
||||
|
||||
@@ -514,7 +511,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
ret[0] = tmp;
|
||||
}
|
||||
}
|
||||
else if(format.special && format.specialFormat == SpecialFormat::R10G10B10A2)
|
||||
else if(format.type == ResourceFormatType::R10G10B10A2)
|
||||
{
|
||||
// allow for vectors of this format - for raw buffer viewer
|
||||
for(int i = 0; i < int(format.compCount / 4); i++)
|
||||
@@ -597,7 +594,7 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(format.special && format.specialFormat == SpecialFormat::R11G11B10)
|
||||
else if(format.type == ResourceFormatType::R11G11B10)
|
||||
{
|
||||
uint32_t packed = readObj<uint32_t>(data, end, ok);
|
||||
|
||||
@@ -813,17 +810,12 @@ uint32_t FormatElement::byteSize() const
|
||||
{
|
||||
uint32_t vecSize = format.compByteWidth * format.compCount;
|
||||
|
||||
if(format.special)
|
||||
{
|
||||
if(format.specialFormat == SpecialFormat::R5G5B5A1 ||
|
||||
format.specialFormat == SpecialFormat::R5G6B5 ||
|
||||
format.specialFormat == SpecialFormat::R4G4B4A4)
|
||||
vecSize = 2;
|
||||
if(format.type == ResourceFormatType::R5G5B5A1 || format.type == ResourceFormatType::R5G6B5 ||
|
||||
format.type == ResourceFormatType::R4G4B4A4)
|
||||
vecSize = 2;
|
||||
|
||||
if(format.specialFormat == SpecialFormat::R10G10B10A2 ||
|
||||
format.specialFormat == SpecialFormat::R11G11B10)
|
||||
vecSize = 4;
|
||||
}
|
||||
if(format.type == ResourceFormatType::R10G10B10A2 || format.type == ResourceFormatType::R11G11B10)
|
||||
vecSize = 4;
|
||||
|
||||
return vecSize * matrixdim;
|
||||
}
|
||||
|
||||
@@ -808,7 +808,7 @@ QVector<VertexInputAttribute> CommonPipelineState::GetVertexInputs()
|
||||
ret[a].Format.compByteWidth = 4;
|
||||
ret[a].Format.compCount = compCount;
|
||||
ret[a].Format.compType = compType;
|
||||
ret[a].Format.special = false;
|
||||
ret[a].Format.type = ResourceFormatType::Regular;
|
||||
ret[a].Format.srgbCorrected = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -794,30 +794,30 @@ private:
|
||||
|
||||
uint32_t compCount;
|
||||
|
||||
switch(fmt.format.specialFormat)
|
||||
switch(fmt.format.type)
|
||||
{
|
||||
case SpecialFormat::BC6:
|
||||
case SpecialFormat::ETC2:
|
||||
case SpecialFormat::R11G11B10:
|
||||
case SpecialFormat::R5G6B5:
|
||||
case SpecialFormat::R9G9B9E5: compCount = 3; break;
|
||||
case SpecialFormat::BC1:
|
||||
case SpecialFormat::BC7:
|
||||
case SpecialFormat::BC3:
|
||||
case SpecialFormat::BC2:
|
||||
case SpecialFormat::R10G10B10A2:
|
||||
case SpecialFormat::R5G5B5A1:
|
||||
case SpecialFormat::R4G4B4A4:
|
||||
case SpecialFormat::ASTC: compCount = 4; break;
|
||||
case SpecialFormat::BC5:
|
||||
case SpecialFormat::R4G4:
|
||||
case SpecialFormat::D16S8:
|
||||
case SpecialFormat::D24S8:
|
||||
case SpecialFormat::D32S8: compCount = 2; break;
|
||||
case SpecialFormat::BC4:
|
||||
case SpecialFormat::S8: compCount = 1; break;
|
||||
case SpecialFormat::YUV:
|
||||
case SpecialFormat::EAC:
|
||||
case ResourceFormatType::BC6:
|
||||
case ResourceFormatType::ETC2:
|
||||
case ResourceFormatType::R11G11B10:
|
||||
case ResourceFormatType::R5G6B5:
|
||||
case ResourceFormatType::R9G9B9E5: compCount = 3; break;
|
||||
case ResourceFormatType::BC1:
|
||||
case ResourceFormatType::BC7:
|
||||
case ResourceFormatType::BC3:
|
||||
case ResourceFormatType::BC2:
|
||||
case ResourceFormatType::R10G10B10A2:
|
||||
case ResourceFormatType::R5G5B5A1:
|
||||
case ResourceFormatType::R4G4B4A4:
|
||||
case ResourceFormatType::ASTC: compCount = 4; break;
|
||||
case ResourceFormatType::BC5:
|
||||
case ResourceFormatType::R4G4:
|
||||
case ResourceFormatType::D16S8:
|
||||
case ResourceFormatType::D24S8:
|
||||
case ResourceFormatType::D32S8: compCount = 2; break;
|
||||
case ResourceFormatType::BC4:
|
||||
case ResourceFormatType::S8: compCount = 1; break;
|
||||
case ResourceFormatType::YUV:
|
||||
case ResourceFormatType::EAC:
|
||||
default: compCount = fmt.format.compCount;
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ private:
|
||||
else if(vt == QMetaType::UInt || vt == QMetaType::UShort || vt == QMetaType::UChar)
|
||||
{
|
||||
uint u = v.toUInt();
|
||||
if(el.hex && el.format.specialFormat == SpecialFormat::Unknown)
|
||||
if(el.hex && el.format.type == ResourceFormatType::Regular)
|
||||
ret = Formatter::HexFormat(u, el.format.compByteWidth);
|
||||
else
|
||||
ret = Formatter::Format(u, el.hex);
|
||||
@@ -2208,7 +2208,7 @@ void BufferViewer::configureMeshColumns()
|
||||
f.format.compByteWidth = sizeof(float);
|
||||
f.format.compCount = sig.compCount;
|
||||
f.format.compType = sig.compType;
|
||||
f.format.special = false;
|
||||
f.format.type = ResourceFormatType::Regular;
|
||||
f.perinstance = false;
|
||||
f.instancerate = 1;
|
||||
f.rowmajor = false;
|
||||
@@ -2275,7 +2275,7 @@ void BufferViewer::configureMeshColumns()
|
||||
f.format.compByteWidth = sizeof(float);
|
||||
f.format.compCount = sig.compCount;
|
||||
f.format.compType = sig.compType;
|
||||
f.format.special = false;
|
||||
f.format.type = ResourceFormatType::Regular;
|
||||
f.perinstance = false;
|
||||
f.instancerate = 1;
|
||||
f.rowmajor = false;
|
||||
|
||||
@@ -1553,9 +1553,8 @@ void MainWindow::on_action_Start_Replay_Loop_triggered()
|
||||
for(const TextureDescription &tex : m_Ctx.GetTextures())
|
||||
{
|
||||
if((tex.creationFlags & TextureCategory::SwapBuffer) &&
|
||||
tex.format.compType != CompType::Depth && tex.format.specialFormat != SpecialFormat::D16S8 &&
|
||||
tex.format.specialFormat != SpecialFormat::D24S8 &&
|
||||
tex.format.specialFormat != SpecialFormat::D32S8)
|
||||
tex.format.compType != CompType::Depth && tex.format.type != ResourceFormatType::D16S8 &&
|
||||
tex.format.type != ResourceFormatType::D24S8 && tex.format.type != ResourceFormatType::D32S8)
|
||||
{
|
||||
displayTex = &tex;
|
||||
break;
|
||||
|
||||
@@ -1945,19 +1945,16 @@ void D3D11PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
|
||||
else
|
||||
{
|
||||
const ResourceFormat &fmt = view.res.Format;
|
||||
if(fmt.special)
|
||||
if(fmt.type == ResourceFormatType::R10G10B10A2)
|
||||
{
|
||||
if(fmt.specialFormat == SpecialFormat::R10G10B10A2)
|
||||
{
|
||||
if(fmt.compType == CompType::UInt)
|
||||
format = lit("uintten");
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
format = lit("unormten");
|
||||
}
|
||||
else if(fmt.specialFormat == SpecialFormat::R11G11B10)
|
||||
{
|
||||
format = lit("floateleven");
|
||||
}
|
||||
if(fmt.compType == CompType::UInt)
|
||||
format = lit("uintten");
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
format = lit("unormten");
|
||||
}
|
||||
else if(fmt.type == ResourceFormatType::R11G11B10)
|
||||
{
|
||||
format = lit("floateleven");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1818,19 +1818,16 @@ void D3D12PipelineStateViewer::resource_itemActivated(RDTreeWidgetItem *item, in
|
||||
else
|
||||
{
|
||||
const ResourceFormat &fmt = view.res.Format;
|
||||
if(fmt.special)
|
||||
if(fmt.type == ResourceFormatType::R10G10B10A2)
|
||||
{
|
||||
if(fmt.specialFormat == SpecialFormat::R10G10B10A2)
|
||||
{
|
||||
if(fmt.compType == CompType::UInt)
|
||||
format = lit("uintten");
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
format = lit("unormten");
|
||||
}
|
||||
else if(fmt.specialFormat == SpecialFormat::R11G11B10)
|
||||
{
|
||||
format = lit("floateleven");
|
||||
}
|
||||
if(fmt.compType == CompType::UInt)
|
||||
format = lit("uintten");
|
||||
if(fmt.compType == CompType::UNorm)
|
||||
format = lit("unormten");
|
||||
}
|
||||
else if(fmt.type == ResourceFormatType::R11G11B10)
|
||||
{
|
||||
format = lit("floateleven");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -676,9 +676,9 @@ void GLPipelineStateViewer::setShaderState(const GLPipe::Shader &stage, QLabel *
|
||||
name = tex->name;
|
||||
typeName = ToQStr(tex->resType);
|
||||
|
||||
if(tex->format.special && (tex->format.specialFormat == SpecialFormat::D16S8 ||
|
||||
tex->format.specialFormat == SpecialFormat::D24S8 ||
|
||||
tex->format.specialFormat == SpecialFormat::D32S8))
|
||||
if(tex->format.type == ResourceFormatType::D16S8 ||
|
||||
tex->format.type == ResourceFormatType::D24S8 ||
|
||||
tex->format.type == ResourceFormatType::D32S8)
|
||||
{
|
||||
if(r.DepthReadChannel == 0)
|
||||
format += tr(" Depth-Read");
|
||||
@@ -2535,9 +2535,9 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Shad
|
||||
name = tex->name;
|
||||
typeName = ToQStr(tex->resType);
|
||||
|
||||
if(tex->format.special && (tex->format.specialFormat == SpecialFormat::D16S8 ||
|
||||
tex->format.specialFormat == SpecialFormat::D24S8 ||
|
||||
tex->format.specialFormat == SpecialFormat::D32S8))
|
||||
if(tex->format.type == ResourceFormatType::D16S8 ||
|
||||
tex->format.type == ResourceFormatType::D24S8 ||
|
||||
tex->format.type == ResourceFormatType::D32S8)
|
||||
{
|
||||
if(r.DepthReadChannel == 0)
|
||||
format += tr(" Depth-Repipead");
|
||||
|
||||
@@ -60,16 +60,13 @@ public:
|
||||
if(compType == CompType::Depth)
|
||||
m_IsDepth = true;
|
||||
|
||||
if(m_Tex->format.special)
|
||||
switch(m_Tex->format.type)
|
||||
{
|
||||
switch(m_Tex->format.specialFormat)
|
||||
{
|
||||
case SpecialFormat::D16S8:
|
||||
case SpecialFormat::D24S8:
|
||||
case SpecialFormat::D32S8:
|
||||
case SpecialFormat::S8: m_IsDepth = true; break;
|
||||
default: break;
|
||||
}
|
||||
case ResourceFormatType::D16S8:
|
||||
case ResourceFormatType::D24S8:
|
||||
case ResourceFormatType::D32S8:
|
||||
case ResourceFormatType::S8: m_IsDepth = true; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1344,7 +1344,7 @@ void TextureViewer::UI_UpdateChannels()
|
||||
// swapbuffer is always srgb for 8-bit types, linear for 16-bit types
|
||||
DISABLE(ui->gammaDisplay);
|
||||
|
||||
if(tex->format.compByteWidth == 2 && !tex->format.special)
|
||||
if(tex->format.compByteWidth == 2 && tex->format.type == ResourceFormatType::Regular)
|
||||
m_TexDisplay.linearDisplayAsGamma = false;
|
||||
else
|
||||
m_TexDisplay.linearDisplayAsGamma = true;
|
||||
@@ -3264,27 +3264,27 @@ void TextureViewer::on_viewTexBuffer_clicked()
|
||||
|
||||
uint32_t w = texptr->width;
|
||||
|
||||
switch(texptr->format.specialFormat)
|
||||
switch(texptr->format.type)
|
||||
{
|
||||
case SpecialFormat::BC1:
|
||||
case SpecialFormat::BC2:
|
||||
case SpecialFormat::BC3:
|
||||
case SpecialFormat::BC4:
|
||||
case SpecialFormat::BC5:
|
||||
case SpecialFormat::BC6:
|
||||
case SpecialFormat::BC7:
|
||||
case SpecialFormat::ETC2:
|
||||
case SpecialFormat::EAC:
|
||||
case SpecialFormat::ASTC:
|
||||
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:
|
||||
varName = lit("block");
|
||||
// display a 4x4 block at a time
|
||||
w /= 4;
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(texptr->format.specialFormat)
|
||||
switch(texptr->format.type)
|
||||
{
|
||||
case SpecialFormat::Unknown:
|
||||
case ResourceFormatType::Regular:
|
||||
{
|
||||
if(texptr->format.compByteWidth == 1)
|
||||
baseType = lit("byte");
|
||||
@@ -3298,31 +3298,32 @@ void TextureViewer::on_viewTexBuffer_clicked()
|
||||
break;
|
||||
}
|
||||
// 2x4 byte block, for 64-bit block formats
|
||||
case SpecialFormat::BC1:
|
||||
case SpecialFormat::BC4:
|
||||
case SpecialFormat::ETC2:
|
||||
case SpecialFormat::EAC:
|
||||
case ResourceFormatType::BC1:
|
||||
case ResourceFormatType::BC4:
|
||||
case ResourceFormatType::ETC2:
|
||||
case ResourceFormatType::EAC:
|
||||
baseType = lit("row_major xint2x1");
|
||||
break;
|
||||
// 4x4 byte block, for 128-bit block formats
|
||||
case SpecialFormat::BC2:
|
||||
case SpecialFormat::BC3:
|
||||
case SpecialFormat::BC5:
|
||||
case SpecialFormat::BC6:
|
||||
case SpecialFormat::BC7:
|
||||
case SpecialFormat::ASTC: baseType = lit("row_major xint4x1"); break;
|
||||
case SpecialFormat::R10G10B10A2: baseType = lit("uintten"); break;
|
||||
case SpecialFormat::R11G11B10: baseType = lit("rgb floateleven"); break;
|
||||
case SpecialFormat::R5G6B5:
|
||||
case SpecialFormat::R5G5B5A1: baseType = lit("xshort"); break;
|
||||
case SpecialFormat::R9G9B9E5: baseType = lit("xint"); break;
|
||||
case SpecialFormat::R4G4B4A4: baseType = lit("xbyte2"); break;
|
||||
case SpecialFormat::R4G4: baseType = lit("xbyte"); break;
|
||||
case SpecialFormat::D16S8:
|
||||
case SpecialFormat::D24S8:
|
||||
case SpecialFormat::D32S8:
|
||||
case SpecialFormat::YUV: baseType = lit("xint4"); break;
|
||||
case SpecialFormat::S8: baseType = lit("xbyte"); break;
|
||||
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;
|
||||
}
|
||||
|
||||
QString format = QFormatStr("%1 %2[%3];").arg(baseType).arg(varName).arg(w);
|
||||
|
||||
Reference in New Issue
Block a user