/// <summary> /// Этот метод имеет прямой вызов, без tempBuffer.SetData(без внутреннего верт.буфера класса Renderer, /// поэтому тут используется еще один vertices.Bind(),чтобы привязать верт.буфер от внешнего класса. /// Например TerrainSpriteLayer. /// </summary> /// <typeparam name="T">в основном это Vertex</typeparam> /// <param name="VertBuffer">Внешний буфер вертексов </param> /// <param name="firstVertex">от</param> /// <param name="numVertices">длина</param> /// <param name="type">тип треугольники и т.д.</param> public void DrawBatcForOpenGLVertexBuffer <T>(VertexBuffer <T> VertBuffer, int firstVertex, int numVertices, PrimitiveType type) where T : struct { #if DEBUG_VERTEX Console.WriteLine("DrawBatcForOpenGL " + VertBuffer.ownername + "array:" + (numVertices - firstVertex).ToString()); #endif Context.DrawPrimitives(type, firstVertex, numVertices); PerfHistory.Increment("batches", 1); }
public void DrawBatch <T>(IVertexBuffer <T> vertices, int firstVertex, int numVertices, PrimitiveType type) where T : struct { vertices.Bind(); Device.DrawPrimitives(type, firstVertex, numVertices); PerfHistory.Increment("batches", 1); }
static void TickInner(OrderManager orderManager) { int t = Environment.TickCount; int dt = t - orderManager.LastTickTime; if (dt >= Settings.Game.Timestep) { using (new PerfSample("tick_time")) { orderManager.LastTickTime += Settings.Game.Timestep; Ui.Tick(); var world = orderManager.world; if (orderManager.GameStarted) { ++Viewport.TicksSinceLastMove; } Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world != null) { var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = Environment.TickCount; } Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); cursorFrame += 0.5f; } } } }
/// <summary> /// Метод используется, для перевалки данных из других spriterenderer в этот /// </summary> /// <param name="vertices">Вертексы</param> /// <param name="numVertices">длина</param> /// <param name="type">тип</param> public void DrawBatchForVertexesSpriteRendererClasses(Vertex[] vertices, int numVertices, PrimitiveType type) { RendererVertexBuffer.ActivateVertextBuffer(); RendererVertexBuffer.SetData(vertices, numVertices); RendererOpenVAO(); Context.DrawPrimitives(type, 0, numVertices); RendererCloseVAO(); #if DEBUG_VERTEX Console.WriteLine("DrawBatchForVertexesSprite SpriteRenderer" + "array:" + numVertices); #endif PerfHistory.Increment("batches", 1); }
static void InnerLogicTick(OrderManager orderManager) { var tick = RunTime; var world = orderManager.World; if (Ui.LastTickTime.ShouldAdvance(tick)) { Ui.LastTickTime.AdvanceTickTime(tick); Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick); Cursor.Tick(); } if (orderManager.LastTickTime.ShouldAdvance(tick)) { using (new PerfSample("tick_time")) { orderManager.LastTickTime.AdvanceTickTime(tick); Sound.Tick(); Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, orderManager.TickImmediate); if (world == null) { return; } if (orderManager.TryTick()) { Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => { world.OrderGenerator.Tick(world); }); world.Tick(); PerfHistory.Tick(); } // Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer)); } } benchmark?.Tick(LocalTick); } }
static void InnerLogicTick(OrderManager orderManager) { var tick = RunTime; var world = orderManager.World; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Sync.CheckSyncUnchanged(world, Ui.Tick); } var worldTimestep = world == null ? Timestep : world.Timestep; var worldTickDelta = tick - orderManager.LastTickTime; if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world == null) { return; } var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (BenchmarkMode) { Log.Write("cpu", "{0};{1}".F(LocalTick, PerfHistory.Items["tick_time"].LastValue)); } if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = RunTime; } // Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); } } } }
static void InnerLogicTick(OrderManager orderManager) { var tick = RunTime; var world = orderManager.World; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Ui.Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Ui.Timestep) * Ui.Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Ui.Timestep; Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick); Cursor.Tick(); } var worldTimestep = world == null ? Ui.Timestep : world.IsLoadingGameSave ? 1 : world.IsReplay ? world.ReplayTimestep : world.Timestep; var worldTickDelta = tick - orderManager.LastTickTime; if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, orderManager.TickImmediate); if (world == null) { return; } var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; if (isNetTick) { orderManager.Tick(); } Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => { world.OrderGenerator.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = RunTime; } // Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer)); } } benchmark?.Tick(LocalTick); } }
private static PerfHistory GetHistory(string counterName, string groupName, string instanceName) { PerfHistory rslt; string counter = PerfHistory.GetKey(counterName, groupName, instanceName); if (!History.TryGetValue(counter, out rslt)) { rslt = new PerfHistory(); rslt.CounterName = counterName; rslt.Category = groupName; rslt.InstanceName = instanceName; History.Add(counter, rslt); } return rslt; }
static void TickInner(OrderManager orderManager) { var tick = Environment.TickCount; var world = orderManager.world; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Viewport.TicksSinceLastMove += uiTickDelta / Timestep; Sync.CheckSyncUnchanged(world, Ui.Tick); cursorFrame += 0.5f; } var worldTimestep = world == null ? Timestep : world.Timestep; var worldTickDelta = (tick - orderManager.LastTickTime); if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world != null) { var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; Log.Write("debug", "--Tick: {0} ({1})", LocalTick, isNetTick ? "net" : "local"); if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = Environment.TickCount; } Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); } } } }
/// <summary> /// 内部逻辑 /// </summary> /// <param name="orderManager"></param> static void InnerLogicTick(OrderManager orderManager, GameTime time) { //var tick = (long)time.TotalGameTime.TotalMilliseconds; var tick = RunTime; var world = orderManager.World; var uiTickDelta = tick - UI.LastTickTime; if (uiTickDelta > Timestep) { var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; UI.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Sync.CheckSyncUnchanged(world, UI.Tick); } var worldTimestep = world == null ? Timestep : world.Timestep; var worldTickDelta = tick - orderManager.LastTickTime; if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { //Tick the world to advance the world time to match real time: var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); Sync.CheckSyncUnchanged(world, orderManager.TickImmediate); if (world == null) { return; } var isNetTick = LocalTick % NetTickScale == 0; if (!isNetTick || orderManager.IsReadyForNextFrame) { ++orderManager.LocalFrameNumber; if (isNetTick) { orderManager.Tick(); } Sync.CheckSyncUnchanged(world, () => { world.OrderGenerator.Tick(world); world.Selection.Tick(world); }); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = RunTime; } //Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.CheckSyncUnchanged(world, () => world.TickRender(worldRenderer)); } } } }
static void InnerLogicTick(OrderManager orderManager) { var tick = RunTime; var world = orderManager.World; var uiTickDelta = tick - Ui.LastTickTime; if (uiTickDelta >= Timestep) { // Explained below for the world tick calculation var integralTickTimestep = (uiTickDelta / Timestep) * Timestep; Ui.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : Timestep; Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, Ui.Tick); Cursor.Tick(); } var worldTimestep = world == null ? Timestep : world.IsLoadingGameSave ? 1 : world.Timestep; var worldTickDelta = tick - orderManager.LastTickTime; if (worldTimestep != 0 && worldTickDelta >= worldTimestep) { using (new PerfSample("tick_time")) { // Tick the world to advance the world time to match real time: // If dt < TickJankThreshold then we should try and catch up by repeatedly ticking // If dt >= TickJankThreshold then we should accept the jank and progress at the normal rate // dt is rounded down to an integer tick count in order to preserve fractional tick components. var integralTickTimestep = (worldTickDelta / worldTimestep) * worldTimestep; orderManager.LastTickTime += integralTickTimestep >= TimestepJankThreshold ? integralTickTimestep : worldTimestep; Sound.Tick(); if (world == null) { orderManager.TickPreGame(); return; } // Collect orders first, we will dispatch them if we can this frame Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => { world.OrderGenerator.Tick(world); }); if (orderManager.TryTick()) { Log.Write("debug", "--Tick: {0} ({1})", LocalTick, orderManager.IsNetTick ? "net" : "local"); world.Tick(); PerfHistory.Tick(); } else if (orderManager.NetFrameNumber == 0) { orderManager.LastTickTime = RunTime; } // Wait until we have done our first world Tick before TickRendering if (orderManager.LocalFrameNumber > 0) { Sync.RunUnsynced(Settings.Debug.SyncCheckUnsyncedCode, world, () => world.TickRender(worldRenderer)); } } if (benchmark != null) { benchmark.Tick(LocalTick); } } }