Exemplo n.º 1
0
        public void GoToMarker(AssetLoadMarker marker)
        {
            int frame, sampleId;

            if (selectedFrameSetup == AssetLoadingFrameSetup.ThisFrame)
            {
                frame = this.GetSelectedFrame();
                // Get the index into the list of sampleIds for this frame
                int sampleIdIndex = frame - marker.firstFrameIndex;
                sampleId = marker.sampleIds[sampleIdIndex];
            }
            else
            {
                frame    = marker.firstFrameIndex;
                sampleId = marker.sampleIds[0];
            }

            var threadSubStr = marker.threadName.Split('.');

            if (threadSubStr.Length < 2) // Main thread and Render thread don't have a thread group
            {
                OpenMarkerInCpuModule(frame, null, threadSubStr[0], (ulong)marker.threadId, marker.threadIndex, sampleId);
            }
            else
            {
                OpenMarkerInCpuModule(frame, threadSubStr[0], threadSubStr[1], (ulong)marker.threadId, marker.threadIndex, sampleId);
            }
        }
Exemplo n.º 2
0
 internal static void LoadSceneObjectsMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // Path name, some kind of count
     marker.filename   = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.sourceName = Path.GetFileName(marker.filename);
     marker.subsystem  = "SceneObjects";
 }
Exemplo n.º 3
0
 internal static void LoadAllAssetsMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // AssetBundle Name, Asset Name
     marker.sourceName = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.assetName  = "LoadAll";
     marker.subsystem  = "Asset in AssetBundle";
 }
Exemplo n.º 4
0
 internal static void ReadObjectMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // path, offset, size bytes
     marker.filename   = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.sizeBytes  = (ulong)frameData.GetSampleMetadataAsLong(sampleIndex, 2);
     marker.subsystem  = frameData.GetSampleMetadataAsString(sampleIndex, 3);
     marker.sourceName = Path.GetFileName(marker.filename);
 }
Exemplo n.º 5
0
 internal static void LoadSceneMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // Scene path, Scene Name
     marker.sourceName = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.assetName  = frameData.GetSampleMetadataAsString(sampleIndex, 1);
     marker.subsystem  = "Scene";
     marker.filename   = marker.sourceName;
 }
Exemplo n.º 6
0
 internal static void AsyncReadManagerMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // Path, size, subsystem
     marker.filename   = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.sizeBytes  = (ulong)frameData.GetSampleMetadataAsLong(sampleIndex, 1);
     marker.subsystem  = frameData.GetSampleMetadataAsString(sampleIndex, 2);
     marker.assetName  = frameData.GetSampleMetadataAsString(sampleIndex, 3);
     marker.sourceName = Path.GetFileName(marker.filename);
 }
Exemplo n.º 7
0
 internal static void LoadAssetSyncMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     // AssetBundle Name, Asset Name
     marker.sourceName = frameData.GetSampleMetadataAsString(sampleIndex, 0);
     marker.assetName  = frameData.GetSampleMetadataAsString(sampleIndex, 1);
     if (string.IsNullOrWhiteSpace(marker.assetName))
     {
         marker.assetName = "(All)";
     }
     marker.subsystem = "Asset in AssetBundle";
 }
Exemplo n.º 8
0
        void ShowContextMenu(Rect cellRect, AssetLoadMarker marker /*, GUIContent content*/) // Keep these in case we add 'Copy to Clipboard' later
        {
            Event current = Event.current;

            if (cellRect.Contains(current.mousePosition) && current.type == EventType.ContextClick)
            {
                GenericMenu menu;
                menu = GenerateActiveContextMenu(marker /*, current, content*/);

                menu.ShowAsContext();

                current.Use();
            }
        }
Exemplo n.º 9
0
        GenericMenu GenerateActiveContextMenu(AssetLoadMarker marker /*, Event evt, GUIContent content*/) // Keep these in case we add 'Copy to Clipboard' later
        {
            GenericMenu menu = new GenericMenu();

            menu.AddItem(Styles.goToMarker, false, () => m_ProfilerView.GoToMarker(marker));
            menu.AddSeparator("");
            if (marker.frameCount == 1)
            {
                menu.AddDisabledItem(Styles.goToFirstFrame);
                menu.AddDisabledItem(Styles.goToLastFrame);
            }
            else
            {
                menu.AddItem(Styles.goToFirstFrame, false, () => m_ProfilerView.GoToFrameInModule(marker.firstFrameIndex));
                menu.AddItem(Styles.goToLastFrame, false, () => m_ProfilerView.GoToFrameInModule(marker.lastFrameIndex));
            }

            menu.AddSeparator("");
            if (!string.IsNullOrEmpty(marker.sourceName))
            {
                menu.AddItem(Styles.filterToThisSource, false, () => m_ProfilerView.FilterBy(marker.sourceName));
            }
            else
            {
                menu.AddDisabledItem(Styles.filterToThisSource);
            }

            if (!string.IsNullOrEmpty(marker.assetName))
            {
                menu.AddItem(Styles.filterToThisAsset, false, () => m_ProfilerView.FilterBy(marker.assetName));
            }
            else
            {
                menu.AddDisabledItem(Styles.filterToThisAsset);
            }

            return(menu);
        }
Exemplo n.º 10
0
 public AssetMarkerTreeViewItem(int id, int depth, string displayName, AssetLoadMarker data) : base(id, depth, displayName)
 {
     assetLoadingMarker = data;
 }
Exemplo n.º 11
0
        public static void PullDataStatic(ref AssetCaptureData captureData, Dictionary <string, AssetMarkerInfo> markers, ref Dictionary <string, int> markerToIDMap, int firstFrameIndex, int lastFrameIndex)
        {
            string error = null;

            var depthStack = new Stack <int>();

            captureData.m_AssetLoadMarkers.Clear();
            captureData.m_StartTimeNs = ulong.MaxValue;
            captureData.m_EndTimeNs   = ulong.MinValue;

            ProfilerFrameDataIterator frameIter = new ProfilerFrameDataIterator();
            double nsFrameStart;

            for (int frameIndex = firstFrameIndex; frameIndex <= lastFrameIndex; ++frameIndex)
            {
                frameIter.SetRoot(frameIndex, 0);

                int threadCount = frameIter.GetThreadCount(frameIndex);

                // iterate over the threads
                for (int threadIndex = 0; threadIndex < threadCount; ++threadIndex)
                {
                    using (RawFrameDataView frameData = ProfilerDriver.GetRawFrameDataView(frameIndex, threadIndex))
                    {
                        if (!frameData.valid)
                        {
                            break;
                        }

                        string fullThreadName = GetFullThreadName(frameData.threadGroupName, frameData.threadName);

                        nsFrameStart = frameData.frameStartTimeNs;
                        if (frameIndex == firstFrameIndex) // This may only need to be done for the main thread, but does the main thread have a guaranteed index?
                        {
                            if (captureData.m_StartTimeNs > nsFrameStart)
                            {
                                captureData.m_StartTimeNs = nsFrameStart; // We will assume that this will only be true for the first frame and thus not be changed, and proceed to use this value as the start time
                            }
                        }

                        GetMarkerIDs(frameData, markers, ref markerToIDMap);

                        depthStack.Clear();
                        // iterate over the samples to collect up any markers
                        int sampleCount = frameData.sampleCount;
                        for (int i = 0; i < sampleCount; ++i)
                        {
                            int markerId = frameData.GetSampleMarkerId(i);

                            if (markerId != FrameDataView.invalidMarkerId && markerToIDMap.ContainsValue(markerId))
                            {
                                s_AddNewMarker.Begin();
                                string markerName = frameData.GetMarkerName(markerId);
                                Assert.IsTrue(markers.ContainsKey(markerName), string.Format("Marker {0} is not present in requested markers.", markerName));

                                // if the marker isn't a continuation of a previous marker, add a new asset load marker
                                if (!CheckForContinuationMarker(frameData, ref captureData, threadIndex, markerId, frameIndex, i))
                                {
                                    AssetLoadMarker assetLoadMarker = new AssetLoadMarker();

                                    // fill in contexts from Metadata
                                    AssetMarkerInfo markerInfo = markers[markerName];
                                    if (markerInfo.metadataCount == frameData.GetSampleMetadataCount(i))
                                    {
                                        markerInfo.metaDataFiller(ref assetLoadMarker, frameData, i);
                                    }
                                    else if (string.IsNullOrEmpty(error)) // Check the error is only shown once
                                    {
                                        error = $"Some markers, such as '{markerName}', have unexpected metadata. This may be because of opening a profile captured with an older version of Unity. Certain values may be missing.";
                                        Debug.LogWarning(error);
                                    }

                                    ulong markerStartTimeNs = frameData.GetSampleStartTimeNs(i);
                                    ulong sampleLengthNs    = frameData.GetSampleTimeNs(i);

                                    assetLoadMarker.markerId = markerId;

                                    if (string.IsNullOrEmpty(assetLoadMarker.filename))
                                    {
                                        assetLoadMarker.readablePath     = "Unknown path";
                                        assetLoadMarker.readableFileName = "?";
                                    }
                                    else
                                    {
                                        assetLoadMarker.readablePath     = assetLoadMarker.filename;
                                        assetLoadMarker.readableFileName = Path.GetFileName(assetLoadMarker.readablePath);
                                        if (assetLoadMarker.readablePath.Contains("/Analytics/"))
                                        {
                                            assetLoadMarker.readableFileName += " (Analytics)";
                                        }
                                    }

                                    assetLoadMarker.startNs  = markerStartTimeNs;
                                    assetLoadMarker.lengthNs = sampleLengthNs;
                                    assetLoadMarker.endNs    = markerStartTimeNs + sampleLengthNs;

                                    assetLoadMarker.startTimeMs = (markerStartTimeNs - captureData.m_StartTimeNs) * 0.000001; // could this go negative?
                                    assetLoadMarker.ms          = assetLoadMarker.lengthNs * 0.000001;
                                    assetLoadMarker.frameCount  = 1;

                                    assetLoadMarker.type            = markerInfo.assetMarkerType;
                                    assetLoadMarker.markerName      = markerName;
                                    assetLoadMarker.threadName      = fullThreadName;
                                    assetLoadMarker.firstFrameIndex = frameIndex;
                                    assetLoadMarker.lastFrameIndex  = frameIndex;
                                    assetLoadMarker.threadIndex     = threadIndex;
                                    assetLoadMarker.threadId        = frameData.threadId;
                                    assetLoadMarker.sampleIds.Add(i);
                                    assetLoadMarker.depth = 1 + depthStack.Count;

                                    captureData.m_AssetLoadMarkers.Add(assetLoadMarker);
                                }

                                s_AddNewMarker.End();
                            }
                            UpdateDepthStack(ref depthStack, frameData.GetSampleChildrenCount(i));
                        }
                    }
                }
            }
            frameIter.Dispose();
        }
Exemplo n.º 12
0
 internal static void UnloadUnusedAssetsMetadataFiller(ref AssetLoadMarker marker, RawFrameDataView frameData, int sampleIndex)
 {
     marker.sourceName = "UnloadUnusedAssets";
     marker.subsystem  = "Assets";
 }