diff --git a/renderdocui/Code/FormatElement.cs b/renderdocui/Code/FormatElement.cs index 33b59bcd8..65185ae14 100644 --- a/renderdocui/Code/FormatElement.cs +++ b/renderdocui/Code/FormatElement.cs @@ -325,7 +325,7 @@ namespace renderdocui.Code return ret; } - static public FormatElement[] ParseFormatString(string formatString, bool tightPacking, out string errors) + static public FormatElement[] ParseFormatString(string formatString, UInt64 maxLen, bool tightPacking, out string errors) { var elems = new List(); @@ -586,6 +586,11 @@ namespace renderdocui.Code var fmt = new ResourceFormat(FormatComponentType.UInt, 4, 4); + if (maxLen > 0 && maxLen < 16) + fmt.compCount = 1; + if (maxLen > 0 && maxLen < 4) + fmt.compByteWidth = 1; + elems.Add(new FormatElement("data", 0, 0, false, 1, false, 1, fmt, true)); } diff --git a/renderdocui/Windows/BufferViewer.cs b/renderdocui/Windows/BufferViewer.cs index 0ebb6a7ee..caa79142d 100644 --- a/renderdocui/Windows/BufferViewer.cs +++ b/renderdocui/Windows/BufferViewer.cs @@ -677,12 +677,14 @@ namespace renderdocui.Windows m_FormatText = formatString; + UInt64 len = 0; Text = "Buffer Contents"; foreach (var b in m_Core.CurBuffers) { if (b.ID == id) { Text = b.name + " - Contents"; + len = b.byteSize; break; } } @@ -691,7 +693,7 @@ namespace renderdocui.Windows string errors = ""; - FormatElement[] elems = FormatElement.ParseFormatString(formatString, true, out errors); + FormatElement[] elems = FormatElement.ParseFormatString(formatString, len, true, out errors); input.Strides = new uint[] { elems.Last().offset + elems.Last().ByteSize }; input.Buffers = new ResourceId[] { isBuffer ? id : ResourceId.Null, isBuffer ? ResourceId.Null : id }; diff --git a/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs index 2aca4efcd..3040c01a8 100644 --- a/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs +++ b/renderdocui/Windows/Dialogs/ConstantBufferPreviewer.cs @@ -406,7 +406,7 @@ namespace renderdocui.Controls { string errors = ""; - m_FormatOverride = FormatElement.ParseFormatString(formatText, false, out errors); + m_FormatOverride = FormatElement.ParseFormatString(formatText, 0, false, out errors); if (m_FormatSpecifier != null) m_FormatSpecifier.SetErrors(errors);