From 4dcb89966c9238130306c7d7b008101def880ea7 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 2 Mar 2015 13:36:24 +0000 Subject: [PATCH] Fix crash when event browser is hiding empty marker regions * When we figure out which event a marker region should jump to if you select the parent, we want to pick the last valid event ID that isn't just a label. However previously this was being done by iterating over the children and picking the last one and assuming there would be a node of that index - which isn't true in the case where some drawcalls were entirely omitted. It would either index out of bounds, or index incorrectly. --- renderdocui/Windows/EventBrowser.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/renderdocui/Windows/EventBrowser.cs b/renderdocui/Windows/EventBrowser.cs index 2c846d7c7..50c1067c4 100644 --- a/renderdocui/Windows/EventBrowser.cs +++ b/renderdocui/Windows/EventBrowser.cs @@ -46,6 +46,8 @@ namespace renderdocui.Windows public UInt32 frameID = 0; public UInt32 eventID = 0; + public bool marker = false; + public ResourceId defCtx = ResourceId.Null; public UInt32 firstDefEv = 0; public UInt32 lastDefEv = 0; @@ -249,6 +251,7 @@ namespace renderdocui.Windows DeferredEvent def = new DeferredEvent(); def.frameID = m_Core.CurFrame; def.eventID = eventNum; + def.marker = (drawcall.flags & DrawcallFlags.SetMarker) != 0; if (drawcall.context != m_Core.FrameInfo[m_Core.CurFrame].immContextId) { @@ -287,9 +290,10 @@ namespace renderdocui.Windows bool found = false; - for (int i = drawcall.children.Length - 1; i >= 0; i--) + for (int i = drawNode.Nodes.Count - 1; i >= 0; i--) { - if ((drawcall.children[i].flags & DrawcallFlags.SetMarker) == 0) + DeferredEvent t = drawNode.Nodes[i].Tag as DeferredEvent; + if (!t.marker) { drawNode.Tag = drawNode.Nodes[i].Tag; found = true;