CBuffer window is a dialog now, with ability to set custom layout

This commit is contained in:
baldurk
2014-09-13 18:48:39 +01:00
parent d9104b73c3
commit bda68c8ba6
15 changed files with 1083 additions and 744 deletions
@@ -1,153 +0,0 @@
namespace renderdocui.Windows.Dialogs
{
partial class BufferFormatSpecifier
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}
@@ -1,79 +0,0 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2014 Crytek
*
* 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.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using renderdoc;
namespace renderdocui.Windows.Dialogs
{
public partial class BufferFormatSpecifier : DockContent
{
BufferViewer m_Viewer = null;
ResourceId m_Buffer = ResourceId.Null;
public BufferFormatSpecifier(BufferViewer viewer, ResourceId buff, 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);
m_Viewer = viewer;
m_Buffer = buff;
}
private void apply_Click(object sender, EventArgs e)
{
SetErrors("");
m_Viewer.ViewRawBuffer(m_Buffer, formatText.Text);
}
public void SetErrors(string err)
{
errors.Text = err;
if (errors.Text == "")
errors.Visible = false;
else
errors.Visible = true;
}
private void formatText_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.A && e.Control)
{
e.SuppressKeyPress = true;
formatText.SelectAll();
}
}
}
}
@@ -0,0 +1,178 @@
namespace renderdocui.Controls
{
partial class ConstantBufferPreviewer
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}
@@ -0,0 +1,345 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2014 Crytek
*
* 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.ComponentModel;
using System.Drawing;
using System.Data;
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 : DockContent, ILogViewerForm, IBufferFormatProcessor
{
private Core m_Core;
public ConstantBufferPreviewer(Core c, ShaderStageType stage, UInt32 slot)
{
InitializeComponent();
m_Core = c;
Stage = stage;
Slot = slot;
shader = m_Core.CurPipelineState.GetShader(stage);
UpdateLabels();
uint offs = 0;
uint size = 0;
m_Core.CurPipelineState.GetConstantBuffer(Stage, Slot, out cbuffer, out offs, out size);
m_Core.Renderer.BeginInvoke((ReplayRenderer r) =>
{
SetVariables(r.GetCBufferVariableContents(shader, Slot, cbuffer, offs));
});
m_Core.AddLogViewer(this);
}
private static List<ConstantBufferPreviewer> m_Docks = new List<ConstantBufferPreviewer>();
public static DockContent Has(ShaderStageType stage, UInt32 slot)
{
foreach (var cb in m_Docks)
{
if(cb.Stage == stage && cb.Slot == slot)
return cb as DockContent;
}
return null;
}
public void ShowDock(DockPane pane, DockAlignment align, double proportion)
{
FormClosed += new FormClosedEventHandler(dock_FormClosed);
if (m_Docks.Count > 0)
Show(m_Docks[0].Pane, m_Docks[0]);
else
Show(pane, align, proportion);
m_Docks.Add(this);
}
static void dock_FormClosed(object sender, FormClosedEventArgs e)
{
m_Docks.Remove(sender as ConstantBufferPreviewer);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
m_Core.RemoveLogViewer(this);
}
base.Dispose(disposing);
}
public void OnLogfileClosed()
{
variables.BeginUpdate();
variables.Nodes.Clear();
variables.EndUpdate();
variables.Invalidate();
}
public void OnLogfileLoaded()
{
variables.BeginUpdate();
variables.Nodes.Clear();
variables.EndUpdate();
variables.Invalidate();
}
private void AddVariables(TreelistView.NodeCollection root, ShaderVariable[] vars)
{
foreach (var v in vars)
{
TreelistView.Node n = root.Add(new TreelistView.Node(new object[] { v.name, v, v.TypeString() }));
if (v.rows > 1)
{
for (int i = 0; i < v.rows; i++)
{
n.Nodes.Add(new TreelistView.Node(new object[] { String.Format("{0}.row{1}", v.name, i), v.Row(i), v.RowTypeString() }));
}
}
if (v.members.Length > 0)
{
AddVariables(n.Nodes, v.members);
}
}
}
private void SetVariables(ShaderVariable[] vars)
{
if (variables.InvokeRequired)
{
this.BeginInvoke(new Action(() => { SetVariables(vars); }));
return;
}
variables.BeginUpdate();
variables.Nodes.Clear();
if(vars != null && vars.Length > 0)
AddVariables(variables.Nodes, vars);
variables.EndUpdate();
variables.Invalidate();
}
public void OnEventSelected(UInt32 frameID, UInt32 eventID)
{
uint offs = 0;
uint size = 0;
m_Core.CurPipelineState.GetConstantBuffer(Stage, Slot, out cbuffer, out offs, out size);
shader = m_Core.CurPipelineState.GetShader(Stage);
var reflection = m_Core.CurPipelineState.GetShaderReflection(Stage);
UpdateLabels();
if (reflection == null || reflection.ConstantBlocks.Length <= Slot)
{
SetVariables(null);
return;
}
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 = "";
private ResourceId cbuffer;
private ResourceId shader;
private ShaderStageType Stage;
private UInt32 Slot = 0;
public override string Text
{
get
{
return String.Format("{0} CB {1}", Stage.ToString(), Slot);
}
}
private void UpdateLabels()
{
BufferName = "";
bool needName = true;
foreach (var b in m_Core.CurBuffers)
{
if (b.ID == cbuffer)
{
BufferName = b.name;
if(b.customName)
needName = false;
}
}
var reflection = m_Core.CurPipelineState.GetShaderReflection(Stage);
if (reflection != null)
{
if (needName &&
Slot < reflection.ConstantBlocks.Length &&
reflection.ConstantBlocks[Slot].name != "")
BufferName = "<" + reflection.ConstantBlocks[Slot].name + ">";
}
nameLabel.Text = BufferName;
slotLabel.Text = Stage.ToString();
slotLabel.Text += " Shader Slot " + Slot;
}
private void variables_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.C && e.Control)
{
int[] width = new int[] { 0, 0, 0 };
foreach (var n in variables.NodesSelection)
{
width[0] = Math.Max(width[0], n[0].ToString().Length);
width[1] = Math.Max(width[1], n[1].ToString().Length);
width[2] = Math.Max(width[2], n[2].ToString().Length);
}
width[0] = Math.Min(50, width[0]);
width[1] = Math.Min(50, width[1]);
width[2] = Math.Min(50, width[2]);
string fmt = "{0,-" + width[0] + "} {1,-" + width[1] + "} {2,-" + width[2] + "}" + Environment.NewLine;
string text = "";
foreach (var n in variables.NodesSelection)
{
text += string.Format(fmt, n[0], n[1], n[2]);
}
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;
}
}
}
@@ -117,22 +117,23 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="groupBox1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<data name="label1.Text" xml:space="preserve">
<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), matrices ([rowmajor] half3x4) and arrays (float[16]) are supported.</value>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="setFormat.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
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==
</value>
</data>
</root>