Refactor BGRA formats to not be special (so allow any BGRA format)

* Also add ASTC and D16S8 types while in the neighbourhood
This commit is contained in:
baldurk
2015-11-29 22:05:26 +01:00
parent 7ef19b8ae1
commit 8b7a025853
20 changed files with 512 additions and 309 deletions
+37 -21
View File
@@ -109,43 +109,52 @@ namespace renderdocui.Code
{
var ret = new List<object>();
if (format.special && format.specialFormat == SpecialFormat.B8G8R8A8)
{
byte b = read.ReadByte();
byte g = read.ReadByte();
byte r = read.ReadByte();
byte a = read.ReadByte();
ret.Add((float)r / 255.0f);
ret.Add((float)g / 255.0f);
ret.Add((float)b / 255.0f);
ret.Add((float)a / 255.0f);
}
else if (format.special && format.specialFormat == SpecialFormat.B5G5R5A1)
if (format.special && format.specialFormat == SpecialFormat.R5G5B5A1)
{
ushort packed = read.ReadUInt16();
ret.Add((float)((packed >> 10) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 0) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 5) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 0) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 10) & 0x1f) / 31.0f);
ret.Add(((packed & 0x8000) > 0) ? 1.0f : 0.0f);
if (format.bgraOrder)
{
object tmp = ret[2];
ret[2] = ret[0];
ret[0] = tmp;
}
}
else if (format.special && format.specialFormat == SpecialFormat.B5G6R5)
else if (format.special && format.specialFormat == SpecialFormat.R5G6B5)
{
ushort packed = read.ReadUInt16();
ret.Add((float)((packed >> 11) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 5) & 0x3f) / 63.0f);
ret.Add((float)((packed >> 0) & 0x1f) / 31.0f);
ret.Add((float)((packed >> 5) & 0x3f) / 63.0f);
ret.Add((float)((packed >> 11) & 0x1f) / 31.0f);
if (format.bgraOrder)
{
object tmp = ret[2];
ret[2] = ret[0];
ret[0] = tmp;
}
}
else if (format.special && format.specialFormat == SpecialFormat.B4G4R4A4)
else if (format.special && format.specialFormat == SpecialFormat.R4G4B4A4)
{
ushort packed = read.ReadUInt16();
ret.Add((float)((packed >> 8) & 0xf) / 15.0f);
ret.Add((float)((packed >> 4) & 0xf) / 15.0f);
ret.Add((float)((packed >> 0) & 0xf) / 15.0f);
ret.Add((float)((packed >> 4) & 0xf) / 15.0f);
ret.Add((float)((packed >> 8) & 0xf) / 15.0f);
ret.Add((float)((packed >> 12) & 0xf) / 15.0f);
if (format.bgraOrder)
{
object tmp = ret[2];
ret[2] = ret[0];
ret[0] = tmp;
}
}
else if (format.special && format.specialFormat == SpecialFormat.R10G10B10A2)
{
@@ -256,6 +265,13 @@ namespace renderdocui.Code
}
}
}
if (format.bgraOrder)
{
object tmp = ret[2];
ret[2] = ret[0];
ret[0] = tmp;
}
}
return ret.ToArray();
+5 -4
View File
@@ -172,13 +172,14 @@ namespace renderdoc
BC7,
ETC2,
EAC,
ASTC,
R10G10B10A2,
R11G11B10,
B5G6R5,
B5G5R5A1,
R5G6B5,
R5G5B5A1,
R9G9B9E5,
B8G8R8A8,
B4G4R4A4,
R4G4B4A4,
D16S8,
D24S8,
D32S8,
S8,
+6
View File
@@ -87,6 +87,7 @@ namespace renderdoc
compType = FormatComponentType.None;
compCount = 0;
compByteWidth = 0;
bgraOrder = false;
srgbCorrected = false;
strname = "";
@@ -101,6 +102,7 @@ namespace renderdoc
compType = type;
compCount = count;
compByteWidth = byteWidth;
bgraOrder = false;
srgbCorrected = false;
strname = "";
@@ -120,6 +122,7 @@ namespace renderdoc
public UInt32 compByteWidth;
public FormatComponentType compType;
public bool bgraOrder;
public bool srgbCorrected;
public override string ToString()
@@ -137,6 +140,7 @@ namespace renderdoc
hash = hash * 17 + compCount.GetHashCode();
hash = hash * 17 + compByteWidth.GetHashCode();
hash = hash * 17 + compType.GetHashCode();
hash = hash * 17 + bgraOrder.GetHashCode();
hash = hash * 17 + srgbCorrected.GetHashCode();
return hash;
}
@@ -148,6 +152,7 @@ namespace renderdoc
return x.compCount == y.compCount &&
x.compByteWidth == y.compByteWidth &&
x.compType == y.compType &&
x.bgraOrder == y.bgraOrder &&
x.srgbCorrected == y.srgbCorrected;
}
public static bool operator !=(ResourceFormat x, ResourceFormat y)
@@ -379,6 +384,7 @@ namespace renderdoc
public UInt32 compCount;
public UInt32 compByteWidth;
public FormatComponentType compType;
public bool bgraOrder;
public SpecialFormat specialFormat;
public bool showAlpha;
+3
View File
@@ -2550,6 +2550,7 @@ namespace renderdocui.Windows
m_MeshDisplay.position.compCount = pos.format.compCount;
m_MeshDisplay.position.compByteWidth = pos.format.compByteWidth;
m_MeshDisplay.position.compType = pos.format.compType;
m_MeshDisplay.position.bgraOrder = pos.format.bgraOrder;
m_MeshDisplay.position.specialFormat = pos.format.special ? pos.format.specialFormat : SpecialFormat.Unknown;
m_MeshDisplay.position.showAlpha = false;
@@ -2622,6 +2623,7 @@ namespace renderdocui.Windows
m_MeshDisplay.secondary.compCount = 0;
m_MeshDisplay.secondary.compByteWidth = 0;
m_MeshDisplay.secondary.compType = FormatComponentType.None;
m_MeshDisplay.secondary.bgraOrder = false;
m_MeshDisplay.secondary.specialFormat = SpecialFormat.Unknown;
m_MeshDisplay.secondary.showAlpha = false;
@@ -2638,6 +2640,7 @@ namespace renderdocui.Windows
m_MeshDisplay.secondary.compCount = tex.format.compCount;
m_MeshDisplay.secondary.compByteWidth = tex.format.compByteWidth;
m_MeshDisplay.secondary.compType = tex.format.compType;
m_MeshDisplay.secondary.bgraOrder = tex.format.bgraOrder;
m_MeshDisplay.secondary.specialFormat = tex.format.special ? tex.format.specialFormat : SpecialFormat.Unknown;
m_MeshDisplay.secondary.showAlpha = CurSecondShowAlpha;
@@ -325,7 +325,8 @@ namespace renderdocui.Windows.PipelineState
typename = texs[t].resType.Str();
if (texs[t].format.special &&
(texs[t].format.specialFormat == SpecialFormat.D24S8 ||
(texs[t].format.specialFormat == SpecialFormat.D16S8 ||
texs[t].format.specialFormat == SpecialFormat.D24S8 ||
texs[t].format.specialFormat == SpecialFormat.D32S8)
)
{
+1
View File
@@ -257,6 +257,7 @@ namespace renderdocui.Windows
bool depth = false;
if (texture.format.compType == FormatComponentType.Depth ||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D16S8) ||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D24S8) ||
(texture.format.special && texture.format.specialFormat == SpecialFormat.D32S8) ||
(texture.format.special && texture.format.specialFormat == SpecialFormat.S8))