internal RawFrameDataView GetRenderThread(RawFrameDataView frameDataView) { //Find render thread using (ProfilerFrameDataIterator frameDataIterator = new ProfilerFrameDataIterator()) { var threadCount = frameDataIterator.GetThreadCount(frameDataView.frameIndex); for (int i = 0; i < threadCount; ++i) { RawFrameDataView frameData = ProfilerDriver.GetRawFrameDataView(frameDataView.frameIndex, i); if (frameData.threadName == "Render Thread") { return(frameData); } else { frameData.Dispose(); } } // If there's no render thread, metadata was pushed on main thread return(frameDataView); } }
internal void DrawUIPane(IProfilerWindowController win) { if (Styles.backgroundStyle == null) { Styles.CreateStyles(); } //make sure all background textures exist Styles.CheckBackgroundTextures(); EditorGUILayout.BeginVertical(); var rect = EditorGUILayout.GetControlRect(GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true)); const int padding = 1; Rect aggregateHeader = rect; aggregateHeader.width = Mathf.Min(434, rect.width); aggregateHeader.height = 34; Rect aggregateData = aggregateHeader; aggregateData.y += aggregateHeader.height + padding; float aggregateBoxHeight = rect.height / 2 - aggregateHeader.height - padding * 2; aggregateData.height = aggregateBoxHeight; Rect infoBox = new Rect(); if (ProfilerDriver.GetStatisticsAvailabilityState(ProfilerArea.VirtualTexturing, win.GetActiveVisibleFrameIndex()) == 0) { GUI.Label(aggregateHeader, "No Virtual Texturing data was collected."); EditorGUILayout.EndVertical(); return; } GUI.Box(rect, "", Styles.backgroundStyle); using (RawFrameDataView frameDataView = ProfilerDriver.GetRawFrameDataView(win.GetActiveVisibleFrameIndex(), 0)) { if (frameDataView.valid) { Assert.IsTrue(frameDataView.threadName == "Main Thread"); RawFrameDataView fRender = GetRenderThread(frameDataView); //system statistics var stringBuilder = new StringBuilder(1024); int requiredTiles = (int)GetCounterValue(frameDataView, "Required Tiles"); stringBuilder.AppendLine($" Tiles required this frame: {requiredTiles}"); stringBuilder.AppendLine($" Max Cache Mip Bias: {GetCounterValueAsFloat(frameDataView, "Max Cache Mip Bias")}"); stringBuilder.AppendLine($" Max Cache Demand: {GetCounterValue(frameDataView, "Max Cache Demand")}%"); stringBuilder.AppendLine($" Total CPU Cache Size: {EditorUtility.FormatBytes(GetCounterValue(frameDataView, "Total CPU Cache Size"))}"); stringBuilder.AppendLine($" Total GPU Cache Size: {EditorUtility.FormatBytes(GetCounterValue(frameDataView, "Total GPU Cache Size"))}"); stringBuilder.AppendLine($" Atlases: {GetCounterValue(frameDataView, "Atlases")}"); string aggregatedText = stringBuilder.ToString(); float aggregateTextHeight = EditorStyles.wordWrappedLabel.CalcHeight(GUIContent.Temp(aggregatedText), rect.width); float actualHeight = Mathf.Max(aggregateBoxHeight, aggregateTextHeight); DrawScrollBackground(new Rect(aggregateData.width - 12, aggregateData.y, 14, aggregateData.height)); GUI.Box(aggregateHeader, " System Statistics", Styles.headerStyle); m_SystemScroll = GUI.BeginScrollView(aggregateData, m_SystemScroll, new Rect(0, 0, aggregateData.width / 2, actualHeight)); GUI.Box(new Rect(0, 0, aggregateData.width, actualHeight), aggregatedText, Styles.statStyle); GUI.EndScrollView(); //player build statistics aggregateHeader.y += aggregateHeader.height + aggregateData.height + padding * 2; aggregateData.y += aggregateHeader.height + aggregateData.height + padding * 2; stringBuilder.Clear(); stringBuilder.AppendLine($" Missing Disk Data: {EditorUtility.FormatBytes(GetCounterValue(frameDataView, "Missing Disk Data"))}"); stringBuilder.AppendLine($" Missing Streaming Tiles: {GetCounterValue(frameDataView, "Missing Streaming Tiles")}"); stringBuilder.AppendLine($" Read From Disk: {EditorUtility.FormatBytes(GetCounterValue(frameDataView, "Read From Disk"))}"); aggregatedText = stringBuilder.ToString(); aggregateTextHeight = EditorStyles.wordWrappedLabel.CalcHeight(GUIContent.Temp(aggregatedText), rect.width); actualHeight = Mathf.Max(aggregateBoxHeight, aggregateTextHeight); DrawScrollBackground(new Rect(aggregateData.width - 12, aggregateData.y, 14, aggregateData.height)); GUI.Box(aggregateHeader, " Player Build Statistics", Styles.headerStyle); m_PlayerScroll = GUI.BeginScrollView(aggregateData, m_PlayerScroll, new Rect(0, 0, aggregateData.width / 2, actualHeight)); GUI.Box(new Rect(0, 0, aggregateData.width, actualHeight), aggregatedText, Styles.statStyle); GUI.EndScrollView(); //PER CACHE DATA Rect perCacheHeader = rect; perCacheHeader.width = rect.width - aggregateHeader.width - padding; perCacheHeader.height = 34; perCacheHeader.x += aggregateHeader.width + padding; Rect formatBox = perCacheHeader; formatBox.height = rect.height - perCacheHeader.height - padding; formatBox.y += perCacheHeader.height + padding; GUI.Box(perCacheHeader, " Per Cache Statistics", Styles.headerStyle); if (m_Header == null || m_HeaderState == null) { Init(); } //Keep using the last VT tick untill a new one is available. if (requiredTiles > 0) { ReadFrameData(fRender); } if (m_SortingChanged) { SortFrameData(); } DrawFormatData(formatBox); if (fRender != frameDataView) { fRender.Dispose(); } } else { GUI.Label(aggregateData, "No frame data available"); } } EditorGUILayout.EndVertical(); infoBox.y = rect.y; infoBox.x = rect.width - 33; infoBox.width = 34; infoBox.height = 34; DrawDocLink(infoBox); }