Store index format and topology in drawcall, to accommodate GL

* D3D11 just latches the state from the input assembler state into the
  drawcall when it's being added. GL stores the state per-draw.
This commit is contained in:
baldurk
2015-01-15 17:17:12 +00:00
parent b9f1b9820f
commit f013f6fd29
19 changed files with 190 additions and 262 deletions
+19 -22
View File
@@ -74,7 +74,6 @@ namespace renderdocui.Windows
public FetchDrawcall Drawcall = null;
public FormatElement IndexFormat = new FormatElement();
public ResourceId IndexBuffer = ResourceId.Null;
public uint IndexOffset = 0;
}
@@ -697,13 +696,12 @@ namespace renderdocui.Windows
FormatElement[] f = null;
Input ret = new Input();
ret.Drawcall = draw;
ret.Topology = m_Core.CurPipelineState.DrawTopology;
ret.Topology = draw.topology;
ResourceId ibuffer = ResourceId.Null;
uint ioffset = 0;
ResourceFormat ifmt = null;
m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset, out ifmt);
m_Core.CurPipelineState.GetIBuffer(out ibuffer, out ioffset);
if (draw != null && (draw.flags & DrawcallFlags.UseIBuffer) == 0)
{
@@ -711,7 +709,6 @@ namespace renderdocui.Windows
ioffset = 0;
}
ret.IndexFormat = new FormatElement("", 0, 0, false, false, 1, ifmt, false);
ret.IndexBuffer = ibuffer;
ret.IndexOffset = ioffset;
@@ -872,12 +869,12 @@ namespace renderdocui.Windows
ret.IndexCount = input.Drawcall.numIndices;
byte[] rawidxs = r.GetBufferData(input.IndexBuffer,
input.IndexOffset + input.Drawcall.indexOffset * input.IndexFormat.format.compByteWidth,
ret.IndexCount * input.IndexFormat.format.compByteWidth);
input.IndexOffset + input.Drawcall.indexOffset * input.Drawcall.indexByteWidth,
ret.IndexCount * input.Drawcall.indexByteWidth);
ret.Indices = new uint[rawidxs.Length / input.IndexFormat.format.compByteWidth];
ret.Indices = new uint[rawidxs.Length / input.Drawcall.indexByteWidth];
if (input.IndexFormat.format.compByteWidth == 2)
if (input.Drawcall.indexByteWidth == 2)
{
ushort[] tmp = new ushort[rawidxs.Length / 2];
@@ -888,7 +885,7 @@ namespace renderdocui.Windows
ret.Indices[i] = tmp[i];
}
}
else if (input.IndexFormat.format.compByteWidth == 4)
else if (input.Drawcall.indexByteWidth == 4)
{
Buffer.BlockCopy(rawidxs, 0, ret.Indices, 0, rawidxs.Length);
}
@@ -896,9 +893,9 @@ namespace renderdocui.Windows
uint minIndex = ret.Indices.Length > 0 ? ret.Indices[0] : 0;
foreach (var i in ret.Indices)
{
if (input.IndexFormat.format.compByteWidth == 2 && i == UInt16.MaxValue)
if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue)
continue;
if (input.IndexFormat.format.compByteWidth == 4 && i == UInt32.MaxValue)
if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue)
continue;
minIndex = Math.Min(minIndex, i);
@@ -921,18 +918,18 @@ namespace renderdocui.Windows
input.IndexBuffer != ResourceId.Null)
{
byte[] rawidxs = r.GetBufferData(input.IndexBuffer,
input.IndexOffset + input.Drawcall.indexOffset * input.IndexFormat.format.compByteWidth,
ret.IndexCount * input.IndexFormat.format.compByteWidth);
input.IndexOffset + input.Drawcall.indexOffset * input.Drawcall.indexByteWidth,
ret.IndexCount * input.Drawcall.indexByteWidth);
if (input.IndexFormat.format.compByteWidth == 0)
if (input.Drawcall.indexByteWidth == 0)
{
ret.Indices = new uint[0];
}
else
{
ret.Indices = new uint[rawidxs.Length / input.IndexFormat.format.compByteWidth];
ret.Indices = new uint[rawidxs.Length / input.Drawcall.indexByteWidth];
if (input.IndexFormat.format.compByteWidth == 2)
if (input.Drawcall.indexByteWidth == 2)
{
ushort[] tmp = new ushort[rawidxs.Length / 2];
@@ -943,7 +940,7 @@ namespace renderdocui.Windows
ret.Indices[i] = tmp[i];
}
}
else if (input.IndexFormat.format.compByteWidth == 4)
else if (input.Drawcall.indexByteWidth == 4)
{
Buffer.BlockCopy(rawidxs, 0, ret.Indices, 0, rawidxs.Length);
}
@@ -952,9 +949,9 @@ namespace renderdocui.Windows
maxIndex = 0;
foreach (var i in ret.Indices)
{
if(input.IndexFormat.format.compByteWidth == 2 && i == UInt16.MaxValue)
if (input.Drawcall.indexByteWidth == 2 && i == UInt16.MaxValue)
continue;
if (input.IndexFormat.format.compByteWidth == 4 && i == UInt32.MaxValue)
if (input.Drawcall.indexByteWidth == 4 && i == UInt32.MaxValue)
continue;
maxIndex = Math.Max(maxIndex, i);
@@ -1579,9 +1576,9 @@ namespace renderdocui.Windows
state.m_Data.Topology == PrimitiveTopology.TriangleStrip ||
state.m_Data.Topology == PrimitiveTopology.TriangleStrip_Adj;
if (state.m_Input.IndexFormat.ByteSize == 2 && index == ushort.MaxValue && strip)
if (state.m_Input.Drawcall.indexByteWidth == 2 && index == ushort.MaxValue && strip)
rowdata[1] = "-1";
if (state.m_Input.IndexFormat.ByteSize == 4 && index == uint.MaxValue && strip)
if (state.m_Input.Drawcall.indexByteWidth == 4 && index == uint.MaxValue && strip)
rowdata[1] = "-1";
x = 2;
@@ -639,15 +639,15 @@ namespace renderdocui.Windows.PipelineState
inputLayouts.NodesSelection.Clear();
inputLayouts.EndUpdate();
topology.Text = state.m_IA.Topology.ToString();
if (state.m_IA.Topology > PrimitiveTopology.PatchList)
topology.Text = draw.topology.ToString();
if (draw.topology > PrimitiveTopology.PatchList)
{
int numCPs = (int)state.m_IA.Topology - (int)PrimitiveTopology.PatchList + 1;
int numCPs = (int)draw.topology - (int)PrimitiveTopology.PatchList + 1;
topology.Text = string.Format("PatchList ({0} Control Points)", numCPs);
}
switch (state.m_IA.Topology)
switch (draw.topology)
{
case PrimitiveTopology.PointList:
topologyDiagram.Image = global::renderdocui.Properties.Resources.topo_pointlist;
@@ -708,7 +708,7 @@ namespace renderdocui.Windows.PipelineState
}
}
var node = iabuffers.Nodes.Add(new object[] { "Index", name, state.m_IA.ibuffer.Format.compByteWidth, state.m_IA.ibuffer.Offset, length });
var node = iabuffers.Nodes.Add(new object[] { "Index", name, draw.indexByteWidth, state.m_IA.ibuffer.Offset, length });
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
@@ -2505,14 +2505,20 @@ namespace renderdocui.Windows.PipelineState
}
}
string ifmt = "UNKNOWN";
if (m_Core.CurDrawcall.indexByteWidth == 2)
ifmt = "R16_UINT";
if (m_Core.CurDrawcall.indexByteWidth == 4)
ifmt = "R32_UINT";
ExportHTMLTable(writer, new string[] { "Buffer", "Format", "Offset", "Byte Length" },
new object[] { name, ia.ibuffer.Format.ToString(), ia.ibuffer.Offset.ToString(), length.ToString() });
new object[] { name, ifmt, ia.ibuffer.Offset.ToString(), length.ToString() });
}
writer.WriteStartElement("p");
writer.WriteEndElement();
ExportHTMLTable(writer, new string[] { "Primitive Topology" }, new object[] { ia.Topology.Str() });
ExportHTMLTable(writer, new string[] { "Primitive Topology" }, new object[] { m_Core.CurDrawcall.topology.Str() });
}
private void ExportHTML(XmlTextWriter writer, D3D11PipelineState.ShaderStage sh)
@@ -322,15 +322,15 @@ namespace renderdocui.Windows.PipelineState
inputLayouts.NodesSelection.Clear();
inputLayouts.EndUpdate();
topology.Text = state.m_VtxIn.Topology.ToString();
if (state.m_VtxIn.Topology > PrimitiveTopology.PatchList)
topology.Text = draw.topology.ToString();
if (draw.topology > PrimitiveTopology.PatchList)
{
int numCPs = (int)state.m_VtxIn.Topology - (int)PrimitiveTopology.PatchList + 1;
int numCPs = (int)draw.topology - (int)PrimitiveTopology.PatchList + 1;
topology.Text = string.Format("PatchList ({0} Control Points)", numCPs);
}
switch (state.m_VtxIn.Topology)
switch (draw.topology)
{
case PrimitiveTopology.PointList:
topologyDiagram.Image = global::renderdocui.Properties.Resources.topo_pointlist;
@@ -373,7 +373,7 @@ namespace renderdocui.Windows.PipelineState
{
if (ibufferUsed || showDisabled.Checked)
{
string ptr = "Buffer " + state.m_VtxIn.ibuffer.Buffer.ToString();
string ptr = "Buffer " + state.m_VtxIn.ibuffer.ToString();
string name = ptr;
UInt32 length = 1;
@@ -384,23 +384,23 @@ namespace renderdocui.Windows.PipelineState
for (int t = 0; t < bufs.Length; t++)
{
if (bufs[t].ID == state.m_VtxIn.ibuffer.Buffer)
if (bufs[t].ID == state.m_VtxIn.ibuffer)
{
name = bufs[t].name;
length = bufs[t].length;
}
}
var node = iabuffers.Nodes.Add(new object[] { "Index", name, state.m_VtxIn.ibuffer.Format.compByteWidth, state.m_VtxIn.ibuffer.Offset, length });
var node = iabuffers.Nodes.Add(new object[] { "Index", name, draw.indexByteWidth, 0, length });
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
node.Tag = state.m_VtxIn.ibuffer.Buffer;
node.Tag = state.m_VtxIn.ibuffer;
if (!ibufferUsed)
InactiveRow(node);
if (state.m_VtxIn.ibuffer.Buffer == ResourceId.Null)
if (state.m_VtxIn.ibuffer == ResourceId.Null)
EmptyRow(node);
}
}
@@ -413,7 +413,7 @@ namespace renderdocui.Windows.PipelineState
node.Image = global::renderdocui.Properties.Resources.action;
node.HoverImage = global::renderdocui.Properties.Resources.action_hover;
node.Tag = state.m_VtxIn.ibuffer.Buffer;
node.Tag = state.m_VtxIn.ibuffer;
EmptyRow(node);