diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs new file mode 100644 index 000000000..0e4eea425 --- /dev/null +++ b/renderdocui/Code/FormatElement.cs @@ -0,0 +1,544 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Baldur Karlsson + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + ******************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Text.RegularExpressions; +using renderdoc; + +namespace renderdocui.Code +{ + public class FormatElement + { + public FormatElement() + { + name = ""; + buffer = 0; + offset = 0; + perinstance = false; + rowmajor = false; + matrixdim = 0; + format = new ResourceFormat(); + hex = false; + } + + public FormatElement(string Name, int buf, uint offs, bool pi, bool rowMat, uint matDim, ResourceFormat f, bool h) + { + name = Name; + buffer = buf; + offset = offs; + format = f; + perinstance = pi; + rowmajor = rowMat; + matrixdim = matDim; + hex = h; + } + + public uint ByteSize + { + get + { + return format.compByteWidth * format.compCount * matrixdim; + } + } + + public object[] GetObjects(BinaryReader read) + { + var ret = new List(); + + if (format.special && format.specialFormat == SpecialFormat.B8G8R8A8) + { + byte b = read.ReadByte(); + byte g = read.ReadByte(); + byte r = read.ReadByte(); + byte a = read.ReadByte(); + + ret.Add((float)r / 255.0f); + ret.Add((float)g / 255.0f); + ret.Add((float)b / 255.0f); + ret.Add((float)a / 255.0f); + } + else if (format.special && format.specialFormat == SpecialFormat.B5G5R5A1) + { + ushort packed = read.ReadUInt16(); + + ret.Add((float)((packed >> 10) & 0x1f) / 31.0f); + ret.Add((float)((packed >> 5) & 0x1f) / 31.0f); + ret.Add((float)((packed >> 0) & 0x1f) / 31.0f); + ret.Add(((packed & 0x8000) > 0) ? 1.0f : 0.0f); + } + else if (format.special && format.specialFormat == SpecialFormat.B5G6R5) + { + ushort packed = read.ReadUInt16(); + + ret.Add((float)((packed >> 11) & 0x1f) / 31.0f); + ret.Add((float)((packed >> 5) & 0x3f) / 63.0f); + ret.Add((float)((packed >> 0) & 0x1f) / 31.0f); + } + else if (format.special && format.specialFormat == SpecialFormat.B4G4R4A4) + { + ushort packed = read.ReadUInt16(); + + ret.Add((float)((packed >> 8) & 0xf) / 15.0f); + ret.Add((float)((packed >> 4) & 0xf) / 15.0f); + ret.Add((float)((packed >> 0) & 0xf) / 15.0f); + ret.Add((float)((packed >> 12) & 0xf) / 15.0f); + } + else if (format.special && format.specialFormat == SpecialFormat.R10G10B10A2) + { + // allow for vectors of this format - for raw buffer viewer + for (int i = 0; i < (format.compCount / 4); i++) + { + uint packed = read.ReadUInt32(); + + uint r = (packed >> 0) & 0x3ff; + uint g = (packed >> 10) & 0x3ff; + uint b = (packed >> 20) & 0x3ff; + uint a = (packed >> 30) & 0x003; + + if (format.compType == FormatComponentType.UInt) + { + ret.Add(r); + ret.Add(g); + ret.Add(b); + ret.Add(a); + } + else + { + ret.Add((float)r / 1023.0f); + ret.Add((float)g / 1023.0f); + ret.Add((float)b / 1023.0f); + ret.Add((float)a / 3.0f); + } + } + } + else if (format.special && format.specialFormat == SpecialFormat.R11G11B10) + { + 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); + + 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)); + } + else + { + int dim = (int)(Math.Max(matrixdim, 1) * format.compCount); + + for (int i = 0; i < dim; i++) + { + if (format.compType == FormatComponentType.Float) + { + if (format.compByteWidth == 4) + ret.Add(read.ReadSingle()); + else if (format.compByteWidth == 2) + ret.Add(format.ConvertFromHalf(read.ReadUInt16())); + } + else if (format.compType == FormatComponentType.SInt) + { + if (format.compByteWidth == 4) + ret.Add((int)read.ReadInt32()); + else if (format.compByteWidth == 2) + ret.Add((int)read.ReadInt16()); + else if (format.compByteWidth == 1) + ret.Add((int)read.ReadSByte()); + } + else if (format.compType == FormatComponentType.UInt) + { + if (format.compByteWidth == 4) + ret.Add((uint)read.ReadUInt32()); + else if (format.compByteWidth == 2) + ret.Add((uint)read.ReadUInt16()); + else if (format.compByteWidth == 1) + ret.Add((uint)read.ReadByte()); + } + else if (format.compType == FormatComponentType.Depth) + { + float f = (float)read.ReadUInt32(); + if (format.compByteWidth == 4) + ret.Add(f / (float)uint.MaxValue); + else if (format.compByteWidth == 3) + ret.Add(f / (float)0x00ffffff); + else if (format.compByteWidth == 2) + ret.Add(f / (float)0xffff); + } + else if (format.compType == FormatComponentType.Double) + { + // should never hit this! just read a float + ret.Add(read.ReadSingle()); + renderdoc.StaticExports.LogText("Unexpected double FormatElement"); + } + else + { + // unorm/snorm + + if (format.compByteWidth == 4) + { + renderdoc.StaticExports.LogText("Unexpected 4-byte unorm/snorm value"); + ret.Add((float)read.ReadUInt32() / (float)uint.MaxValue); // should never hit this - no 32bit unorm/snorm type + } + else if (format.compByteWidth == 2) + { + ret.Add(format.Interpret(read.ReadUInt16())); + } + else if (format.compByteWidth == 1) + { + ret.Add(format.Interpret(read.ReadByte())); + } + } + } + } + + return ret.ToArray(); + } + + public ShaderVariable GetShaderVar(BinaryReader read) + { + object[] objs = GetObjects(read); + + ShaderVariable ret = new ShaderVariable(); + + ret.name = name; + ret.type = VarType.Float; + if (format.compType == FormatComponentType.UInt) + ret.type = VarType.UInt; + if (format.compType == FormatComponentType.SInt) + ret.type = VarType.Int; + if (format.compType == FormatComponentType.Double) + ret.type = VarType.Double; + + ret.columns = Math.Min(format.compCount, 4); + ret.rows = Math.Min(matrixdim, 4); + + ret.members = new ShaderVariable[0] { }; + + ret.value.fv = new float[16]; + ret.value.uv = new uint[16]; + ret.value.iv = new int[16]; + + for (uint row = 0; row < ret.rows; row++) + { + for (uint col = 0; col < ret.columns; col++) + { + uint dst = row * ret.columns + col; + uint src = row * format.compCount + col; + + object o = objs[src]; + + if (o is float) + ret.value.fv[dst] = (float)o; + else if (o is uint) + ret.value.uv[dst] = (uint)o; + else if (o is int) + ret.value.iv[dst] = (int)o; + } + } + + return ret; + } + + static public FormatElement[] ParseFormatString(string formatString, bool tightPacking, out string errors) + { + var elems = new List(); + + var formatReader = new StringReader(formatString); + + // regex doesn't account for trailing or preceeding whitespace, or comments + + var regExpr = @"^(row_major\s+)?" + // row_major matrix + @"(" + + @"uintten|unormten" + + @"|unormh|unormb" + + @"|snormh|snormb" + + @"|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 + @"(\s+[A-Za-z_][A-Za-z0-9_]*)?" + // get identifier name + @"(\[[0-9]+\])?" + // optional array dimension + @"(\s*:\s*[A-Za-z_][A-Za-z0-9_]*)?" + // optional semantic + @"$"; + + Regex regParser = new Regex(regExpr, RegexOptions.Compiled); + + bool success = true; + errors = ""; + + var text = formatReader.ReadToEnd(); + + text = text.Replace("{", "").Replace("}", ""); + + Regex c_comments = new Regex(@"/\*[^*]*\*+(?:[^*/][^*]*\*+)*/", RegexOptions.Compiled); + text = c_comments.Replace(text, ""); + + Regex cpp_comments = new Regex(@"//.*", RegexOptions.Compiled); + text = cpp_comments.Replace(text, ""); + + uint offset = 0; + + // get each line and parse it to determine the format the user wanted + foreach (var l in text.Split(';')) + { + var line = l; + line = line.Trim(); + + if (line == "") continue; + + var match = regParser.Match(line); + + if (!match.Success) + { + errors = "Couldn't parse line:\n" + line; + success = false; + break; + } + + var basetype = match.Groups[2].Value; + bool row_major = match.Groups[1].Success; + var vectorDim = match.Groups[3].Success ? match.Groups[3].Value : "1"; + var matrixDim = match.Groups[4].Success ? match.Groups[4].Value.Substring(1) : "1"; + var name = match.Groups[5].Success ? match.Groups[5].Value.Trim() : "data"; + var arrayDim = match.Groups[6].Success ? match.Groups[6].Value.Trim() : "[1]"; + arrayDim = arrayDim.Substring(1, arrayDim.Length - 2); + + if (match.Groups[4].Success) + { + var a = vectorDim; + vectorDim = matrixDim; + matrixDim = a; + } + + ResourceFormat fmt = new ResourceFormat(FormatComponentType.None, 0, 0); + + bool hex = false; + + FormatComponentType type = FormatComponentType.Float; + uint count = 0; + uint arrayCount = 1; + uint matrixCount = 0; + uint width = 0; + + // calculate format + { + if (!uint.TryParse(vectorDim, out count)) + { + errors = "Invalid vector dimension on line:\n" + line; + success = false; + break; + } + if (!uint.TryParse(arrayDim, out arrayCount)) + { + arrayCount = 1; + } + arrayCount = Math.Max(0, arrayCount); + if (!uint.TryParse(matrixDim, out matrixCount)) + { + errors = "Invalid matrix second dimension on line:\n" + line; + success = false; + break; + } + + if (basetype == "bool") + { + type = FormatComponentType.UInt; + width = 4; + } + else if (basetype == "byte") + { + type = FormatComponentType.SInt; + width = 1; + } + else if (basetype == "ubyte" || basetype == "xbyte") + { + type = FormatComponentType.UInt; + width = 1; + } + else if (basetype == "short") + { + type = FormatComponentType.SInt; + width = 2; + } + else if (basetype == "ushort" || basetype == "xshort") + { + type = FormatComponentType.UInt; + width = 2; + } + else if (basetype == "int") + { + type = FormatComponentType.SInt; + width = 4; + } + else if (basetype == "uint" || basetype == "xint") + { + type = FormatComponentType.UInt; + width = 4; + } + else if (basetype == "half") + { + type = FormatComponentType.Float; + width = 2; + } + else if (basetype == "float") + { + type = FormatComponentType.Float; + width = 4; + } + else if (basetype == "double") + { + type = FormatComponentType.Float; + width = 8; + } + else if (basetype == "unormh") + { + type = FormatComponentType.UNorm; + width = 2; + } + else if (basetype == "unormb") + { + type = FormatComponentType.UNorm; + width = 1; + } + else if (basetype == "snormh") + { + type = FormatComponentType.SNorm; + width = 2; + } + else if (basetype == "snormb") + { + type = FormatComponentType.SNorm; + width = 1; + } + else if (basetype == "uintten") + { + fmt = new ResourceFormat(FormatComponentType.UInt, 4 * count, 1); + fmt.special = true; + fmt.specialFormat = SpecialFormat.R10G10B10A2; + } + else if (basetype == "unormten") + { + fmt = new ResourceFormat(FormatComponentType.UNorm, 4 * count, 1); + fmt.special = true; + fmt.specialFormat = SpecialFormat.R10G10B10A2; + } + else + { + errors = "Unrecognised basic type on line:\n" + line; + success = false; + break; + } + } + + if (basetype == "xint" || basetype == "xshort" || basetype == "xbyte") + hex = true; + + if (fmt.compType == FormatComponentType.None) + fmt = new ResourceFormat(type, count, width); + + if (arrayCount == 1) + { + FormatElement elem = new FormatElement(name, 0, offset, false, row_major, matrixCount, fmt, hex); + + uint advance = elem.ByteSize; + + if (!tightPacking) + { + // cbuffer packing always works in floats + advance = (advance + 3U) & (~3U); + + // cbuffer packing doesn't allow elements to cross float4 boundaries, nudge up if this was the case + if (offset / 16 != (offset + elem.ByteSize - 1) / 16) + { + elem.offset = offset = (offset + 0xFU) & (~0xFU); + } + } + + elems.Add(elem); + + offset += advance; + } + else + { + // when cbuffer packing, arrays are always aligned at float4 boundary + if (!tightPacking) + { + if (offset % 16 != 0) + { + offset = (offset + 0xFU) & (~0xFU); + } + } + + for (uint a = 0; a < arrayCount; a++) + { + FormatElement elem = new FormatElement(String.Format("{0}[{1}]", name, a), 0, offset, false, row_major, matrixCount, fmt, hex); + + elems.Add(elem); + + uint advance = elem.ByteSize; + + // cbuffer packing each array element is always float4 aligned + if (!tightPacking) + { + advance = (advance + 0xFU) & (~0xFU); + } + + offset += advance; + } + } + } + + if (!success || elems.Count == 0) + { + elems.Clear(); + + var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4); + + elems.Add(new FormatElement("data", 0, 0, false, false, 1, fmt, true)); + } + + return elems.ToArray(); + } + + public string name; + public int buffer; + public uint offset; + public bool perinstance; + public bool rowmajor; + public uint matrixdim; + public ResourceFormat format; + public bool hex; + } +} diff --git a/renderdocui/Controls/BufferFormatSpecifier.Designer.cs b/renderdocui/Controls/BufferFormatSpecifier.Designer.cs new file mode 100644 index 000000000..0416990b9 --- /dev/null +++ b/renderdocui/Controls/BufferFormatSpecifier.Designer.cs @@ -0,0 +1,156 @@ +namespace renderdocui.Windows.Dialogs +{ + partial class BufferFormatSpecifier + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.GroupBox groupBox1; + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BufferFormatSpecifier)); + this.formatText = new System.Windows.Forms.TextBox(); + this.helpText = new System.Windows.Forms.Label(); + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.errors = new System.Windows.Forms.Label(); + this.apply = new System.Windows.Forms.Button(); + this.hideHelp = new System.Windows.Forms.Button(); + groupBox1 = new System.Windows.Forms.GroupBox(); + groupBox1.SuspendLayout(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // groupBox1 + // + groupBox1.Controls.Add(this.formatText); + groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; + groupBox1.Location = new System.Drawing.Point(3, 195); + groupBox1.Name = "groupBox1"; + groupBox1.Size = new System.Drawing.Size(556, 227); + groupBox1.TabIndex = 0; + groupBox1.TabStop = false; + groupBox1.Text = "Format"; + // + // formatText + // + this.formatText.Dock = System.Windows.Forms.DockStyle.Fill; + this.formatText.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.formatText.Location = new System.Drawing.Point(3, 16); + this.formatText.Multiline = true; + this.formatText.Name = "formatText"; + this.formatText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; + this.formatText.Size = new System.Drawing.Size(550, 208); + 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); + // + // helpText + // + this.helpText.AutoSize = true; + this.helpText.Location = new System.Drawing.Point(8, 8); + this.helpText.Margin = new System.Windows.Forms.Padding(8); + this.helpText.Name = "helpText"; + this.helpText.Size = new System.Drawing.Size(517, 130); + this.helpText.TabIndex = 1; + this.helpText.Text = resources.GetString("helpText.Text"); + // + // tableLayoutPanel1 + // + 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(this.helpText, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.errors, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.apply, 1, 2); + this.tableLayoutPanel1.Controls.Add(this.hideHelp, 1, 0); + this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + 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.Size = new System.Drawing.Size(643, 425); + this.tableLayoutPanel1.TabIndex = 0; + // + // 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, 146); + this.errors.Name = "errors"; + this.errors.Size = new System.Drawing.Size(637, 46); + this.errors.TabIndex = 3; + // + // apply + // + this.apply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.apply.Location = new System.Drawing.Point(572, 394); + this.apply.Margin = new System.Windows.Forms.Padding(8); + this.apply.Name = "apply"; + this.apply.Size = new System.Drawing.Size(63, 23); + this.apply.TabIndex = 1; + this.apply.Text = "Apply"; + this.apply.UseVisualStyleBackColor = true; + this.apply.Click += new System.EventHandler(this.apply_Click); + // + // hideHelp + // + this.hideHelp.Location = new System.Drawing.Point(565, 3); + this.hideHelp.Name = "hideHelp"; + this.hideHelp.Size = new System.Drawing.Size(75, 23); + this.hideHelp.TabIndex = 4; + this.hideHelp.Text = "Hide Help"; + this.hideHelp.UseVisualStyleBackColor = true; + this.hideHelp.Click += new System.EventHandler(this.hideHelp_Click); + // + // BufferFormatSpecifier + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.tableLayoutPanel1); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "BufferFormatSpecifier"; + this.Size = new System.Drawing.Size(643, 425); + groupBox1.ResumeLayout(false); + groupBox1.PerformLayout(); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.TextBox formatText; + private System.Windows.Forms.Button apply; + private System.Windows.Forms.Label errors; + private System.Windows.Forms.Button hideHelp; + private System.Windows.Forms.Label helpText; + } +} \ No newline at end of file diff --git a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.cs b/renderdocui/Controls/BufferFormatSpecifier.cs similarity index 83% rename from renderdocui/Windows/Dialogs/BufferFormatSpecifier.cs rename to renderdocui/Controls/BufferFormatSpecifier.cs index 2267f9669..1e99321c5 100644 --- a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.cs +++ b/renderdocui/Controls/BufferFormatSpecifier.cs @@ -36,26 +36,26 @@ using renderdoc; namespace renderdocui.Windows.Dialogs { - public partial class BufferFormatSpecifier : DockContent + public partial class BufferFormatSpecifier : UserControl { - BufferViewer m_Viewer = null; - ResourceId m_Buffer = ResourceId.Null; + IBufferFormatProcessor m_Viewer = null; - public BufferFormatSpecifier(BufferViewer viewer, ResourceId buff, string format) + public BufferFormatSpecifier(IBufferFormatProcessor viewer, string format) { InitializeComponent(); // WHY THE HELL do you require \r\n in text boxes? formatText.Text = format.Replace("\r\n", "\n").Replace("\n", Environment.NewLine); + errors.Visible = false; + m_Viewer = viewer; - m_Buffer = buff; } private void apply_Click(object sender, EventArgs e) { SetErrors(""); - m_Viewer.ViewRawBuffer(m_Buffer, formatText.Text); + m_Viewer.ProcessBufferFormat(formatText.Text); } public void SetErrors(string err) @@ -75,5 +75,15 @@ namespace renderdocui.Windows.Dialogs formatText.SelectAll(); } } + + private void hideHelp_Click(object sender, EventArgs e) + { + helpText.Visible = !helpText.Visible; + } + } + + public interface IBufferFormatProcessor + { + void ProcessBufferFormat(string formatText); } } diff --git a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.resx b/renderdocui/Controls/BufferFormatSpecifier.resx similarity index 96% rename from renderdocui/Windows/Dialogs/BufferFormatSpecifier.resx rename to renderdocui/Controls/BufferFormatSpecifier.resx index 57a64d86c..758740bd4 100644 --- a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.resx +++ b/renderdocui/Controls/BufferFormatSpecifier.resx @@ -120,10 +120,7 @@ False - - False - - + 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;" diff --git a/renderdocui/Controls/ConstantBufferPreviewer.Designer.cs b/renderdocui/Controls/ConstantBufferPreviewer.Designer.cs deleted file mode 100644 index be32dce3d..000000000 --- a/renderdocui/Controls/ConstantBufferPreviewer.Designer.cs +++ /dev/null @@ -1,111 +0,0 @@ -namespace renderdocui.Controls -{ - partial class ConstantBufferPreviewer - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - #region Component Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - TreelistView.TreeListColumn treeListColumn1 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarName", "Name"))); - TreelistView.TreeListColumn treeListColumn2 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarValue", "Value"))); - TreelistView.TreeListColumn treeListColumn3 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarType", "Type"))); - this.slotLabel = new System.Windows.Forms.Label(); - this.nameLabel = new System.Windows.Forms.Label(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.variables = new TreelistView.TreeListView(); - this.tableLayoutPanel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.variables)).BeginInit(); - this.SuspendLayout(); - // - // slotLabel - // - this.slotLabel.AutoSize = true; - this.slotLabel.Location = new System.Drawing.Point(3, 0); - this.slotLabel.Name = "slotLabel"; - this.slotLabel.Padding = new System.Windows.Forms.Padding(5); - this.slotLabel.Size = new System.Drawing.Size(10, 23); - this.slotLabel.TabIndex = 0; - // - // nameLabel - // - this.nameLabel.AutoSize = true; - this.nameLabel.Location = new System.Drawing.Point(19, 0); - this.nameLabel.Name = "nameLabel"; - this.nameLabel.Padding = new System.Windows.Forms.Padding(5); - this.nameLabel.Size = new System.Drawing.Size(10, 23); - this.nameLabel.TabIndex = 1; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tableLayoutPanel1.Controls.Add(this.slotLabel, 0, 0); - this.tableLayoutPanel1.Controls.Add(this.nameLabel, 1, 0); - this.tableLayoutPanel1.Controls.Add(this.variables, 0, 1); - this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 2; - 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.Size = new System.Drawing.Size(499, 357); - this.tableLayoutPanel1.TabIndex = 0; - // - // variables - // - treeListColumn1.AutoSizeMinSize = 0; - treeListColumn1.Width = 175; - treeListColumn2.AutoSize = true; - treeListColumn2.AutoSizeMinSize = 0; - treeListColumn2.Width = 50; - treeListColumn3.AutoSizeMinSize = 0; - treeListColumn3.Width = 50; - this.variables.Columns.AddRange(new TreelistView.TreeListColumn[] { - treeListColumn1, - treeListColumn2, - treeListColumn3}); - this.variables.ColumnsOptions.LeftMargin = 0; - this.tableLayoutPanel1.SetColumnSpan(this.variables, 2); - this.variables.Cursor = System.Windows.Forms.Cursors.Arrow; - this.variables.Dock = System.Windows.Forms.DockStyle.Fill; - this.variables.Location = new System.Drawing.Point(3, 26); - this.variables.Name = "variables"; - this.variables.RowOptions.ShowHeader = false; - this.variables.Size = new System.Drawing.Size(493, 328); - this.variables.TabIndex = 2; - this.variables.Text = "treeListView1"; - this.variables.KeyDown += new System.Windows.Forms.KeyEventHandler(this.variables_KeyDown); - // - // ConstantBufferPreviewer - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.tableLayoutPanel1); - this.Name = "ConstantBufferPreviewer"; - this.Size = new System.Drawing.Size(499, 357); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.variables)).EndInit(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private TreelistView.TreeListView variables; - private System.Windows.Forms.Label slotLabel; - private System.Windows.Forms.Label nameLabel; - - } -} diff --git a/renderdocui/Interop/FetchInfo.cs b/renderdocui/Interop/FetchInfo.cs index 755c02a15..9398c91d0 100644 --- a/renderdocui/Interop/FetchInfo.cs +++ b/renderdocui/Interop/FetchInfo.cs @@ -148,45 +148,25 @@ namespace renderdoc return Maths_HalfToFloat(comp); } - public string Interpret(UInt32 comp, bool hex) - { - if (compByteWidth != 4 || compType == FormatComponentType.Float) throw new ArgumentException(); - - if (compType == FormatComponentType.SInt) - { - int cast = (int)comp; - return String.Format("{0}", cast); - } - else if (compType == FormatComponentType.UInt) - { - return String.Format(hex ? "{0:X8}" : "{0}", comp); - } - - throw new ArgumentException(); - } - - public string Interpret(UInt16 comp, bool hex) + public object Interpret(UInt16 comp) { if (compByteWidth != 2 || compType == FormatComponentType.Float) throw new ArgumentException(); if (compType == FormatComponentType.SInt) { - Int16 cast = (Int16)comp; - return String.Format("{0}", cast); + return (Int16)comp; } else if (compType == FormatComponentType.UInt) { - return String.Format(hex ? "{0:X4}" : "{0}", comp); + return comp; } else if (compType == FormatComponentType.UNorm) { - float f = (float)comp / (float)UInt16.MaxValue; - return Formatter.Format(f); + return (float)comp / (float)UInt16.MaxValue; } else if (compType == FormatComponentType.UNorm_SRGB) { - float f = (float)comp / (float)UInt16.MaxValue; - return Formatter.Format(f); + return (float)comp / (float)UInt16.MaxValue; } else if (compType == FormatComponentType.SNorm) { @@ -199,34 +179,31 @@ namespace renderdoc else f = ((float)cast) / 32767.0f; - return Formatter.Format(f); + return f; } throw new ArgumentException(); } - public string Interpret(byte comp, bool hex) + public object Interpret(byte comp) { if (compByteWidth != 1 || compType == FormatComponentType.Float) throw new ArgumentException(); if (compType == FormatComponentType.SInt) { - sbyte cast = (sbyte)comp; - return String.Format("{0}", cast); + return (sbyte)comp; } else if (compType == FormatComponentType.UInt) { - return String.Format(hex ? "{0:X2}" : "{0}", comp); + return comp; } else if (compType == FormatComponentType.UNorm) { - float f = ((float)comp) / 255.0f; - return Formatter.Format(f); + return ((float)comp) / 255.0f; } else if (compType == FormatComponentType.UNorm_SRGB) { - float f = ((float)comp) / 255.0f; - return Formatter.Format(f); + return ((float)comp) / 255.0f; } else if (compType == FormatComponentType.SNorm) { @@ -239,7 +216,7 @@ namespace renderdoc else f = ((float)cast) / 127.0f; - return Formatter.Format(f); + return f; } throw new ArgumentException(); diff --git a/renderdocui/Interop/Shader.cs b/renderdocui/Interop/Shader.cs index 0c035c912..a7e703040 100644 --- a/renderdocui/Interop/Shader.cs +++ b/renderdocui/Interop/Shader.cs @@ -169,7 +169,7 @@ namespace renderdoc public string Row(int row, VarType t) { if(t == VarType.Double) - return RowValuesToString((int)columns, value.dv[row*columns+0], value.dv[row*columns+1]); + return RowValuesToString((int)columns, value.dv[row * columns + 0], value.dv[row * columns + 1]); else if(t == VarType.Int) return RowValuesToString((int)columns, value.iv[row * columns + 0], value.iv[row * columns + 1], value.iv[row * columns + 2], value.iv[row * columns + 3]); else if(t == VarType.UInt) diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index cf4e39096..03db7f1d6 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -31,7 +31,6 @@ using System.IO; using System.Drawing; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Threading; using System.Windows.Forms; using WeifenLuo.WinFormsUI.Docking; @@ -56,7 +55,7 @@ namespace renderdocui.Windows // explicitly myself but the UI interaction makes that murky, so bear in mind that you need to be able to // handle changing events while a thread is still going and about to populate some data etc, and be able // to abort that and start anew without anything breaking or racing. - public partial class BufferViewer : DockContent, ILogViewerForm + public partial class BufferViewer : DockContent, ILogViewerForm, IBufferFormatProcessor { #region Data Privates @@ -628,227 +627,17 @@ namespace renderdocui.Windows } } - var elems = new List(); - - var formatReader = new StringReader(formatString); - - // regex doesn't account for trailing or preceeding whitespace, or comments - - var regExpr = @"^(row_major\s+)?" + // row_major matrix - @"(" + - @"uintten|unormten" + - @"|unormh|unormb" + - @"|snormh|snormb" + - @"|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 - @"(\s+[A-Za-z_][A-Za-z0-9_]*)?" + // get identifier name - @"(\[[0-9]+\])?" + // optional array dimension - @"(\s*:\s*[A-Za-z_][A-Za-z0-9_]*)?" + // optional semantic - @"$"; - - Regex regParser = new Regex(regExpr, RegexOptions.Compiled); - - bool success = true; - string errors = ""; - Input input = new Input(); - input.Strides = new uint[] { 0 }; + string errors = ""; - var text = formatReader.ReadToEnd(); - - text = text.Replace("{", "").Replace("}", ""); - - Regex c_comments = new Regex(@"/\*[^*]*\*+(?:[^*/][^*]*\*+)*/", RegexOptions.Compiled); - text = c_comments.Replace(text, ""); - - Regex cpp_comments = new Regex(@"//.*", RegexOptions.Compiled); - text = cpp_comments.Replace(text, ""); - - // get each line and parse it to determine the format the user wanted - foreach (var l in text.Split(';')) - { - var line = l; - line = line.Trim(); - - if (line == "") continue; - - var match = regParser.Match(line); - - if (!match.Success) - { - errors = "Couldn't parse line:\n" + line; - success = false; - break; - } - - var basetype = match.Groups[2].Value; - bool row_major = match.Groups[1].Success; - var vectorDim = match.Groups[3].Success ? match.Groups[3].Value : "1"; - var matrixDim = match.Groups[4].Success ? match.Groups[4].Value.Substring(1) : "1"; - var name = match.Groups[5].Success ? match.Groups[5].Value.Trim() : "data"; - var arrayDim = match.Groups[6].Success ? match.Groups[6].Value.Trim() : "[1]"; - arrayDim = arrayDim.Substring(1, arrayDim.Length - 2); - - if(match.Groups[4].Success) - { - var a = vectorDim; - vectorDim = matrixDim; - matrixDim = a; - } - - ResourceFormat fmt = new ResourceFormat(FormatComponentType.None, 0, 0); - - bool hex = false; - - FormatComponentType type = FormatComponentType.Float; - uint count = 0; - uint arrayCount = 1; - uint matrixCount = 0; - uint width = 0; - - // calculate format - { - if (!uint.TryParse(vectorDim, out count)) - { - errors = "Invalid vector dimension on line:\n" + line; - success = false; - break; - } - if (!uint.TryParse(arrayDim, out arrayCount)) - { - arrayCount = 1; - } - arrayCount = Math.Max(0, arrayCount); - if (!uint.TryParse(matrixDim, out matrixCount)) - { - errors = "Invalid matrix second dimension on line:\n" + line; - success = false; - break; - } - - if (basetype == "bool") - { - type = FormatComponentType.UInt; - width = 4; - } - else if (basetype == "byte") - { - type = FormatComponentType.SInt; - width = 1; - } - else if (basetype == "ubyte" || basetype == "xbyte") - { - type = FormatComponentType.UInt; - width = 1; - } - else if (basetype == "short") - { - type = FormatComponentType.SInt; - width = 2; - } - else if (basetype == "ushort" || basetype == "xshort") - { - type = FormatComponentType.UInt; - width = 2; - } - else if (basetype == "int") - { - type = FormatComponentType.SInt; - width = 4; - } - else if (basetype == "uint" || basetype == "xint") - { - type = FormatComponentType.UInt; - width = 4; - } - else if (basetype == "half") - { - type = FormatComponentType.Float; - width = 2; - } - else if (basetype == "float") - { - type = FormatComponentType.Float; - width = 4; - } - else if (basetype == "double") - { - type = FormatComponentType.Float; - width = 8; - } - else if (basetype == "unormh") - { - type = FormatComponentType.UNorm; - width = 2; - } - else if (basetype == "unormb") - { - type = FormatComponentType.UNorm; - width = 1; - } - else if (basetype == "snormh") - { - type = FormatComponentType.SNorm; - width = 2; - } - else if (basetype == "snormb") - { - type = FormatComponentType.SNorm; - width = 1; - } - else if (basetype == "uintten") - { - fmt = new ResourceFormat(FormatComponentType.UInt, 4 * count, 1); - fmt.special = true; - fmt.specialFormat = SpecialFormat.R10G10B10A2; - } - else if (basetype == "unormten") - { - fmt = new ResourceFormat(FormatComponentType.UNorm, 4 * count, 1); - fmt.special = true; - fmt.specialFormat = SpecialFormat.R10G10B10A2; - } - else - { - errors = "Unrecognised basic type on line:\n" + line; - success = false; - break; - } - } - - 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, hex); - - elems.Add(elem); - input.Strides[0] += elem.ByteSize; - } - - if (!success || elems.Count == 0) - { - elems.Clear(); - - var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4); - - elems.Add(new FormatElement("data", 0, input.Strides[0], false, false, 1, fmt, true)); - input.Strides[0] = elems.Last().ByteSize; - } + FormatElement[] elems = FormatElement.ParseFormatString(formatString, true, out errors); + input.Strides = new uint[] { elems.Last().offset + elems.Last().ByteSize }; input.Buffers = new ResourceId[] { buff }; input.Offsets = new uint[] { 0 }; input.IndexBuffer = ResourceId.Null; - input.BufferFormats = elems.ToArray(); + input.BufferFormats = elems; input.IndexOffset = 0; m_VSIn.m_Input = input; @@ -1545,6 +1334,30 @@ namespace renderdocui.Windows } } + private string ElementString(FormatElement el, object o) + { + if (o is float) + { + return Formatter.Format((float)o); + } + else if (o is uint) + { + uint u = (uint)o; + + if (el.format.compByteWidth == 4) String.Format(el.hex ? "{0:X8}" : "{0}", u); + if (el.format.compByteWidth == 2) String.Format(el.hex ? "{0:X4}" : "{0}", u); + if (el.format.compByteWidth == 1) String.Format(el.hex ? "{0:X2}" : "{0}", u); + + return String.Format("{0}", (uint)o); + } + else if (o is int) + { + return String.Format("{0}", (int)o); + } + + return o.ToString(); + } + private void UI_CacheRow(UIState state, int rowIdx) { if (state.m_Rows[rowIdx] != null || SuppressCaching) @@ -1660,160 +1473,33 @@ namespace renderdocui.Windows strm.Seek(offs, SeekOrigin.Begin); } - string elname = bufferFormats[el].name.ToLowerInvariant(); - var fmt = bufferFormats[el].format; + object[] elements = bufferFormats[el].GetObjects(read); - if (fmt.special && fmt.specialFormat == SpecialFormat.B8G8R8A8) + if (bufferFormats[el].matrixdim == 1) { - byte b = read.ReadByte(); - byte g = read.ReadByte(); - byte r = read.ReadByte(); - byte a = read.ReadByte(); - - 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; + for (int i = 0; i < elements.Length; i++) + rowdata[x + i] = ElementString(bufferFormats[el], elements[i]); + x += elements.Length; } - else if (fmt.special && fmt.specialFormat == SpecialFormat.B5G5R5A1) + else { - ushort packed = read.ReadUInt16(); - - rowdata[x + 2] = (float)((packed >> 0) & 0x1f) / 31.0f; - rowdata[x + 1] = (float)((packed >> 5) & 0x1f) / 31.0f; - rowdata[x + 0] = (float)((packed >> 10) & 0x1f) / 31.0f; - rowdata[x + 3] = ((packed & 0x8000) > 0) ? 1.0f : 0.0f; - x += 4; - } - else if (fmt.special && fmt.specialFormat == SpecialFormat.B5G6R5) - { - ushort packed = read.ReadUInt16(); - - rowdata[x + 2] = (float)((packed >> 0) & 0x1f) / 31.0f; - rowdata[x + 1] = (float)((packed >> 5) & 0x3f) / 63.0f; - rowdata[x + 0] = (float)((packed >> 11) & 0x1f) / 31.0f; - x += 3; - } - else if (fmt.special && fmt.specialFormat == SpecialFormat.B4G4R4A4) - { - ushort packed = read.ReadUInt16(); - - rowdata[x + 2] = (float)((packed >> 0) & 0xf) / 15.0f; - rowdata[x + 1] = (float)((packed >> 4) & 0xf) / 15.0f; - rowdata[x + 0] = (float)((packed >> 8) & 0xf) / 15.0f; - rowdata[x + 3] = (float)((packed >> 12) & 0xf) / 15.0f; - x += 4; - } - else if (fmt.special && fmt.specialFormat == SpecialFormat.R10G10B10A2) - { - // allow for vectors of this format - for raw buffer viewer - for (int i = 0; i < (fmt.compCount / 4); i++) - { - uint packed = read.ReadUInt32(); - - uint r = (packed >> 0) & 0x3ff; - uint g = (packed >> 10) & 0x3ff; - uint b = (packed >> 20) & 0x3ff; - uint a = (packed >> 30) & 0x003; - - if (fmt.compType == FormatComponentType.UInt) - { - rowdata[x + 0] = r; - rowdata[x + 1] = g; - rowdata[x + 2] = b; - rowdata[x + 3] = a; - } - else - { - rowdata[x + 0] = (float)r / 1023.0f; - rowdata[x + 1] = (float)g / 1023.0f; - rowdata[x + 2] = (float)b / 1023.0f; - rowdata[x + 3] = (float)a / 3.0f; - } - - x += 4; - } - } - else if (fmt.special && fmt.specialFormat == SpecialFormat.R11G11B10) - { - 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); - - rowdata[x + 0] = ((float)(xMantissa) / 64.0f) * Math.Pow(2.0f, (float)xExponent - 15.0f); - rowdata[x + 1] = ((float)(yMantissa) / 32.0f) * Math.Pow(2.0f, (float)yExponent - 15.0f); - rowdata[x + 2] = ((float)(zMantissa) / 32.0f) * Math.Pow(2.0f, (float)zExponent - 15.0f); - - x += 3; - } - else if(bufferFormats[el].matrixdim > 1) - { - object[] arr = new object[bufferFormats[el].matrixdim * fmt.compCount]; - for (int i = 0; i < bufferFormats[el].matrixdim * fmt.compCount; i++) - { - if (fmt.compType == FormatComponentType.Float) - { - if (fmt.compByteWidth == 4) - arr[i] = read.ReadSingle(); - else if (fmt.compByteWidth == 2) - arr[i] = fmt.ConvertFromHalf(read.ReadUInt16()); - } - else - { - if (fmt.compByteWidth == 4) - arr[i] = fmt.Interpret(read.ReadUInt32(), bufferFormats[el].hex); - else if (fmt.compByteWidth == 2) - arr[i] = fmt.Interpret(read.ReadUInt16(), bufferFormats[el].hex); - else if (fmt.compByteWidth == 1) - arr[i] = fmt.Interpret(read.ReadByte(), bufferFormats[el].hex); - } - } - - int cols = (int)fmt.compCount; + int cols = (int)bufferFormats[el].format.compCount; int rows = (int)bufferFormats[el].matrixdim; for (int col = 0; col < cols; col++) { - object[] colarr = new object[rows]; + string[] colarr = new string[rows]; for (int row = 0; row < rows; row++) { if (!bufferFormats[el].rowmajor) - colarr[row] = arr[col * rows + row]; + colarr[row] = ElementString(bufferFormats[el], elements[col * rows + row]); else - colarr[row] = arr[row * cols + col]; + colarr[row] = ElementString(bufferFormats[el], elements[row * cols + col]); } rowdata[x++] = colarr; } } - else if (fmt.compType == FormatComponentType.Float) - { - for (int i = 0; i < fmt.compCount; i++, x++) - { - if (fmt.compByteWidth == 4) - rowdata[x] = read.ReadSingle(); - else if (fmt.compByteWidth == 2) - rowdata[x] = fmt.ConvertFromHalf(read.ReadUInt16()); - } - } - else - { - for (int i = 0; i < fmt.compCount; i++, x++) - { - if (fmt.compByteWidth == 4) - rowdata[x] = fmt.Interpret(read.ReadUInt32(), bufferFormats[el].hex); - else if (fmt.compByteWidth == 2) - rowdata[x] = fmt.Interpret(read.ReadUInt16(), bufferFormats[el].hex); - else if (fmt.compByteWidth == 1) - rowdata[x] = fmt.Interpret(read.ReadByte(), bufferFormats[el].hex); - } - } } } catch (System.IO.EndOfStreamException) @@ -2433,14 +2119,25 @@ namespace renderdocui.Windows ShowFormatSpecifier(); } + public void ProcessBufferFormat(string formatText) + { + ViewRawBuffer(GetUIState(MeshDataStage.VSIn).m_Input.Buffers[0], formatText); + } + private void ShowFormatSpecifier() { UIState ui = GetUIState(MeshDataStage.VSIn); - if (m_FormatSpecifier == null) - m_FormatSpecifier = new BufferFormatSpecifier(this, ui.m_Input.Buffers[0], m_FormatText); + if (m_FormatSpecifier == null) + { + m_FormatSpecifier = new BufferFormatSpecifier(this, m_FormatText); - m_FormatSpecifier.Show(dockPanel, DockState.DockBottom); + var dock = Helpers.WrapDockContent(dockPanel, m_FormatSpecifier, m_FormatSpecifier.Text); + dock.CloseButton = false; + dock.CloseButtonVisible = false; + } + + (m_FormatSpecifier.Parent as DockContent).Show(dockPanel, DockState.DockBottom); } private void debugVertex_Click(object sender, EventArgs e) @@ -2756,49 +2453,4 @@ namespace renderdocui.Windows } } } - - public class FormatElement - { - public FormatElement() - { - name = ""; - buffer = 0; - offset = 0; - perinstance = false; - 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, bool h) - { - name = Name; - buffer = buf; - offset = offs; - format = fmt; - perinstance = pi; - rowmajor = rowMat; - matrixdim = matDim; - hex = h; - } - - public uint ByteSize - { - get - { - return format.compByteWidth * format.compCount * matrixdim; - } - } - - public string name; - public int buffer; - public uint offset; - public bool perinstance; - public bool rowmajor; - public uint matrixdim; - public ResourceFormat format; - public bool hex; - } - } diff --git a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.Designer.cs b/renderdocui/Windows/Dialogs/BufferFormatSpecifier.Designer.cs deleted file mode 100644 index 07e561379..000000000 --- a/renderdocui/Windows/Dialogs/BufferFormatSpecifier.Designer.cs +++ /dev/null @@ -1,153 +0,0 @@ -namespace renderdocui.Windows.Dialogs -{ - partial class BufferFormatSpecifier - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - System.Windows.Forms.GroupBox groupBox1; - System.Windows.Forms.Label label1; - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(BufferFormatSpecifier)); - this.formatText = new System.Windows.Forms.TextBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.errors = new System.Windows.Forms.Label(); - this.apply = new System.Windows.Forms.Button(); - groupBox1 = new System.Windows.Forms.GroupBox(); - label1 = new System.Windows.Forms.Label(); - groupBox1.SuspendLayout(); - this.tableLayoutPanel1.SuspendLayout(); - this.SuspendLayout(); - // - // groupBox1 - // - groupBox1.Controls.Add(this.formatText); - groupBox1.Dock = System.Windows.Forms.DockStyle.Fill; - groupBox1.Location = new System.Drawing.Point(3, 195); - groupBox1.Name = "groupBox1"; - groupBox1.Size = new System.Drawing.Size(571, 102); - groupBox1.TabIndex = 0; - groupBox1.TabStop = false; - groupBox1.Text = "Format"; - // - // formatText - // - this.formatText.Dock = System.Windows.Forms.DockStyle.Fill; - this.formatText.Font = new System.Drawing.Font("Consolas", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.formatText.Location = new System.Drawing.Point(3, 16); - this.formatText.Multiline = true; - this.formatText.Name = "formatText"; - this.formatText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - 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); - // - // 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(517, 130); - label1.TabIndex = 1; - label1.Text = resources.GetString("label1.Text"); - // - // tableLayoutPanel1 - // - 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.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 = 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.Size = new System.Drawing.Size(656, 300); - this.tableLayoutPanel1.TabIndex = 0; - // - // 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, 146); - this.errors.Name = "errors"; - this.errors.Size = new System.Drawing.Size(650, 46); - this.errors.TabIndex = 3; - // - // apply - // - 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"; - this.apply.Size = new System.Drawing.Size(63, 23); - this.apply.TabIndex = 1; - this.apply.Text = "Apply"; - this.apply.UseVisualStyleBackColor = true; - this.apply.Click += new System.EventHandler(this.apply_Click); - // - // BufferFormatSpecifier - // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(656, 300); - this.Controls.Add(this.tableLayoutPanel1); - this.DockAreas = ((WeifenLuo.WinFormsUI.Docking.DockAreas)(((((WeifenLuo.WinFormsUI.Docking.DockAreas.DockLeft | WeifenLuo.WinFormsUI.Docking.DockAreas.DockRight) - | WeifenLuo.WinFormsUI.Docking.DockAreas.DockTop) - | WeifenLuo.WinFormsUI.Docking.DockAreas.DockBottom) - | WeifenLuo.WinFormsUI.Docking.DockAreas.Document))); - this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; - this.MaximizeBox = false; - this.MinimizeBox = false; - this.Name = "BufferFormatSpecifier"; - this.ShowInTaskbar = false; - this.Text = "Buffer Format"; - groupBox1.ResumeLayout(false); - groupBox1.PerformLayout(); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.ResumeLayout(false); - - } - - #endregion - - private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; - private System.Windows.Forms.TextBox formatText; - private System.Windows.Forms.Button apply; - private System.Windows.Forms.Label errors; - } -} \ No newline at end of file diff --git a/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.Designer.cs b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.Designer.cs new file mode 100644 index 000000000..40aeedb50 --- /dev/null +++ b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.Designer.cs @@ -0,0 +1,178 @@ +namespace renderdocui.Controls +{ + partial class ConstantBufferPreviewer + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ConstantBufferPreviewer)); + TreelistView.TreeListColumn treeListColumn1 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarName", "Name"))); + TreelistView.TreeListColumn treeListColumn2 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarValue", "Value"))); + TreelistView.TreeListColumn treeListColumn3 = ((TreelistView.TreeListColumn)(new TreelistView.TreeListColumn("VarType", "Type"))); + this.tableLayout = new System.Windows.Forms.TableLayoutPanel(); + this.toolStrip1 = new System.Windows.Forms.ToolStrip(); + this.slotLabel = new System.Windows.Forms.ToolStripLabel(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.nameLabel = new System.Windows.Forms.ToolStripLabel(); + this.setFormat = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.split = new System.Windows.Forms.SplitContainer(); + this.variables = new TreelistView.TreeListView(); + this.tableLayout.SuspendLayout(); + this.toolStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.split)).BeginInit(); + this.split.Panel1.SuspendLayout(); + this.split.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.variables)).BeginInit(); + this.SuspendLayout(); + // + // tableLayout + // + this.tableLayout.ColumnCount = 1; + this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayout.Controls.Add(this.toolStrip1, 0, 0); + this.tableLayout.Controls.Add(this.split, 0, 1); + this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill; + this.tableLayout.Location = new System.Drawing.Point(0, 0); + this.tableLayout.Name = "tableLayout"; + this.tableLayout.RowCount = 2; + this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayout.Size = new System.Drawing.Size(491, 330); + this.tableLayout.TabIndex = 0; + // + // toolStrip1 + // + this.toolStrip1.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.slotLabel, + this.toolStripSeparator1, + this.nameLabel, + this.toolStripSeparator2, + this.setFormat}); + this.toolStrip1.Location = new System.Drawing.Point(0, 0); + this.toolStrip1.Name = "toolStrip1"; + this.toolStrip1.Size = new System.Drawing.Size(491, 25); + this.toolStrip1.TabIndex = 4; + this.toolStrip1.Text = "toolStrip1"; + // + // slotLabel + // + this.slotLabel.Name = "slotLabel"; + this.slotLabel.Size = new System.Drawing.Size(19, 22); + this.slotLabel.Text = " "; + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(6, 25); + // + // nameLabel + // + this.nameLabel.Name = "nameLabel"; + this.nameLabel.Size = new System.Drawing.Size(22, 22); + this.nameLabel.Text = " "; + // + // setFormat + // + this.setFormat.CheckOnClick = true; + this.setFormat.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text; + this.setFormat.Image = ((System.Drawing.Image)(resources.GetObject("setFormat.Image"))); + this.setFormat.ImageTransparentColor = System.Drawing.Color.Magenta; + this.setFormat.Name = "setFormat"; + this.setFormat.Size = new System.Drawing.Size(23, 22); + this.setFormat.Text = "{}"; + this.setFormat.ToolTipText = "Set constant buffer layout"; + this.setFormat.CheckedChanged += new System.EventHandler(this.setFormat_CheckedChanged); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(6, 25); + // + // split + // + this.split.Dock = System.Windows.Forms.DockStyle.Fill; + this.split.Location = new System.Drawing.Point(3, 28); + this.split.Name = "split"; + this.split.Orientation = System.Windows.Forms.Orientation.Horizontal; + // + // split.Panel1 + // + this.split.Panel1.Controls.Add(this.variables); + this.split.Panel1MinSize = 100; + this.split.Panel2Collapsed = true; + this.split.Panel2MinSize = 150; + this.split.Size = new System.Drawing.Size(485, 299); + this.split.SplitterDistance = 100; + this.split.TabIndex = 5; + // + // variables + // + treeListColumn1.AutoSizeMinSize = 0; + treeListColumn1.Width = 175; + treeListColumn2.AutoSize = true; + treeListColumn2.AutoSizeMinSize = 0; + treeListColumn2.Width = 50; + treeListColumn3.AutoSizeMinSize = 0; + treeListColumn3.Width = 50; + this.variables.Columns.AddRange(new TreelistView.TreeListColumn[] { + treeListColumn1, + treeListColumn2, + treeListColumn3}); + this.variables.ColumnsOptions.LeftMargin = 0; + this.variables.Cursor = System.Windows.Forms.Cursors.Arrow; + this.variables.Dock = System.Windows.Forms.DockStyle.Fill; + this.variables.Location = new System.Drawing.Point(0, 0); + this.variables.Name = "variables"; + this.variables.RowOptions.ShowHeader = false; + this.variables.Size = new System.Drawing.Size(485, 299); + this.variables.TabIndex = 4; + this.variables.Text = "treeListView1"; + // + // ConstantBufferPreviewer + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(491, 330); + this.Controls.Add(this.tableLayout); + this.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Name = "ConstantBufferPreviewer"; + this.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockRight; + this.tableLayout.ResumeLayout(false); + this.tableLayout.PerformLayout(); + this.toolStrip1.ResumeLayout(false); + this.toolStrip1.PerformLayout(); + this.split.Panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.split)).EndInit(); + this.split.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.variables)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayout; + private System.Windows.Forms.ToolStrip toolStrip1; + private System.Windows.Forms.ToolStripLabel slotLabel; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripLabel nameLabel; + private System.Windows.Forms.ToolStripButton setFormat; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.SplitContainer split; + private TreelistView.TreeListView variables; + + } +} diff --git a/renderdocui/Controls/ConstantBufferPreviewer.cs b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs similarity index 74% rename from renderdocui/Controls/ConstantBufferPreviewer.cs rename to renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs index f7544f6ff..95077e8e4 100644 --- a/renderdocui/Controls/ConstantBufferPreviewer.cs +++ b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs @@ -32,12 +32,14 @@ using System.Linq; using System.Text; using System.Windows.Forms; using renderdocui.Code; +using renderdocui.Windows.Dialogs; using renderdoc; using WeifenLuo.WinFormsUI.Docking; +using System.IO; namespace renderdocui.Controls { - public partial class ConstantBufferPreviewer : UserControl, ILogViewerForm + public partial class ConstantBufferPreviewer : DockContent, ILogViewerForm, IBufferFormatProcessor { private Core m_Core; @@ -63,37 +65,34 @@ namespace renderdocui.Controls m_Core.AddLogViewer(this); } - private static List m_Docks = new List(); + private static List m_Docks = new List(); public static DockContent Has(ShaderStageType stage, UInt32 slot) { - foreach (var d in m_Docks) + foreach (var cb in m_Docks) { - ConstantBufferPreviewer cb = d.Controls[0] as ConstantBufferPreviewer; - if(cb.Stage == stage && cb.Slot == slot) - return cb.Parent as DockContent; + return cb as DockContent; } return null; } - public static void ShowDock(DockContent dock, DockPane pane, DockAlignment align, double proportion) + public void ShowDock(DockPane pane, DockAlignment align, double proportion) { - dock.FormClosed += new FormClosedEventHandler(dock_FormClosed); + FormClosed += new FormClosedEventHandler(dock_FormClosed); if (m_Docks.Count > 0) - dock.Show(m_Docks[0].Pane, m_Docks[0]); + Show(m_Docks[0].Pane, m_Docks[0]); else - dock.Show(pane, align, proportion); + Show(pane, align, proportion); - m_Docks.Add(dock); + m_Docks.Add(this); } static void dock_FormClosed(object sender, FormClosedEventArgs e) { - DockContent p = sender as DockContent; - m_Docks.Remove(p); + m_Docks.Remove(sender as ConstantBufferPreviewer); } /// @@ -185,10 +184,20 @@ namespace renderdocui.Controls return; } - m_Core.Renderer.BeginInvoke((ReplayRenderer r) => - { - SetVariables(r.GetCBufferVariableContents(shader, Slot, cbuffer, offs)); - }); + if (m_FormatOverride != null) + { + m_Core.Renderer.BeginInvoke((ReplayRenderer r) => + { + SetVariables(ApplyFormatOverride(r.GetBufferData(cbuffer, offs, size))); + }); + } + else + { + m_Core.Renderer.BeginInvoke((ReplayRenderer r) => + { + SetVariables(r.GetCBufferVariableContents(shader, Slot, cbuffer, offs)); + }); + } } private string BufferName = ""; @@ -266,5 +275,71 @@ namespace renderdocui.Controls Clipboard.SetText(text); } } + + private BufferFormatSpecifier m_FormatSpecifier = null; + private FormatElement[] m_FormatOverride = null; + + ShaderVariable[] ApplyFormatOverride(byte[] data) + { + if(m_FormatOverride == null || m_FormatOverride.Length == 0) return null; + + var stream = new MemoryStream(data); + var reader = new BinaryReader(stream); + + ShaderVariable[] ret = new ShaderVariable[m_FormatOverride.Length]; + + for (int i = 0; i < m_FormatOverride.Length; i++) + { + stream.Seek(m_FormatOverride[i].offset, SeekOrigin.Begin); + ret[i] = m_FormatOverride[i].GetShaderVar(reader); + } + + reader.Dispose(); + stream.Dispose(); + + return ret; + } + + public void ProcessBufferFormat(string formatText) + { + if (formatText == "") + { + m_FormatOverride = null; + if (m_FormatSpecifier != null) + m_FormatSpecifier.SetErrors(""); + } + else + { + string errors = ""; + + m_FormatOverride = FormatElement.ParseFormatString(formatText, false, out errors); + + if (m_FormatSpecifier != null) + m_FormatSpecifier.SetErrors(errors); + } + + OnEventSelected(m_Core.CurFrame, m_Core.CurEvent); + } + + private void setFormat_CheckedChanged(object sender, EventArgs e) + { + if (!setFormat.Checked) + { + split.Panel2.Controls.Remove(m_FormatSpecifier); + split.Panel2Collapsed = true; + + ProcessBufferFormat(""); + + return; + } + + if (m_FormatSpecifier == null) + m_FormatSpecifier = new BufferFormatSpecifier(this, ""); + + split.Panel2.Controls.Add(m_FormatSpecifier); + m_FormatSpecifier.Dock = DockStyle.Fill; + split.Panel2Collapsed = false; + split.SplitterDistance = split.ClientRectangle.Height / 2; + } } } diff --git a/renderdocui/Controls/ConstantBufferPreviewer.resx b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.resx similarity index 80% rename from renderdocui/Controls/ConstantBufferPreviewer.resx rename to renderdocui/Windows/Dialogs/ConstantBufferPreviewer.resx index 1af7de150..8af6a287b 100644 --- a/renderdocui/Controls/ConstantBufferPreviewer.resx +++ b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.resx @@ -117,4 +117,23 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 17, 17 + + + + + iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAIDSURBVDhPpZLrS5NhGMb3j4SWh0oRQVExD4gonkDpg4hG + YKxG6WBogkMZKgPNCEVJFBGdGETEvgwyO9DJE5syZw3PIlPEE9pgBCLZ5XvdMB8Ew8gXbl54nuf63dd9 + 0OGSnwCahxbPRNPAPMw9Xpg6ZmF46kZZ0xSKzJPIrhpDWsVnpBhGkKx3nAX8Pv7z1zg8OoY/cITdn4fw + bf/C0kYAN3Ma/w3gWfZL5kzTKBxjWyK2DftwI9tyMYCZKXbNHaD91bLYJrDXsYbrWfUKwJrPE9M2M1Oc + VzOOpHI7Jr376Hi9ogHqFIANO0/MmmmbmSmm9a8ze+I4MrNWAdjtoJgWcx+PSzg166yZZ8xM8XvXDix9 + c4jIqFYAjoriBV9AhEPv1mH/sonogha0afbZMMZz+yreTGyhpusHwtNNCsA5U1zS4BLxzJIfg299qO32 + Ir7UJtZfftyATqeT+8o2D8JSjQrAJblrncYL7ZJ2+bfaFnC/1S1NjL3diRat7qrO7wLRP3HjWsojBeCo + mDEo5mNjuweFGvjWg2EBhCbpkW78htSHHwRyNdmgAFzPEee2iFkzayy2OLXzT4gr6UdUnlXrullsxxQ+ + kx0g8BTA3aZlButjSTyjODq/WcQcW/B/Je4OQhLvKQDnzN1mp0nnkvAhR8VuMzNrpm1mpjgkoVwB/v8D + TgDQASA1MVpwzwAAAABJRU5ErkJggg== + + \ No newline at end of file diff --git a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs index f0ebd5a68..629111f39 100644 --- a/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/D3D11PipelineStateViewer.cs @@ -1879,10 +1879,7 @@ namespace renderdocui.Windows.PipelineState var prev = new ConstantBufferPreviewer(m_Core, stage.stage, slot); - var dock = Helpers.WrapDockContent(m_DockContent.DockPanel, prev); - dock.DockState = DockState.DockRight; - dock.DockAreas |= DockAreas.Float; - ConstantBufferPreviewer.ShowDock(dock, m_DockContent.Pane, DockAlignment.Right, 0.3); + prev.ShowDock(m_DockContent.Pane, DockAlignment.Right, 0.3); } private void cbuffers_NodeDoubleClicked(TreelistView.Node node) diff --git a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs index 2e63c6097..b0ff9f133 100644 --- a/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs +++ b/renderdocui/Windows/PipelineState/GLPipelineStateViewer.cs @@ -986,10 +986,7 @@ namespace renderdocui.Windows.PipelineState var prev = new ConstantBufferPreviewer(m_Core, stage.stage, slot); - var dock = Helpers.WrapDockContent(m_DockContent.DockPanel, prev); - dock.DockState = DockState.DockRight; - dock.DockAreas |= DockAreas.Float; - ConstantBufferPreviewer.ShowDock(dock, m_DockContent.Pane, DockAlignment.Right, 0.3); + prev.ShowDock(m_DockContent.Pane, DockAlignment.Right, 0.3); } private void cbuffers_NodeDoubleClicked(TreelistView.Node node) diff --git a/renderdocui/renderdocui.csproj b/renderdocui/renderdocui.csproj index da95c8c5f..82c4812ac 100644 --- a/renderdocui/renderdocui.csproj +++ b/renderdocui/renderdocui.csproj @@ -95,6 +95,7 @@ + @@ -120,10 +121,10 @@ Component - - UserControl + + Form - + ConstantBufferPreviewer.cs @@ -193,10 +194,10 @@ AboutDialog.cs - - Form + + UserControl - + BufferFormatSpecifier.cs @@ -298,7 +299,7 @@ TimelineBar.cs - + ConstantBufferPreviewer.cs @@ -325,7 +326,7 @@ AboutDialog.cs - + BufferFormatSpecifier.cs