mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 13:30:44 +00:00
Add 'floateleven' buffer format for R11G11B10 packed data, fix unpacking
This commit is contained in:
@@ -103,6 +103,7 @@ There are also some non-hlsl types for displaying other formats which don't have
|
||||
* ``snormf`` - 32bit signed normalised value
|
||||
* ``uintten`` - 4 component unsigned integer format, packed as 10:10:10:2
|
||||
* ``unormten`` - 4 component unsigned normalised format, packed as 10:10:10:2
|
||||
* ``floateleven`` - 3 component floating point format, packed as 11:11:10
|
||||
* ``xuint`` - hex-formatted 32bit integer
|
||||
* ``xshort`` - hex-formatted 16bit integer
|
||||
* ``xbyte`` - hex-formatted 8bit integer
|
||||
|
||||
@@ -149,6 +149,7 @@ QList<FormatElement> FormatElement::ParseFormatString(const QString &formatStrin
|
||||
"^(row_major\\s+)?" // row_major matrix
|
||||
"("
|
||||
"uintten|unormten"
|
||||
"|floateleven"
|
||||
"|unormh|unormb"
|
||||
"|snormh|snormb"
|
||||
"|bool" // bool is stored as 4-byte int
|
||||
@@ -337,6 +338,14 @@ QList<FormatElement> FormatElement::ParseFormatString(const QString &formatStrin
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = eSpecial_R10G10B10A2;
|
||||
}
|
||||
else if(basetype == "floateleven")
|
||||
{
|
||||
fmt.compType = eCompType_Float;
|
||||
fmt.compCount = 3 * count;
|
||||
fmt.compByteWidth = 1;
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = eSpecial_R11G11B10;
|
||||
}
|
||||
else
|
||||
{
|
||||
errors = "Unrecognised basic type on line:\n" + line;
|
||||
@@ -585,16 +594,50 @@ QVariantList FormatElement::GetVariants(const byte *&data, const byte *end) cons
|
||||
{
|
||||
uint32_t packed = readObj<uint32_t>(data, end, ok);
|
||||
|
||||
uint32_t xMantissa = ((packed >> 0) & 0x3f);
|
||||
uint32_t xExponent = ((packed >> 6) & 0x1f);
|
||||
uint32_t yMantissa = ((packed >> 11) & 0x3f);
|
||||
uint32_t yExponent = ((packed >> 17) & 0x1f);
|
||||
uint32_t zMantissa = ((packed >> 22) & 0x1f);
|
||||
uint32_t zExponent = ((packed >> 27) & 0x1f);
|
||||
uint32_t mantissas[] = {
|
||||
(packed >> 0) & 0x3f, (packed >> 11) & 0x3f, (packed >> 22) & 0x1f,
|
||||
};
|
||||
int32_t exponents[] = {
|
||||
int32_t(packed >> 6) & 0x1f, int32_t(packed >> 17) & 0x1f, int32_t(packed >> 27) & 0x1f,
|
||||
};
|
||||
static const uint32_t leadbit[] = {
|
||||
0x40, 0x40, 0x20,
|
||||
};
|
||||
|
||||
ret.push_back(((float)(xMantissa) / 64.0f) * qPow(2.0f, (float)xExponent - 15.0f));
|
||||
ret.push_back(((float)(yMantissa) / 32.0f) * qPow(2.0f, (float)yExponent - 15.0f));
|
||||
ret.push_back(((float)(zMantissa) / 32.0f) * qPow(2.0f, (float)zExponent - 15.0f));
|
||||
for(int i = 0; i < 3; i++)
|
||||
{
|
||||
if(mantissas[i] == 0 && exponents[i] == 0)
|
||||
{
|
||||
ret.push_back((float)0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(exponents[i] == 0x1f)
|
||||
{
|
||||
// no sign bit, can't be negative infinity
|
||||
if(mantissas[i] == 0)
|
||||
ret.push_back((float)qInf());
|
||||
else
|
||||
ret.push_back((float)qQNaN());
|
||||
}
|
||||
else if(exponents[i] != 0)
|
||||
{
|
||||
// normal value, add leading bit
|
||||
uint32_t combined = leadbit[i] | mantissas[i];
|
||||
|
||||
// calculate value
|
||||
ret.push_back(((float)combined / (float)leadbit[i]) *
|
||||
qPow(2.0f, (float)exponents[i] - 15.0f));
|
||||
}
|
||||
else if(exponents[i] == 0)
|
||||
{
|
||||
// we know xMantissa isn't 0 also, or it would have been caught above so
|
||||
// this is a subnormal value, pretend exponent is 1 and don't add leading bit
|
||||
|
||||
ret.push_back(((float)mantissas[i] / (float)leadbit[i]) * qPow(2.0f, (float)1.0f - 15.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -82,7 +82,7 @@ Basic types accepted: bool, byte, short, int, half, float, double.
|
||||
Unsigned integer types: ubyte, ushort, uint
|
||||
Hex-formatted integer types: xbyte, xshort, xint
|
||||
|
||||
Additionally special formats: unorm[hb] (half, byte) and snorm[hb], and uintten/unormten (10:10:10:2 packing)
|
||||
Additionally special formats: unorm[hb] (half, byte) and snorm[hb], uintten/unormten (10:10:10:2 packing), floateleven (11:11:10F packing)
|
||||
|
||||
Vectors (e.g. float4), matrices ([row_major] half3x4) and arrays (float[16]) are supported.</string>
|
||||
</property>
|
||||
|
||||
@@ -1834,14 +1834,21 @@ void D3D11PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int
|
||||
else
|
||||
{
|
||||
const ResourceFormat &fmt = view.res.Format;
|
||||
if(fmt.special && fmt.specialFormat == eSpecial_R10G10B10A2)
|
||||
if(fmt.special)
|
||||
{
|
||||
if(fmt.compType == eCompType_UInt)
|
||||
format = "uintten";
|
||||
if(fmt.compType == eCompType_UNorm)
|
||||
format = "unormten";
|
||||
if(fmt.specialFormat == eSpecial_R10G10B10A2)
|
||||
{
|
||||
if(fmt.compType == eCompType_UInt)
|
||||
format = "uintten";
|
||||
if(fmt.compType == eCompType_UNorm)
|
||||
format = "unormten";
|
||||
}
|
||||
else if(fmt.specialFormat == eSpecial_R11G11B10)
|
||||
{
|
||||
format = "floateleven";
|
||||
}
|
||||
}
|
||||
else if(!fmt.special)
|
||||
else
|
||||
{
|
||||
switch(fmt.compByteWidth)
|
||||
{
|
||||
|
||||
@@ -1822,14 +1822,21 @@ void D3D12PipelineStateViewer::resource_itemActivated(QTreeWidgetItem *item, int
|
||||
else
|
||||
{
|
||||
const ResourceFormat &fmt = view.res.Format;
|
||||
if(fmt.special && fmt.specialFormat == eSpecial_R10G10B10A2)
|
||||
if(fmt.special)
|
||||
{
|
||||
if(fmt.compType == eCompType_UInt)
|
||||
format = "uintten";
|
||||
if(fmt.compType == eCompType_UNorm)
|
||||
format = "unormten";
|
||||
if(fmt.specialFormat == eSpecial_R10G10B10A2)
|
||||
{
|
||||
if(fmt.compType == eCompType_UInt)
|
||||
format = "uintten";
|
||||
if(fmt.compType == eCompType_UNorm)
|
||||
format = "unormten";
|
||||
}
|
||||
else if(fmt.specialFormat == eSpecial_R11G11B10)
|
||||
{
|
||||
format = "floateleven";
|
||||
}
|
||||
}
|
||||
else if(!fmt.special)
|
||||
else
|
||||
{
|
||||
switch(fmt.compByteWidth)
|
||||
{
|
||||
|
||||
@@ -258,16 +258,49 @@ namespace renderdocui.Code
|
||||
{
|
||||
uint packed = read.ReadUInt32();
|
||||
|
||||
uint xMantissa = ((packed >> 0) & 0x3f);
|
||||
uint xExponent = ((packed >> 6) & 0x1f);
|
||||
uint yMantissa = ((packed >> 11) & 0x3f);
|
||||
uint yExponent = ((packed >> 17) & 0x1f);
|
||||
uint zMantissa = ((packed >> 22) & 0x1f);
|
||||
uint zExponent = ((packed >> 27) & 0x1f);
|
||||
uint[] mantissas = new uint[] {
|
||||
(packed >> 0) & 0x3f, (packed >> 11) & 0x3f, (packed >> 22) & 0x1f,
|
||||
};
|
||||
uint[] leadbit = new uint[] {
|
||||
0x40, 0x40, 0x20,
|
||||
};
|
||||
int[] exponents = new int[]{
|
||||
(int)(packed >> 6) & 0x1f, (int)(packed >> 17) & 0x1f, (int)(packed >> 27) & 0x1f,
|
||||
};
|
||||
|
||||
ret.Add(((float)(xMantissa) / 64.0f) * Math.Pow(2.0f, (float)xExponent - 15.0f));
|
||||
ret.Add(((float)(yMantissa) / 32.0f) * Math.Pow(2.0f, (float)yExponent - 15.0f));
|
||||
ret.Add(((float)(zMantissa) / 32.0f) * Math.Pow(2.0f, (float)zExponent - 15.0f));
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (mantissas[i] == 0 && exponents[i] == 0)
|
||||
{
|
||||
ret.Add((float)0.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (exponents[i] == 0x1f)
|
||||
{
|
||||
// no sign bit, can't be negative infinity
|
||||
if (mantissas[i] == 0)
|
||||
ret.Add(float.PositiveInfinity);
|
||||
else
|
||||
ret.Add(float.NaN);
|
||||
}
|
||||
else if (exponents[i] != 0)
|
||||
{
|
||||
// normal value, add leading bit
|
||||
uint combined = leadbit[i] | mantissas[i];
|
||||
|
||||
// calculate value
|
||||
ret.Add(((float)combined / (float)leadbit[i]) * Math.Pow(2.0f, (float)exponents[i] - 15.0f));
|
||||
}
|
||||
else if (exponents[i] == 0)
|
||||
{
|
||||
// we know xMantissa isn't 0 also, or it would have been caught above so
|
||||
// this is a subnormal value, pretend exponent is 1 and don't add leading bit
|
||||
|
||||
ret.Add(((float)mantissas[i] / (float)leadbit[i]) * Math.Pow(2.0f, (float)1.0f - 15.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -426,6 +459,7 @@ namespace renderdocui.Code
|
||||
var regExpr = @"^(row_major\s+)?" + // row_major matrix
|
||||
@"(" +
|
||||
@"uintten|unormten" +
|
||||
@"|floateleven" +
|
||||
@"|unormh|unormb" +
|
||||
@"|snormh|snormb" +
|
||||
@"|bool" + // bool is stored as 4-byte int
|
||||
@@ -608,6 +642,12 @@ namespace renderdocui.Code
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = SpecialFormat.R10G10B10A2;
|
||||
}
|
||||
else if (basetype == "floateleven")
|
||||
{
|
||||
fmt = new ResourceFormat(FormatComponentType.Float, 3 * count, 1);
|
||||
fmt.special = true;
|
||||
fmt.specialFormat = SpecialFormat.R11G11B10;
|
||||
}
|
||||
else
|
||||
{
|
||||
errors = "Unrecognised basic type on line:\n" + line;
|
||||
|
||||
@@ -125,7 +125,7 @@ Basic types accepted: bool, byte, short, int, half, float, double.
|
||||
Unsigned integer types: ubyte, ushort, uint
|
||||
Hex-formatted integer types: xbyte, xshort, xint
|
||||
|
||||
Additionally special formats: unorm[hb] (half, byte) and snorm[hb], and uintten/unormten (10:10:10:2 packing)
|
||||
Additionally special formats: unorm[hb] (half, byte) and snorm[hb], uintten/unormten (10:10:10:2 packing), floateleven (11:11:10F packing)
|
||||
|
||||
Vectors (e.g. float4), matrices ([row_major] half3x4) and arrays (float[16]) are supported.</value>
|
||||
</data>
|
||||
|
||||
@@ -2042,10 +2042,17 @@ namespace renderdocui.Windows.PipelineState
|
||||
{
|
||||
if (view != null)
|
||||
{
|
||||
if (view.Format.special && view.Format.specialFormat == SpecialFormat.R10G10B10A2)
|
||||
if (view.Format.special)
|
||||
{
|
||||
if (view.Format.compType == FormatComponentType.UInt) format = "uintten";
|
||||
if (view.Format.compType == FormatComponentType.UNorm) format = "unormten";
|
||||
if (view.Format.specialFormat == SpecialFormat.R10G10B10A2)
|
||||
{
|
||||
if (view.Format.compType == FormatComponentType.UInt) format = "uintten";
|
||||
if (view.Format.compType == FormatComponentType.UNorm) format = "unormten";
|
||||
}
|
||||
else if (view.Format.specialFormat == SpecialFormat.R11G11B10)
|
||||
{
|
||||
format = "floateleven";
|
||||
}
|
||||
}
|
||||
else if (!view.Format.special)
|
||||
{
|
||||
|
||||
@@ -1721,10 +1721,17 @@ namespace renderdocui.Windows.PipelineState
|
||||
{
|
||||
if (view != null)
|
||||
{
|
||||
if (view.Format.special && view.Format.specialFormat == SpecialFormat.R10G10B10A2)
|
||||
if (view.Format.special)
|
||||
{
|
||||
if (view.Format.compType == FormatComponentType.UInt) format = "uintten";
|
||||
if (view.Format.compType == FormatComponentType.UNorm) format = "unormten";
|
||||
if (view.Format.specialFormat == SpecialFormat.R10G10B10A2)
|
||||
{
|
||||
if (view.Format.compType == FormatComponentType.UInt) format = "uintten";
|
||||
if (view.Format.compType == FormatComponentType.UNorm) format = "unormten";
|
||||
}
|
||||
else if (view.Format.specialFormat == SpecialFormat.R11G11B10)
|
||||
{
|
||||
format = "floateleven";
|
||||
}
|
||||
}
|
||||
else if (!view.Format.special)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user