Beispiel #1
0
        public void GetData()
        {
            if (this.hasrun == false)
            {
                return;
            }

            DeviceContext ctx = this.context.CurrentDeviceContext;

            while (!ctx.IsDataAvailable(this.tstart))
            {
            }
            while (!ctx.IsDataAvailable(this.tend))
            {
            }
            while (!ctx.IsDataAvailable(this.tsdis))
            {
            }

            Int64 startTime         = ctx.GetData <Int64>(this.tstart);
            Int64 endTime           = ctx.GetData <Int64>(this.tend);
            TimestampQueryData data = ctx.GetData <TimestampQueryData>(this.tsdis);

            float time = 0.0f;

            if (data.IsDisjointed == false)
            {
                Int64 delta     = endTime - startTime;
                float frequency = (float)data.Frequency;
                time = ((float)delta / frequency) * 1000.0f;

                this.Elapsed = time;
            }
        }
Beispiel #2
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];
            }
        }