mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-23 14:15:42 +00:00
CBuffer window is a dialog now, with ability to set custom layout
This commit is contained in:
@@ -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<FormatElement>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
+17
-16
@@ -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>
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user