示例#1
0
        internal static MyOcclusionQueryRender Get(string debugName)
        {
            var query = new MyOcclusionQueryRender()
            {
                Query         = MyQueryFactory.CreateOcclusionQuery(debugName),
                Size          = 1.0f,
                NextQueryTime = 0
            };

            m_queries.Add(query);
            return(query);
        }
示例#2
0
        internal void Clear()
        {
            if (m_disjoint != null)
            {
                MyQueryFactory.RelaseDisjointQuery(m_disjoint);
                m_disjoint = null;
            }

            while (m_issued.Count > 0)
            {
                MyQueryFactory.RelaseTimestampQuery(m_issued.Dequeue().m_query);
            }
        }
示例#3
0
        static void GatherFrame(MyFrameProfiling frame)
        {
            QueryDataTimestampDisjoint disjoint = MyImmediateRC.RC.DeviceContext.GetData <QueryDataTimestampDisjoint>(frame.m_disjoint.m_query, AsynchronousFlags.DoNotFlush);

#if UNSHARPER
            if (!disjoint.Disjoint.value)
#else
            if (!disjoint.Disjoint)
#endif
            {
                var    freq    = disjoint.Frequency;
                double invFreq = 1.0 / (double)freq;

                m_timestampStack.Clear();

                int stackDepth = 0;

                while (frame.m_issued.Count > 0)
                {
                    var q = frame.m_issued.Dequeue();

                    ulong timestamp;
                    MyImmediateRC.RC.DeviceContext.GetData <ulong>(q.m_query, AsynchronousFlags.DoNotFlush, out timestamp);

                    if (q.m_info == MyIssuedQueryEnum.BlockStart)
                    {
                        stackDepth++;
                        MyRender11.GetRenderProfiler().GPU_StartProfilingBlock(q.m_tag);
                        m_timestampStack.Push(timestamp);
                    }
                    else if (q.m_info == MyIssuedQueryEnum.BlockEnd)
                    {
                        stackDepth--;
                        var start = m_timestampStack.Pop();
                        var time  = (timestamp - start) * invFreq;

                        // tick is 100 nanoseconds = 10^-7 second
                        MyRender11.GetRenderProfiler().GPU_EndProfilingBlock(0, MyTimeSpan.FromSeconds(time));
                    }

                    Debug.Assert(stackDepth >= 0);

                    MyQueryFactory.RelaseTimestampQuery(q.m_query);
                }

                Debug.Assert(stackDepth == 0);
            }

            frame.Clear();
        }
示例#4
0
        internal void EndProfilingBlock()
        {
            var q = MyQueryFactory.CreateTimestampQuery();

            End(q);
            var info = new MyIssuedQuery(q, "", MyIssuedQueryEnum.BlockEnd);

            if (m_deferred)
            {
                ProfilingQueries.m_issued.Enqueue(info);
            }
            else
            {
                MyGpuProfiler.IC_Enqueue(info);
            }
        }
示例#5
0
        internal void BeginProfilingBlock(string tag)
        {
            var q = MyQueryFactory.CreateTimestampQuery();

            End(q);
            var info = new MyIssuedQuery(q, tag, MyIssuedQueryEnum.BlockStart);

            if (m_deferred)
            {
                ProfilingQueries.m_issued.Enqueue(info);
            }
            else
            {
                MyGpuProfiler.IC_Enqueue(info);
            }
        }
示例#6
0
        internal static void StartFrame()
        {
            if (m_pooledFrames.Count == 0)
            {
                WaitForLastFrame();
                GatherFinishedFrames();
            }

            m_currentFrame = m_pooledFrames.Dequeue();

            var disjoint = MyQueryFactory.CreateDisjointQuery();

            MyImmediateRC.RC.Begin(disjoint);
            m_currentFrame.m_disjoint = disjoint;

            IC_BeginBlock("Frame");
        }
示例#7
0
        internal void EndProfilingBlock()
        {
            var q = MyQueryFactory.CreateTimestampQuery();

            End(q);
            var info = new MyIssuedQuery(q, "", MyIssuedQueryEnum.BlockEnd);

            if (m_deferred)
            {
                ProfilingQueries.m_issued.Enqueue(info);
            }
            else
            {
                MyGpuProfiler.IC_Enqueue(info);
            }
            // this tag will be visible in NSight because of this call:
            m_annotation.EndEvent();
        }
示例#8
0
        /// <summary>
        /// BeginProfilingBlock that works even when PerformanceProfilingSymbol is false
        /// </summary>
        internal void BeginProfilingBlockAlways(string tag)
        {
            var q = MyQueryFactory.CreateTimestampQuery();

            End(q);
            var info = new MyIssuedQuery(q, tag, MyIssuedQueryEnum.BlockStart);

            if (m_deferred)
            {
                ProfilingQueries.m_issued.Enqueue(info);
            }
            else
            {
                MyGpuProfiler.IC_Enqueue(info);
            }
            // this tag will be visible in NSight because of this call:
            m_annotation.BeginEvent(tag);
        }
示例#9
0
 internal void Destroy()
 {
     Ignore = Running;
     MyQueryFactory.RelaseOcclusionQuery(this);
 }