Example #1
0
 public ProfilerTreeMember()
 {
     m_ChildMembers = new List <ProfilerTreeMember>();
     m_Parent       = null;
     m_Name         = "invalid";
     m_Time         = 0.0;
 }
Example #2
0
 public ProfilerTreeMember()
 {
     m_ChildMembers = new List<ProfilerTreeMember>();
     m_Parent = null;
     m_Name = "invalid";
     m_Time = 0.0;
 }
Example #3
0
        public static void EndFrameProfiling(DeviceContext context)
        {
            PendingFrameQueries pendingFrame = new PendingFrameQueries();

            pendingFrame.m_DisjointQueryId = m_CurrentDisjointQuery;
            pendingFrame.m_BeginQuery      = m_CurrentFrameFirstQuery;
            pendingFrame.m_EndQuery        = m_CurrentQuery;

            EndProfilePoint(context);

            if (m_QueriesStack.Count != 0)
            {
                throw new Exception("Wrong profile point count! Did you forget about EndProfilePoint?");
            }

            context.End(m_DisjointQueries[m_CurrentDisjointQuery]);

            m_PendingFrames.Enqueue(pendingFrame);

            IncrementCurrentDisjointQuery();

            // Time to fetch prev frames!
            if (m_PendingFrames.Count > 4)
            {
                pendingFrame = m_PendingFrames.Dequeue();
                TimestampQueryData disjointData = context.GetData <TimestampQueryData>(m_DisjointQueries[pendingFrame.m_DisjointQueryId]);
                ProfilerTreeMember parent       = new ProfilerTreeMember();
                ProfilerTreeMember frameParent  = parent;

                for (int queryIterator = pendingFrame.m_BeginQuery; queryIterator != (pendingFrame.m_EndQuery + 1) % MAX_HW_QUERIES; queryIterator = (queryIterator + 1) % MAX_HW_QUERIES)
                {
                    if (m_CorrespondingQueryEnds[queryIterator] != Int32.MaxValue)
                    {
                        var  profilerObject        = new ProfilerTreeMember();
                        int  correspondingEnd      = m_CorrespondingQueryEnds[queryIterator];
                        long beginProfilePointData = context.GetData <long>(m_HWQueries[queryIterator]);
                        long endProfilePointData   = context.GetData <long>(m_HWQueries[correspondingEnd]);

                        profilerObject.m_Time   = (double)(endProfilePointData - beginProfilePointData) / (double)disjointData.Frequency * 1000.0;
                        profilerObject.m_Name   = m_HWQueriesDescs[queryIterator];
                        profilerObject.m_Parent = parent;

                        parent.m_ChildMembers.Add(profilerObject);
                        parent = profilerObject;
                    }
                    else
                    {
                        parent = parent.m_Parent;
                        if (parent == null)
                        {
                            throw new Exception("Error while constructing profiler tree");
                        }
                    }
                }
                if (frameParent.m_ChildMembers.Count < 1)
                {
                    throw new Exception("Error while constructing profiler tree");
                }

                m_CurrentFrameProfilerTree = frameParent.m_ChildMembers[0];
            }
        }
Example #4
0
        public static void EndFrameProfiling(DeviceContext context)
        {
            PendingFrameQueries pendingFrame = new PendingFrameQueries();

            pendingFrame.m_DisjointQueryId = m_CurrentDisjointQuery;
            pendingFrame.m_BeginQuery = m_CurrentFrameFirstQuery;
            pendingFrame.m_EndQuery = m_CurrentQuery;

            EndProfilePoint(context);

            if(m_QueriesStack.Count != 0)
            {
                throw new Exception("Wrong profile point count! Did you forget about EndProfilePoint?");
            }

            context.End(m_DisjointQueries[m_CurrentDisjointQuery]);

            m_PendingFrames.Enqueue(pendingFrame);

            IncrementCurrentDisjointQuery();
            
            // Time to fetch prev frames!
            if (m_PendingFrames.Count > 4)
            {
                pendingFrame = m_PendingFrames.Dequeue();
                TimestampQueryData disjointData = context.GetData<TimestampQueryData>(m_DisjointQueries[pendingFrame.m_DisjointQueryId]);
                ProfilerTreeMember parent = new ProfilerTreeMember();
                ProfilerTreeMember frameParent = parent;

                for (int queryIterator = pendingFrame.m_BeginQuery; queryIterator != (pendingFrame.m_EndQuery + 1) % MAX_HW_QUERIES; queryIterator = (queryIterator + 1) % MAX_HW_QUERIES)
                {
                    if (m_CorrespondingQueryEnds[queryIterator] != Int32.MaxValue)
                    {
                        var profilerObject = new ProfilerTreeMember();
                        int correspondingEnd = m_CorrespondingQueryEnds[queryIterator];
                        long beginProfilePointData = context.GetData<long>(m_HWQueries[queryIterator]);
                        long endProfilePointData = context.GetData<long>(m_HWQueries[correspondingEnd]);

                        profilerObject.m_Time = (double)(endProfilePointData - beginProfilePointData) / (double)disjointData.Frequency * 1000.0;
                        profilerObject.m_Name = m_HWQueriesDescs[queryIterator];
                        profilerObject.m_Parent = parent;

                        parent.m_ChildMembers.Add(profilerObject);
                        parent = profilerObject;
                    }
                    else
                    {
                        parent = parent.m_Parent;
                        if (parent == null)
                        {
                            throw new Exception("Error while constructing profiler tree");
                        }
                    }
                }
                if (frameParent.m_ChildMembers.Count < 1)
                {
                    throw new Exception("Error while constructing profiler tree");
                }

                m_CurrentFrameProfilerTree = frameParent.m_ChildMembers[0];
            }
        }