Allow using hex formatting strings for custom constant buffer layouts

This commit is contained in:
baldurk
2016-11-02 13:59:32 +01:00
parent c2103ed2ba
commit 567a236034
3 changed files with 30 additions and 10 deletions
+2
View File
@@ -383,6 +383,8 @@ namespace renderdocui.Code
ret.columns = Math.Min(format.compCount, 4);
ret.rows = Math.Min(matrixdim, 4);
ret.displayAsHex = hex;
ret.members = new ShaderVariable[0] { };
ret.value.fv = new float[16];
+5
View File
@@ -53,6 +53,11 @@ namespace renderdoc
return String.Format("{0}", u);
}
public static String Format(UInt32 u, bool hex)
{
return String.Format(hex ? "{0:X8}" : "{0}", u);
}
public static String Format(Int32 i)
{
return String.Format("{0}", i);
+23 -10
View File
@@ -38,6 +38,9 @@ namespace renderdoc
public VarType type;
[CustomMarshalAs(CustomUnmanagedType.Skip)]
public bool displayAsHex = false;
[StructLayout(LayoutKind.Sequential)]
public struct ValueUnion
{
@@ -91,10 +94,15 @@ namespace renderdoc
if (rows == 0 && columns == 0)
return "-";
if (columns == 1)
return type.Str();
string typeStr = type.Str();
return String.Format("{0}{1}", type.Str(), columns);
if(displayAsHex && type == VarType.UInt)
typeStr = "xint";
if (columns == 1)
return typeStr;
return String.Format("{0}{1}", typeStr, columns);
}
public string TypeString()
@@ -107,9 +115,14 @@ namespace renderdoc
return String.Format("{0}[{1}]", members[0].TypeString(), members.Length);
}
if (rows == 1 && columns == 1) return type.Str();
if (rows == 1) return String.Format("{0}{1}", type.Str(), columns);
else return String.Format("{0}{1}x{2}", type.Str(), rows, columns);
string typeStr = type.Str();
if (displayAsHex && type == VarType.UInt)
typeStr = "xint";
if (rows == 1 && columns == 1) return typeStr;
if (rows == 1) return String.Format("{0}{1}", typeStr, columns);
else return String.Format("{0}{1}x{2}", typeStr, rows, columns);
}
public string RowValuesToString(int cols, double x, double y, double z, double w)
@@ -130,10 +143,10 @@ namespace renderdoc
public string RowValuesToString(int cols, UInt32 x, UInt32 y, UInt32 z, UInt32 w)
{
if (cols == 1) return Formatter.Format(x);
else if (cols == 2) return Formatter.Format(x) + ", " + Formatter.Format(y);
else if (cols == 3) return Formatter.Format(x) + ", " + Formatter.Format(y) + ", " + Formatter.Format(z);
else return Formatter.Format(x) + ", " + Formatter.Format(y) + ", " + Formatter.Format(z) + ", " + Formatter.Format(w);
if (cols == 1) return Formatter.Format(x, displayAsHex);
else if (cols == 2) return Formatter.Format(x, displayAsHex) + ", " + Formatter.Format(y, displayAsHex);
else if (cols == 3) return Formatter.Format(x, displayAsHex) + ", " + Formatter.Format(y, displayAsHex) + ", " + Formatter.Format(z, displayAsHex);
else return Formatter.Format(x, displayAsHex) + ", " + Formatter.Format(y, displayAsHex) + ", " + Formatter.Format(z, displayAsHex) + ", " + Formatter.Format(w, displayAsHex);
}
public string RowValuesToString(int cols, Int32 x, Int32 y, Int32 z, Int32 w)