mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-12 13:00:32 +00:00
Add missing handling of uscaled and sscaled formats
This commit is contained in:
@@ -48,11 +48,11 @@ float ConvertComponent(ResourceFormat fmt, byte *data)
|
||||
{
|
||||
return *(float *)u32;
|
||||
}
|
||||
else if(fmt.compType == eCompType_UInt)
|
||||
else if(fmt.compType == eCompType_UInt || fmt.compType == eCompType_UScaled)
|
||||
{
|
||||
return float(*u32);
|
||||
}
|
||||
else if(fmt.compType == eCompType_SInt)
|
||||
else if(fmt.compType == eCompType_SInt || fmt.compType == eCompType_SScaled)
|
||||
{
|
||||
return float(*i32);
|
||||
}
|
||||
@@ -66,11 +66,11 @@ float ConvertComponent(ResourceFormat fmt, byte *data)
|
||||
{
|
||||
return ConvertFromHalf(*u16);
|
||||
}
|
||||
else if(fmt.compType == eCompType_UInt)
|
||||
else if(fmt.compType == eCompType_UInt || fmt.compType == eCompType_UScaled)
|
||||
{
|
||||
return float(*u16);
|
||||
}
|
||||
else if(fmt.compType == eCompType_SInt)
|
||||
else if(fmt.compType == eCompType_SInt || fmt.compType == eCompType_SScaled)
|
||||
{
|
||||
return float(*i16);
|
||||
}
|
||||
@@ -95,11 +95,11 @@ float ConvertComponent(ResourceFormat fmt, byte *data)
|
||||
uint8_t *u8 = (uint8_t *)data;
|
||||
int8_t *i8 = (int8_t *)data;
|
||||
|
||||
if(fmt.compType == eCompType_UInt)
|
||||
if(fmt.compType == eCompType_UInt || fmt.compType == eCompType_UScaled)
|
||||
{
|
||||
return float(*u8);
|
||||
}
|
||||
else if(fmt.compType == eCompType_SInt)
|
||||
else if(fmt.compType == eCompType_SInt || fmt.compType == eCompType_SScaled)
|
||||
{
|
||||
return float(*i8);
|
||||
}
|
||||
|
||||
@@ -699,6 +699,10 @@ namespace renderdocui.Code
|
||||
ret[a].GenericValue[c] = attrs[i].GenericValue.u[c];
|
||||
else if (compType == FormatComponentType.SInt)
|
||||
ret[a].GenericValue[c] = attrs[i].GenericValue.i[c];
|
||||
else if (compType == FormatComponentType.UScaled)
|
||||
ret[a].GenericValue[c] = (float)attrs[i].GenericValue.u[c];
|
||||
else if (compType == FormatComponentType.SScaled)
|
||||
ret[a].GenericValue[c] = (float)attrs[i].GenericValue.i[c];
|
||||
}
|
||||
|
||||
ret[a].PerInstance = false;
|
||||
|
||||
@@ -168,6 +168,13 @@ namespace renderdocui.Code
|
||||
uint b = (packed >> 20) & 0x3ff;
|
||||
uint a = (packed >> 30) & 0x003;
|
||||
|
||||
if (format.bgraOrder)
|
||||
{
|
||||
uint tmp = b;
|
||||
b = r;
|
||||
r = tmp;
|
||||
}
|
||||
|
||||
if (format.compType == FormatComponentType.UInt)
|
||||
{
|
||||
ret.Add(r);
|
||||
@@ -175,6 +182,55 @@ namespace renderdocui.Code
|
||||
ret.Add(b);
|
||||
ret.Add(a);
|
||||
}
|
||||
else if (format.compType == FormatComponentType.UScaled)
|
||||
{
|
||||
ret.Add((float)r);
|
||||
ret.Add((float)g);
|
||||
ret.Add((float)b);
|
||||
ret.Add((float)a);
|
||||
}
|
||||
else if (format.compType == FormatComponentType.SInt ||
|
||||
format.compType == FormatComponentType.SScaled)
|
||||
{
|
||||
int ir, ig, ib, ia;
|
||||
|
||||
// interpret RGB as 10-bit signed integers
|
||||
if(r <= 511)
|
||||
ir = (int)r;
|
||||
else
|
||||
ir = ((int)r) - 1024;
|
||||
|
||||
if (g <= 511)
|
||||
ig = (int)g;
|
||||
else
|
||||
ig = ((int)g) - 1024;
|
||||
|
||||
if (b <= 511)
|
||||
ib = (int)b;
|
||||
else
|
||||
ib = ((int)b) - 1024;
|
||||
|
||||
// 2-bit signed integer
|
||||
if (a <= 1)
|
||||
ia = (int)a;
|
||||
else
|
||||
ia = ((int)a) - 4;
|
||||
|
||||
if (format.compType == FormatComponentType.SInt)
|
||||
{
|
||||
ret.Add(ir);
|
||||
ret.Add(ig);
|
||||
ret.Add(ib);
|
||||
ret.Add(ia);
|
||||
}
|
||||
else if (format.compType == FormatComponentType.SScaled)
|
||||
{
|
||||
ret.Add((float)ir);
|
||||
ret.Add((float)ig);
|
||||
ret.Add((float)ib);
|
||||
ret.Add((float)ia);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.Add((float)r / 1023.0f);
|
||||
@@ -232,6 +288,24 @@ namespace renderdocui.Code
|
||||
else if (format.compByteWidth == 1)
|
||||
ret.Add((uint)read.ReadByte());
|
||||
}
|
||||
else if (format.compType == FormatComponentType.UScaled)
|
||||
{
|
||||
if (format.compByteWidth == 4)
|
||||
ret.Add((float)read.ReadUInt32());
|
||||
else if (format.compByteWidth == 2)
|
||||
ret.Add((float)read.ReadUInt16());
|
||||
else if (format.compByteWidth == 1)
|
||||
ret.Add((float)read.ReadByte());
|
||||
}
|
||||
else if (format.compType == FormatComponentType.SScaled)
|
||||
{
|
||||
if (format.compByteWidth == 4)
|
||||
ret.Add((float)read.ReadInt32());
|
||||
else if (format.compByteWidth == 2)
|
||||
ret.Add((float)read.ReadInt16());
|
||||
else if (format.compByteWidth == 1)
|
||||
ret.Add((float)read.ReadSByte());
|
||||
}
|
||||
else if (format.compType == FormatComponentType.Depth)
|
||||
{
|
||||
float f = (float)read.ReadUInt32();
|
||||
|
||||
@@ -181,6 +181,14 @@ namespace renderdoc
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
else if (compType == FormatComponentType.SScaled)
|
||||
{
|
||||
return (float)((Int16)comp);
|
||||
}
|
||||
else if (compType == FormatComponentType.UScaled)
|
||||
{
|
||||
return (float)comp;
|
||||
}
|
||||
else if (compType == FormatComponentType.UNorm)
|
||||
{
|
||||
return (float)comp / (float)UInt16.MaxValue;
|
||||
@@ -214,6 +222,14 @@ namespace renderdoc
|
||||
{
|
||||
return comp;
|
||||
}
|
||||
else if (compType == FormatComponentType.SScaled)
|
||||
{
|
||||
return (float)((sbyte)comp);
|
||||
}
|
||||
else if (compType == FormatComponentType.UScaled)
|
||||
{
|
||||
return (float)comp;
|
||||
}
|
||||
else if (compType == FormatComponentType.UNorm)
|
||||
{
|
||||
return ((float)comp) / 255.0f;
|
||||
|
||||
@@ -236,9 +236,9 @@ namespace renderdoc
|
||||
|
||||
if (compType == FormatComponentType.Float)
|
||||
ret += "float";
|
||||
else if (compType == FormatComponentType.UInt)
|
||||
else if (compType == FormatComponentType.UInt || compType == FormatComponentType.UScaled)
|
||||
ret += "uint";
|
||||
else if (compType == FormatComponentType.SInt)
|
||||
else if (compType == FormatComponentType.SInt || compType == FormatComponentType.SScaled)
|
||||
ret += "int";
|
||||
else if (compType == FormatComponentType.UNorm)
|
||||
ret += "unorm float";
|
||||
|
||||
Reference in New Issue
Block a user