From 1b4bf97574c96031c6393d975f942e61a99c66f1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 28 Jan 2015 02:23:30 +0000 Subject: [PATCH] Fix for instance rates not being accounted for on vertex inputs --- renderdocui/Code/FormatElement.cs | 11 +++++++---- renderdocui/Windows/BufferViewer.cs | 11 +++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs index b94166358..c406ac0ce 100644 --- a/renderdocui/Code/FormatElement.cs +++ b/renderdocui/Code/FormatElement.cs @@ -40,6 +40,7 @@ namespace renderdocui.Code buffer = 0; offset = 0; perinstance = false; + instancerate = 1; rowmajor = false; matrixdim = 0; format = new ResourceFormat(); @@ -47,13 +48,14 @@ namespace renderdocui.Code systemValue = SystemAttribute.None; } - public FormatElement(string Name, int buf, uint offs, bool pi, bool rowMat, uint matDim, ResourceFormat f, bool h) + public FormatElement(string Name, int buf, uint offs, bool pi, int ir, bool rowMat, uint matDim, ResourceFormat f, bool h) { name = Name; buffer = buf; offset = offs; format = f; perinstance = pi; + instancerate = ir; rowmajor = rowMat; matrixdim = matDim; hex = h; @@ -512,7 +514,7 @@ namespace renderdocui.Code if (arrayCount == 1) { - FormatElement elem = new FormatElement(name, 0, offset, false, row_major, matrixCount, fmt, hex); + FormatElement elem = new FormatElement(name, 0, offset, false, 1, row_major, matrixCount, fmt, hex); uint advance = elem.ByteSize; @@ -545,7 +547,7 @@ namespace renderdocui.Code 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); + FormatElement elem = new FormatElement(String.Format("{0}[{1}]", name, a), 0, offset, false, 1, row_major, matrixCount, fmt, hex); elems.Add(elem); @@ -568,7 +570,7 @@ namespace renderdocui.Code var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4); - elems.Add(new FormatElement("data", 0, 0, false, false, 1, fmt, true)); + elems.Add(new FormatElement("data", 0, 0, false, 1, false, 1, fmt, true)); } return elems.ToArray(); @@ -578,6 +580,7 @@ namespace renderdocui.Code public int buffer; public uint offset; public bool perinstance; + public int instancerate; public bool rowmajor; public uint matrixdim; public ResourceFormat format; diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index d368e9303..891c70478 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -818,6 +818,7 @@ namespace renderdocui.Windows a.VertexBuffer, a.RelativeByteOffset, a.PerInstance, + a.InstanceRate, false, // row major matrix 1, // matrix dimension a.Format, @@ -1374,8 +1375,9 @@ namespace renderdocui.Windows Stream strm = state.m_Stream[bufferFormats[el].buffer]; BinaryReader read = state.m_Reader[bufferFormats[el].buffer]; - uint offs = input.Strides[bufferFormats[el].buffer] * (bufferFormats[el].perinstance ? instance : index) + - bufferFormats[el].offset; + uint offs = input.Strides[bufferFormats[el].buffer] * + (bufferFormats[el].perinstance ? (instance/(uint)bufferFormats[el].instancerate) : index) + + bufferFormats[el].offset; if (!MeshView) offs += ByteOffset; @@ -1637,8 +1639,9 @@ namespace renderdocui.Windows Stream strm = state.m_Stream[bufferFormats[el].buffer]; BinaryReader read = state.m_Reader[bufferFormats[el].buffer]; - uint offs = input.Strides[bufferFormats[el].buffer] * (bufferFormats[el].perinstance ? instance : index) + - bufferFormats[el].offset; + uint offs = input.Strides[bufferFormats[el].buffer] * + (bufferFormats[el].perinstance ? (instance / (uint)bufferFormats[el].instancerate) : index) + + bufferFormats[el].offset; if (!MeshView) offs += ByteOffset;