mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-29 21:30:53 +00:00
Add ability to view buffer elements as hex with xint/xshort/xbyte
This commit is contained in:
@@ -148,7 +148,7 @@ namespace renderdoc
|
||||
return Maths_HalfToFloat(comp);
|
||||
}
|
||||
|
||||
public string Interpret(UInt32 comp)
|
||||
public string Interpret(UInt32 comp, bool hex)
|
||||
{
|
||||
if (compByteWidth != 4 || compType == FormatComponentType.Float) throw new ArgumentException();
|
||||
|
||||
@@ -159,13 +159,13 @@ namespace renderdoc
|
||||
}
|
||||
else if (compType == FormatComponentType.UInt)
|
||||
{
|
||||
return String.Format("{0}", comp);
|
||||
return String.Format(hex ? "{0:X8}" : "{0}", comp);
|
||||
}
|
||||
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public string Interpret(UInt16 comp)
|
||||
public string Interpret(UInt16 comp, bool hex)
|
||||
{
|
||||
if (compByteWidth != 2 || compType == FormatComponentType.Float) throw new ArgumentException();
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace renderdoc
|
||||
}
|
||||
else if (compType == FormatComponentType.UInt)
|
||||
{
|
||||
return String.Format("{0}", comp);
|
||||
return String.Format(hex ? "{0:X4}" : "{0}", comp);
|
||||
}
|
||||
else if (compType == FormatComponentType.UNorm)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ namespace renderdoc
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
public string Interpret(byte comp)
|
||||
public string Interpret(byte comp, bool hex)
|
||||
{
|
||||
if (compByteWidth != 1 || compType == FormatComponentType.Float) throw new ArgumentException();
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace renderdoc
|
||||
}
|
||||
else if (compType == FormatComponentType.UInt)
|
||||
{
|
||||
return String.Format("{0}", comp);
|
||||
return String.Format(hex ? "{0:X2}" : "{0}", comp);
|
||||
}
|
||||
else if (compType == FormatComponentType.UNorm)
|
||||
{
|
||||
|
||||
@@ -639,7 +639,11 @@ namespace renderdocui.Windows
|
||||
@"uintten|unormten" +
|
||||
@"|unormh|unormb" +
|
||||
@"|snormh|snormb" +
|
||||
@"|bool|byte|ubyte|short|ushort|int|uint|half|float|double" + // basic types last since they're most the most common match
|
||||
@"|bool" + // bool is stored as 4-byte int in hlsl
|
||||
@"|byte|short|int" + // signed ints
|
||||
@"|ubyte|ushort|uint" + // unsigned ints
|
||||
@"|xbyte|xshort|xint" + // hex ints
|
||||
@"|half|float|double" + // float types
|
||||
@")" +
|
||||
@"([1-9])?" + // might be a vector
|
||||
@"(x[1-9])?" + // or a matrix
|
||||
@@ -701,6 +705,8 @@ namespace renderdocui.Windows
|
||||
|
||||
ResourceFormat fmt = new ResourceFormat(FormatComponentType.None, 0, 0);
|
||||
|
||||
bool hex = false;
|
||||
|
||||
FormatComponentType type = FormatComponentType.Float;
|
||||
uint count = 0;
|
||||
uint arrayCount = 1;
|
||||
@@ -737,7 +743,7 @@ namespace renderdocui.Windows
|
||||
type = FormatComponentType.SInt;
|
||||
width = 1;
|
||||
}
|
||||
else if (basetype == "ubyte")
|
||||
else if (basetype == "ubyte" || basetype == "xbyte")
|
||||
{
|
||||
type = FormatComponentType.UInt;
|
||||
width = 1;
|
||||
@@ -747,7 +753,7 @@ namespace renderdocui.Windows
|
||||
type = FormatComponentType.SInt;
|
||||
width = 2;
|
||||
}
|
||||
else if (basetype == "ushort")
|
||||
else if (basetype == "ushort" || basetype == "xshort")
|
||||
{
|
||||
type = FormatComponentType.UInt;
|
||||
width = 2;
|
||||
@@ -757,7 +763,7 @@ namespace renderdocui.Windows
|
||||
type = FormatComponentType.SInt;
|
||||
width = 4;
|
||||
}
|
||||
else if (basetype == "uint")
|
||||
else if (basetype == "uint" || basetype == "xint")
|
||||
{
|
||||
type = FormatComponentType.UInt;
|
||||
width = 4;
|
||||
@@ -817,10 +823,13 @@ namespace renderdocui.Windows
|
||||
}
|
||||
}
|
||||
|
||||
if (basetype == "xint" || basetype == "xshort" || basetype == "xbyte")
|
||||
hex = true;
|
||||
|
||||
if(fmt.compType == FormatComponentType.None)
|
||||
fmt = new ResourceFormat(type, count * arrayCount, width);
|
||||
|
||||
FormatElement elem = new FormatElement(name, 0, input.Strides[0], false, row_major, matrixCount, fmt);
|
||||
FormatElement elem = new FormatElement(name, 0, input.Strides[0], false, row_major, matrixCount, fmt, hex);
|
||||
|
||||
elems.Add(elem);
|
||||
input.Strides[0] += elem.ByteSize;
|
||||
@@ -832,7 +841,7 @@ namespace renderdocui.Windows
|
||||
|
||||
var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4);
|
||||
|
||||
elems.Add(new FormatElement("data", 0, input.Strides[0], false, false, 1, fmt));
|
||||
elems.Add(new FormatElement("data", 0, input.Strides[0], false, false, 1, fmt, true));
|
||||
input.Strides[0] = elems.Last().ByteSize;
|
||||
}
|
||||
|
||||
@@ -949,7 +958,8 @@ namespace renderdocui.Windows
|
||||
a.PerInstance,
|
||||
false, // row major matrix
|
||||
1, // matrix dimension
|
||||
a.Format);
|
||||
a.Format,
|
||||
false);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -971,7 +981,7 @@ namespace renderdocui.Windows
|
||||
ret.Offsets = o;
|
||||
ret.Buffers = bs;
|
||||
|
||||
ret.IndexFormat = new FormatElement("", 0, 0, false, false, 1, ifmt);
|
||||
ret.IndexFormat = new FormatElement("", 0, 0, false, false, 1, ifmt, false);
|
||||
ret.IndexBuffer = ibuffer;
|
||||
ret.IndexOffset = ioffset;
|
||||
|
||||
@@ -1660,10 +1670,10 @@ namespace renderdocui.Windows
|
||||
byte r = read.ReadByte();
|
||||
byte a = read.ReadByte();
|
||||
|
||||
rowdata[x+0] = fmt.Interpret(r);
|
||||
rowdata[x+1] = fmt.Interpret(g);
|
||||
rowdata[x+2] = fmt.Interpret(b);
|
||||
rowdata[x+3] = fmt.Interpret(a);
|
||||
rowdata[x + 0] = fmt.Interpret(r, false);
|
||||
rowdata[x + 1] = fmt.Interpret(g, false);
|
||||
rowdata[x + 2] = fmt.Interpret(b, false);
|
||||
rowdata[x + 3] = fmt.Interpret(a, false);
|
||||
x += 4;
|
||||
}
|
||||
else if (fmt.special && fmt.specialFormat == SpecialFormat.B5G5R5A1)
|
||||
@@ -1757,11 +1767,11 @@ namespace renderdocui.Windows
|
||||
else
|
||||
{
|
||||
if (fmt.compByteWidth == 4)
|
||||
arr[i] = fmt.Interpret(read.ReadUInt32());
|
||||
arr[i] = fmt.Interpret(read.ReadUInt32(), bufferFormats[el].hex);
|
||||
else if (fmt.compByteWidth == 2)
|
||||
arr[i] = fmt.Interpret(read.ReadUInt16());
|
||||
arr[i] = fmt.Interpret(read.ReadUInt16(), bufferFormats[el].hex);
|
||||
else if (fmt.compByteWidth == 1)
|
||||
arr[i] = fmt.Interpret(read.ReadByte());
|
||||
arr[i] = fmt.Interpret(read.ReadByte(), bufferFormats[el].hex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1797,11 +1807,11 @@ namespace renderdocui.Windows
|
||||
for (int i = 0; i < fmt.compCount; i++, x++)
|
||||
{
|
||||
if (fmt.compByteWidth == 4)
|
||||
rowdata[x] = fmt.Interpret(read.ReadUInt32());
|
||||
rowdata[x] = fmt.Interpret(read.ReadUInt32(), bufferFormats[el].hex);
|
||||
else if (fmt.compByteWidth == 2)
|
||||
rowdata[x] = fmt.Interpret(read.ReadUInt16());
|
||||
rowdata[x] = fmt.Interpret(read.ReadUInt16(), bufferFormats[el].hex);
|
||||
else if (fmt.compByteWidth == 1)
|
||||
rowdata[x] = fmt.Interpret(read.ReadByte());
|
||||
rowdata[x] = fmt.Interpret(read.ReadByte(), bufferFormats[el].hex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2754,9 +2764,10 @@ namespace renderdocui.Windows
|
||||
rowmajor = false;
|
||||
matrixdim = 0;
|
||||
format = new ResourceFormat();
|
||||
hex = false;
|
||||
}
|
||||
|
||||
public FormatElement(string Name, int buf, uint offs, bool pi, bool rowMat, uint matDim, ResourceFormat fmt)
|
||||
public FormatElement(string Name, int buf, uint offs, bool pi, bool rowMat, uint matDim, ResourceFormat fmt, bool h)
|
||||
{
|
||||
name = Name;
|
||||
buffer = buf;
|
||||
@@ -2765,6 +2776,7 @@ namespace renderdocui.Windows
|
||||
perinstance = pi;
|
||||
rowmajor = rowMat;
|
||||
matrixdim = matDim;
|
||||
hex = h;
|
||||
}
|
||||
|
||||
public uint ByteSize
|
||||
@@ -2782,6 +2794,7 @@ namespace renderdocui.Windows
|
||||
public bool rowmajor;
|
||||
public uint matrixdim;
|
||||
public ResourceFormat format;
|
||||
public bool hex;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+12
-10
@@ -45,9 +45,9 @@
|
||||
//
|
||||
groupBox1.Controls.Add(this.formatText);
|
||||
groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
groupBox1.Location = new System.Drawing.Point(3, 117);
|
||||
groupBox1.Location = new System.Drawing.Point(3, 195);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new System.Drawing.Size(650, 141);
|
||||
groupBox1.Size = new System.Drawing.Size(571, 102);
|
||||
groupBox1.TabIndex = 0;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Format";
|
||||
@@ -60,7 +60,7 @@
|
||||
this.formatText.Multiline = true;
|
||||
this.formatText.Name = "formatText";
|
||||
this.formatText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.formatText.Size = new System.Drawing.Size(644, 122);
|
||||
this.formatText.Size = new System.Drawing.Size(565, 83);
|
||||
this.formatText.TabIndex = 0;
|
||||
this.formatText.Text = "float4 asd; // blah blah\r\nfloat3 bar;";
|
||||
this.formatText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.formatText_KeyDown);
|
||||
@@ -68,35 +68,36 @@
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
this.tableLayoutPanel1.SetColumnSpan(label1, 2);
|
||||
label1.Location = new System.Drawing.Point(8, 8);
|
||||
label1.Margin = new System.Windows.Forms.Padding(8);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new System.Drawing.Size(549, 52);
|
||||
label1.Size = new System.Drawing.Size(517, 130);
|
||||
label1.TabIndex = 1;
|
||||
label1.Text = resources.GetString("label1.Text");
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 1;
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel1.Controls.Add(groupBox1, 0, 2);
|
||||
this.tableLayoutPanel1.Controls.Add(label1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.apply, 0, 3);
|
||||
this.tableLayoutPanel1.Controls.Add(this.errors, 0, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.apply, 1, 2);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 4;
|
||||
this.tableLayoutPanel1.RowCount = 3;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(656, 300);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// apply
|
||||
//
|
||||
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.apply.Location = new System.Drawing.Point(585, 269);
|
||||
this.apply.Margin = new System.Windows.Forms.Padding(8);
|
||||
this.apply.Name = "apply";
|
||||
@@ -108,10 +109,11 @@
|
||||
//
|
||||
// errors
|
||||
//
|
||||
this.tableLayoutPanel1.SetColumnSpan(this.errors, 2);
|
||||
this.errors.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.errors.Font = new System.Drawing.Font("Microsoft Sans Serif", 14.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.errors.ForeColor = System.Drawing.Color.DarkRed;
|
||||
this.errors.Location = new System.Drawing.Point(3, 68);
|
||||
this.errors.Location = new System.Drawing.Point(3, 146);
|
||||
this.errors.Name = "errors";
|
||||
this.errors.Size = new System.Drawing.Size(650, 46);
|
||||
this.errors.TabIndex = 3;
|
||||
|
||||
@@ -124,9 +124,15 @@
|
||||
<value>False</value>
|
||||
</metadata>
|
||||
<data name="label1.Text" xml:space="preserve">
|
||||
<value>Type in a buffer format specifier. Comments and {} braces are skipped, : semantics are ignored.
|
||||
Basic types accepted: bool, byte, ubyte, short, ushort, int, uint, half, float, double.
|
||||
<value>Type in a buffer format declaration. Comments and {} braces are skipped, : semantics are ignored.
|
||||
Declare each element as an hlsl variable, e.g: "float4 first; float2 second; uint2 third;"
|
||||
|
||||
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)
|
||||
|
||||
Vectors (e.g. float4) and matrices ([rowmajor] half3x4) are supported. Arrays (float[16]) are not supported.</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user