mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Add 'floateleven' buffer format for R11G11B10 packed data, fix unpacking
This commit is contained in:
@@ -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