From 48a03ae21ffc8ab03dcccfd2c2ef45923e2cd322 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 27 Nov 2015 20:42:42 +0100 Subject: [PATCH] Only fetch the PostVS data needed for this draw, not the whole buffer * For instanced draws where there are many instance and each instance is a lot, this saves fetching a *ton* of redundant data. --- renderdocui/Windows/BufferViewer.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index 05395bb5c..cb2da4664 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -967,8 +967,6 @@ namespace renderdocui.Windows } else { - ret.Buffers[0] = r.GetBufferData(ret.PostVS.buf, ret.PostVS.offset, 0); - ret.Topology = ret.PostVS.topo; ret.IndexCount = ret.PostVS.numVerts; @@ -982,6 +980,8 @@ namespace renderdocui.Windows ret.Indices = null; ret.DataIndices = null; + uint maxIndex = Math.Max(ret.IndexCount, 1) - 1; + if (ret.PostVS.buf != ResourceId.Null && type == MeshDataStage.VSOut && (input.Drawcall.flags & DrawcallFlags.UseIBuffer) > 0 && input.IndexBuffer != ResourceId.Null) { @@ -1052,8 +1052,20 @@ namespace renderdocui.Windows Buffer.BlockCopy(rawidxs, 0, ret.DataIndices, 0, ret.DataIndices.Length * sizeof(uint)); } } + + maxIndex = 0; + foreach (var i in ret.DataIndices) + { + if (i == input.IndexRestartValue && input.IndexRestart) + continue; + + maxIndex = Math.Max(maxIndex, i); + } } + if (ret.PostVS.buf != ResourceId.Null) + ret.Buffers[0] = r.GetBufferData(ret.PostVS.buf, ret.PostVS.offset, (maxIndex + 1) * ret.PostVS.stride); + return ret; } else if (input.Buffers != null && m_Output != null)