当前位置: 首页>>代码示例>>C#>>正文


C# DeviceContext.GetData方法代码示例

本文整理汇总了C#中DeviceContext.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceContext.GetData方法的具体用法?C# DeviceContext.GetData怎么用?C# DeviceContext.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DeviceContext的用法示例。


在下文中一共展示了DeviceContext.GetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetElapsedMilliseconds

        public double GetElapsedMilliseconds(DeviceContext context)
        {

            long timestampStart;
            long timestampEnd;
            QueryDataTimestampDisjoint disjointData;

            while (!context.GetData(queryTimeStampStart, AsynchronousFlags.None, out timestampStart)) ;
            while (!context.GetData(queryTimeStampEnd, AsynchronousFlags.None, out timestampEnd)) ;
            while (!context.GetData(queryTimeStampDisjoint, AsynchronousFlags.None, out disjointData)) ;

            if (disjointData.Disjoint)
                return -1;
            long delta = timestampEnd - timestampStart;
            return (delta * 1000.0) / disjointData.Frequency;
        }
开发者ID:MaybeMars,项目名称:SharpDX-Samples,代码行数:16,代码来源:GPUProfiler.cs

示例2: EndFrameProfiling

        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];
            }
        }
开发者ID:shoff,项目名称:CSharpRenderer,代码行数:62,代码来源:GPUProfiler.cs


注:本文中的DeviceContext.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。