private void UpdateInternal() { MyStatToken token; MySimpleProfiler.BeginBlock("UpdateFrame", MySimpleProfiler.ProfilingBlockType.INTERNAL); using (token = Stats.Generic.Measure("BeforeUpdate")) { MyRenderProxy.BeforeUpdate(); } this.m_totalTime = this.m_gameTimer.Elapsed; this.m_updateCounter += (ulong)1L; if (MySession.Static != null) { this.m_simulationTimeWithSpeed += MyTimeSpan.FromMilliseconds(16.666666666666668 * MyFakes.SIMULATION_SPEED); } bool enableNetworkPacketTracking = MyCompilationSymbols.EnableNetworkPacketTracking; this.Update(); if (!IsDedicated) { this.PrepareForDraw(); } using (token = Stats.Generic.Measure("AfterUpdate")) { this.AfterDraw(); } MySimpleProfiler.End("UpdateFrame"); MySimpleProfiler.Commit(); }
private void UpdateInternal() { using (Stats.Generic.Measure("BeforeUpdate")) { ProfilerShort.Begin("UpdateInternal::BeforeUpdate"); VRageRender.MyRenderProxy.BeforeUpdate(); ProfilerShort.End(); } ProfilerShort.Begin("UpdateInternal::Update"); //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Default, "Update Start"); m_updateTime = m_gameTimer.Elapsed; Update(); ProfilerShort.End(); if (!IsDedicated) { ProfilerShort.Begin("UpdateInternal::PrepareForDraw"); PrepareForDraw(); ProfilerShort.End(); } using (Stats.Generic.Measure("AfterUpdate")) { ProfilerShort.Begin("UpdateInternal::AfterUpdate"); VRageRender.MyRenderProxy.AfterUpdate(m_updateTime); ProfilerShort.End(); } ProfilerShort.Commit(); MySimpleProfiler.Commit(); //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Default, "Update End"); }
public override void Simulate() { if (MyPerGameSettings.EnableAi) { if (MyFakes.DEBUG_ONE_VOXEL_PATHFINDING_STEP_SETTING) { if (!MyFakes.DEBUG_ONE_VOXEL_PATHFINDING_STEP) { return; } } else if (MyFakes.DEBUG_ONE_AI_STEP_SETTING) { if (!MyFakes.DEBUG_ONE_AI_STEP) { return; } MyFakes.DEBUG_ONE_AI_STEP = false; } MySimpleProfiler.Begin("AI", MySimpleProfiler.ProfilingBlockType.OTHER, "Simulate"); if (this.m_pathfinding != null) { this.m_pathfinding.Update(); } base.Simulate(); this.m_behaviorTreeCollection.Update(); this.m_botCollection.Update(); MySimpleProfiler.End("Simulate"); } }
public static void Begin(string name) { if (Enabled) { MySimpleProfiler.Begin(prefix + name); } }
public static void End(string name) { if (Enabled) { MySimpleProfiler.End(prefix + name); } }
public override void Simulate() { if (MyPerGameSettings.EnableAi) { // Pathfinding should be updated before the bots are simulated, so that the changes // in meshes and voxels are reflected in the new meshes if the bots want to do some pathfinding if (MyFakes.DEBUG_ONE_VOXEL_PATHFINDING_STEP_SETTING) { if (!MyFakes.DEBUG_ONE_VOXEL_PATHFINDING_STEP) // voxel pathfinding step isn't allowed - it disables also other AI stuff return; } else { if (MyFakes.DEBUG_ONE_AI_STEP_SETTING) if (!MyFakes.DEBUG_ONE_AI_STEP) // AI step isn't allowed return; else // disable next AI step - and do one MyFakes.DEBUG_ONE_AI_STEP = false; } MySimpleProfiler.Begin("AI"); if (m_pathfinding != null) m_pathfinding.Update(); ProfilerShort.Begin("MyAIComponent.Simulate()"); base.Simulate(); m_behaviorTreeCollection.Update(); m_botCollection.Update(); ProfilerShort.End(); MySimpleProfiler.End("AI"); } }
private void OnComplete() { MySimpleProfiler.Begin("MyOreDetectorComponent - OnComplete"); CompletionCallback(this, m_result, m_emptyCells); CompletionCallback = null; //m_result = null; m_instancePool.Deallocate(this); MySimpleProfiler.End(); }
private static void UpdateSceneFrame() { MySimpleProfiler.Begin("Textures"); ProfilerShort.Begin("LoadMeshes"); MyMeshes.Load(); ProfilerShort.End(); ProfilerShort.Begin("QueryTexturesFromEntities"); QueryTexturesFromEntities(); ProfilerShort.End(); ProfilerShort.Begin("MyTextures.Load"); MyManagers.FileTextures.LoadAllRequested(); ProfilerShort.End(); ProfilerShort.Begin("GatherTextures"); GatherTextures(); ProfilerShort.End(); MySimpleProfiler.End("Textures"); MyBillboardRenderer.OnFrameStart(); UpdateActors(); MyBigMeshTable.Table.MoveToGPU(); ProfilerShort.Begin("Update merged groups"); ProfilerShort.Begin("UpdateBeforeDraw"); foreach (var r in MyComponentFactory <MyGroupRootComponent> .GetAll()) { r.UpdateBeforeDraw(); } ProfilerShort.End(); ProfilerShort.Begin("MoveToGPU"); foreach (var r in MyComponentFactory <MyGroupRootComponent> .GetAll()) { foreach (var val in r.m_materialGroups.Values) { // optimize: keep list+set for updating val.MoveToGPU(); } } ProfilerShort.End(); ProfilerShort.End(); ProfilerShort.Begin("Fill foliage streams"); MyGpuProfiler.IC_BeginBlock("Fill foliage streams"); m_foliageGenerator.PerFrame(); m_foliageGenerator.Begin(); MyFoliageComponents.Update(); m_foliageGenerator.End(); MyGpuProfiler.IC_EndBlock(); ProfilerShort.End(); MyCommon.MoveToNextFrame(); }
private void UpdateDeposits(ref BoundingSphereD sphere) { MySimpleProfiler.Begin("UpdateAndRegisterMarkers"); var newlist = new List <MiningInformation>(); foreach (var group in DepositGroupsByEntity.Values) { group.UpdateDeposits(ref sphere); foreach (var deposit in group.Deposits) { foreach (var material in deposit.Materials) { Vector3D pos; material.ComputeWorldPosition(deposit.VoxelMap, out pos); Logger.Instance.LogDebug($"Material: {material.Material.MinedOre}, Count: {material.Positions.Count}, Location: {pos}"); newlist.Add(new MiningInformation() { Location = pos, Material = material.Material, Voxel = deposit.VoxelMap, Positions = material.Positions, }); } } } for (var index = 0; index < newlist.Count - 1; index++) { var first = newlist[index]; var second = newlist[index + 1]; if ((first.Location - sphere.Center).LengthSquared() > (second.Location - sphere.Center).LengthSquared()) { newlist.Move(index, index + 1); } } //lock (m_miningInformationLock) //{ MiningInformation.Clear(); newlist.ForEach((i) => MiningInformation.Add(i)); MiningInformation.ApplyChanges(); Logger.Instance.LogDebugOnGameThread($"Mining Deposit count: {MiningInformation.Count}"); //} MyAPIGateway.Parallel.StartBackground(() => BuildAggregatedResult()); //BuildAggregatedResult(); MySimpleProfiler.End(); }
static void GatherFrame(MyFrameProfiling frame) { QueryDataTimestampDisjoint disjoint = MyImmediateRC.RC.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.GetData <ulong>(q.m_query, AsynchronousFlags.DoNotFlush, out timestamp); if (q.m_info == MyIssuedQueryEnum.BlockStart) { stackDepth++; MyRender11.GetRenderProfiler().GPU_StartProfilingBlock(q.m_tag); MySimpleProfiler.BeginGPUBlock(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)); MySimpleProfiler.EndGPUBlock(MyTimeSpan.FromSeconds(time)); } Debug.Assert(stackDepth >= 0); MyQueryFactory.RelaseTimestampQuery(q.m_query); } Debug.Assert(stackDepth == 0); } frame.Clear(); }
public void Clear() { MySimpleProfiler.Begin("Clear markers"); foreach (var group in DepositGroupsByEntity.Values) { foreach (var deposit in group.Deposits) { //MyOreDepositGroup.UnregisterMarker(deposit); //MyHud.OreMarkers.UnregisterMarker(deposit); } } MySimpleProfiler.End(); }
private void AddVoxelMapsInRange() { MySimpleProfiler.Begin("AddVoxelMapsInRange"); foreach (var voxelMap in m_inRangeCache) { if (!DepositGroupsByEntity.ContainsKey(voxelMap.GetTopMostParent() as MyVoxelBase)) //GK: Get only topmost in order to ignore MyVoxelPhysics { DepositGroupsByEntity.Add(voxelMap, new MyOreDepositGroup(voxelMap)); } } m_inRangeCache.Clear(); MySimpleProfiler.End(); }
private void RemoveVoxelMapsOutOfRange() { MySimpleProfiler.Begin("RemoveVoxelMapsOutOfRange"); foreach (var voxelMap in DepositGroupsByEntity.Keys) { if (!m_inRangeCache.Contains(voxelMap.GetTopMostParent() as MyVoxelBase)) //GK: Get only topmost in order to ignore MyVoxelPhysics { m_notInRangeCache.Add(voxelMap); } } foreach (var notInRange in m_notInRangeCache) { DepositGroupsByEntity.Remove(notInRange); } m_notInRangeCache.Clear(); MySimpleProfiler.End(); }
public void Run(string argument) { MySimpleProfiler.Begin("Scripts"); if (this.IsWorking == false || this.IsFunctional == false) { return; } if (Sync.IsServer) { string response; this.ExecuteCode(argument, out response); SetDetailedInfo(response); } else { SendRunProgramRequest(argument); } MySimpleProfiler.End("Scripts"); }
private void UpdateInternal() { using (Stats.Generic.Measure("BeforeUpdate")) { ProfilerShort.Begin("UpdateInternal::BeforeUpdate"); VRageRender.MyRenderProxy.BeforeUpdate(); ProfilerShort.End(); } ProfilerShort.Begin("UpdateInternal::Update"); //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Default, "Update Start"); m_updateTime = m_gameTimer.Elapsed; m_updateCounter++; if (VRage.MyCompilationSymbols.EnableNetworkPacketTracking) { System.Diagnostics.Debug.WriteLine("----- Tick # " + m_updateTime.Milliseconds); } Update(); ProfilerShort.End(); if (!IsDedicated) { ProfilerShort.Begin("UpdateInternal::PrepareForDraw"); PrepareForDraw(); ProfilerShort.End(); } using (Stats.Generic.Measure("AfterUpdate")) { ProfilerShort.Begin("UpdateInternal::AfterUpdate"); VRageRender.MyRenderProxy.AfterUpdate(m_updateTime); ProfilerShort.End(); } ProfilerShort.Commit(); MySimpleProfiler.Commit(); //VRage.Trace.MyTrace.Send(VRage.Trace.TraceWindow.Default, "Update End"); }
//WorkPriority IPrioritizedWork.Priority //{ // get { return WorkPriority.VeryLow; } //} void IWork.DoWork(WorkData workData) { MySimpleProfiler.Begin("MyDepositQuery.DoWork"); try { m_result.ClearList(); m_emptyCells = new List <Vector3I>(); var cache = Cache; cache.Resize(new Vector3I(MyOreDetectorComponent.CELL_SIZE_IN_LOD_VOXELS)); var storage = VoxelMap.Storage as IMyStorage; if (storage == null || storage.Closed) { return; } Vector3I c; for (c.Z = Min.Z; c.Z <= Max.Z; ++c.Z) { for (c.Y = Min.Y; c.Y <= Max.Y; ++c.Y) { for (c.X = Min.X; c.X <= Max.X; ++c.X) { if (storage == null || storage.Closed) { break; } ProcessCell(cache, storage, c); } } } m_result.ApplyChanges(); } finally { MySimpleProfiler.End(); } }
public static void UpdateBeforeSimulation() { if (MySandboxGame.IsGameReady == false) { return; } ProfilerShort.Begin("MyEntities.UpdateBeforeSimulation"); System.Diagnostics.Debug.Assert(MyEntities.UpdateInProgress == false); MyEntities.UpdateInProgress = true; { ProfilerShort.Begin("Before first frame"); MyEntities.UpdateOnceBeforeFrame(); ProfilerShort.BeginNextBlock("Each update"); m_entitiesForUpdate.List.ApplyChanges(); m_entitiesForUpdate.Update(); MySimpleProfiler.Begin("Blocks"); m_entitiesForUpdate.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateBeforeSimulation(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.End("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.BeginNextBlock("10th update"); m_entitiesForUpdate10.List.ApplyChanges(); m_entitiesForUpdate10.Update(); m_entitiesForUpdate10.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateBeforeSimulation10(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.End("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.BeginNextBlock("100th update"); m_entitiesForUpdate100.List.ApplyChanges(); m_entitiesForUpdate100.Update(); m_entitiesForUpdate100.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateBeforeSimulation100(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.End(); } MySimpleProfiler.End("Blocks"); MyEntities.UpdateInProgress = false; ProfilerShort.End(); }
// Update all physics objects - AFTER physics simulation public static void UpdateAfterSimulation() { if (MySandboxGame.IsGameReady == false) { return; } VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("UpdateAfterSimulation"); { System.Diagnostics.Debug.Assert(MyEntities.UpdateInProgress == false); MyEntities.UpdateInProgress = true; ProfilerShort.Begin("UpdateAfter1"); m_entitiesForUpdate.List.ApplyChanges(); MySimpleProfiler.Begin("Blocks"); m_entitiesForUpdate.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateAfterSimulation(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.End("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.End(); ProfilerShort.Begin("UpdateAfter10"); m_entitiesForUpdate10.List.ApplyChanges(); m_entitiesForUpdate10.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateAfterSimulation10(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.End("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.End(); ProfilerShort.Begin("UpdateAfter100"); m_entitiesForUpdate100.List.ApplyChanges(); m_entitiesForUpdate100.Iterate((x) => { ProfilerShort.Begin(x.GetType().Name); if (x.MarkedForClose == false) { if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.Begin(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.Begin("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.Begin("&&GRID&&" + grid.DisplayName); } } x.UpdateAfterSimulation100(); if (ProfilePerBlock) { MyCubeBlock block = x as MyCubeBlock; if (block != null) { MySimpleProfiler.End(block.DefinitionDisplayNameText + (ProfilePerGrid ? $" - {block.CubeGrid.DisplayName}" : string.Empty)); if (ProfilePerGrid) { MySimpleProfiler.End("&&GRID&&" + block.CubeGrid.DisplayName); } } } if (ProfilePerGrid) { MyCubeGrid grid = x as MyCubeGrid; if (grid != null) { MySimpleProfiler.End("&&GRID&&" + grid.DisplayName); } } } ProfilerShort.End(); }); ProfilerShort.End(); MySimpleProfiler.End("Blocks"); MyEntities.UpdateInProgress = false; MyEntities.DeleteRememberedEntities(); } if (m_creationThread != null) { while (m_creationThread.ConsumeResult()) { ; // Add entities created asynchronously } } VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); }