Пример #1
0
        private static void ProcessRenderFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            for (int i = 0; i < frame.RenderInput.Count; i++)
            {
                var msg = frame.RenderInput[i];

                if (msg == null)
                {
                    continue;
                }

                if ((filter == null || filter(msg.MessageType)))
                {
                    ProcessMessage(msg);

                    if (msg.MessageClass == MyRenderMessageType.StateChangeOnce)
                    {
                        // TODO: Remove from render input, don't just set to null
                        frame.RenderInput[i] = null;
                        MyRenderProxy.MessagePool.Return(msg);
                    }
                }
            }
            frame.Processed = true;
        }
Пример #2
0
        static void ProcessMessageQueue(MessageFilterDelegate filter = null)
        {
            MyRenderProxy.AssertRenderThread();

            while (true)
            {
                bool          isPreFrame;
                MyUpdateFrame frame = SharedData.GetRenderFrame(out isPreFrame);
                if (frame == null)
                {
                    return;
                }

                MyRender.CurrentUpdateTime = frame.UpdateTimestamp;

                if (isPreFrame)
                {
                    MyRender.GetRenderProfiler().StartProfilingBlock("ProcessMessageQueue.ProcessPreFrame");
                    ProcessPreFrame(frame, filter);
                    MyRender.GetRenderProfiler().EndProfilingBlock();
                    SharedData.ReturnPreFrame(frame);
                }
                else
                {
                    MyRender.GetRenderProfiler().StartProfilingBlock("ProcessMessageQueue.ProcessRenderFrame");
                    ProcessRenderFrame(frame, filter);
                    MyRender.GetRenderProfiler().EndProfilingBlock();

                    MyRender.GetRenderProfiler().StartProfilingBlock("ProcessMessageQueue.MyRenderClipmap.UpdateQueued");
                    MyRenderClipmap.UpdateQueued();
                    MyRender.GetRenderProfiler().EndProfilingBlock();
                    return;
                }
            }
        }
Пример #3
0
        public MyUpdateData()
        {
            m_frameDataPool = new MyConcurrentPool<MyUpdateFrame>(5, true);
            m_updateDataQueue = new MyConcurrentQueue<MyUpdateFrame>(5);

            CurrentUpdateFrame = m_frameDataPool.Get();
        }
Пример #4
0
        public MyUpdateData()
        {
            m_frameDataPool   = new MyConcurrentPool <MyUpdateFrame>(5, true);
            m_updateDataQueue = new MyConcurrentQueue <MyUpdateFrame>(5);

            CurrentUpdateFrame = m_frameDataPool.Get();
        }
Пример #5
0
        private static void ProcessPreFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            if (!frame.Processed)
            {
                foreach (var msg in frame.RenderInput)
                {
                    if (msg == null)
                    {
                        continue;
                    }

                    if ((filter == null || filter(msg.MessageType)) && msg.MessageClass != MyRenderMessageType.Draw)
                    {
                        ProcessMessage(msg);
                    }
                }

                Debug.Assert(m_drawMessages.Count == 0 && m_debugDrawMessages.Count == 0, "Draw messages was skipped, but there's draw messages!");
            }

            // Return messages
            foreach (var msg in frame.RenderInput)
            {
                if (msg != null)
                {
                    MyRenderProxy.MessagePool.Return(msg);
                }
            }
            frame.RenderInput.Clear();
        }
Пример #6
0
        /// <summary>
        /// Commits current frame as atomic operation and prepares new frame
        /// </summary>
        public void CommitUpdateFrame()
        {
            VRage.Library.Utils.MyTimeSpan lastUpdateTimestamp = CurrentUpdateFrame.UpdateTimestamp;

            CurrentUpdateFrame.Processed = false;
            m_updateDataQueue.Enqueue(CurrentUpdateFrame);
            CurrentUpdateFrame = m_frameDataPool.Get();

            CurrentUpdateFrame.UpdateTimestamp = lastUpdateTimestamp;
        }
Пример #7
0
        /// <summary>
        /// Commits current frame as atomic operation and prepares new frame
        /// </summary>
        public void CommitUpdateFrame()
        {
            VRage.Library.Utils.MyTimeSpan lastUpdateTimestamp = CurrentUpdateFrame.UpdateTimestamp;

            CurrentUpdateFrame.Processed = false;
            m_updateDataQueue.Enqueue(CurrentUpdateFrame);
            CurrentUpdateFrame = m_frameDataPool.Get();

            CurrentUpdateFrame.UpdateTimestamp = lastUpdateTimestamp;
        }
Пример #8
0
 public MyUpdateFrame GetRenderFrame(out bool isPreFrame)
 {
     using (m_lock.Acquire())
     {
         MyUpdateFrame result = m_inputRenderMessages.GetRenderFrame(out isPreFrame);
         if (!isPreFrame)
         {
             m_inputBillboards.RefreshRead();
             m_inputTriangleBillboards.RefreshRead();
         }
         return(result);
     }
 }
Пример #9
0
        private static void ProcessPreFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            int processCtr = 0;

            m_processStopwatch.Restart();

            if (!frame.Processed)
            {
                foreach (var msg in frame.RenderInput)
                {
                    if (msg == null)
                    {
                        continue;
                    }

                    if ((filter == null || filter(msg.MessageType)) && msg.MessageClass != MyRenderMessageType.Draw && msg.MessageClass != MyRenderMessageType.DebugDraw)
                    {
                        processCtr++;
                        ProcessMessage(msg);
                    }

                    if ((processCtr % 1000) == 0)
                    {
                        m_processStopwatch.Stop();
                        if (m_processStopwatch.Elapsed.TotalSeconds > 0.5f)
                        {
#if !BLIT
                            //Debug.WriteLine("DoEvents()");
                            if (MyRenderProxy.EnableAppEventsCall)
                            {
                                Application.DoEvents();
                            }
#endif
                            m_processStopwatch.Reset();
                        }
                        m_processStopwatch.Start();
                    }
                }
            }

            // Return messages
            foreach (var msg in frame.RenderInput)
            {
                if (msg != null)
                {
                    MyRenderProxy.MessagePool.Return(msg);
                }
            }

            frame.RenderInput.Clear();
        }
Пример #10
0
        private static void ProcessRenderFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            int processCtr = 0;

            m_processStopwatch.Restart();

            for (int i = 0; i < frame.RenderInput.Count; i++)
            {
                var msg = frame.RenderInput[i];

                if (msg == null)
                {
                    continue;
                }

                if ((filter == null || filter(msg.MessageType)))
                {
                    ProcessMessage(msg);
                    processCtr++;

                    if (msg.MessageClass == MyRenderMessageType.StateChangeOnce)
                    {
                        frame.RenderInput[i] = null;
                        MyRenderProxy.MessagePool.Return(msg);
                    }
                }

                if ((processCtr % 1000) == 0)
                {
                    m_processStopwatch.Stop();
                    if (m_processStopwatch.Elapsed.TotalSeconds > 0.5f)
                    {
#if !BLIT
                        //Debug.WriteLine("DoEvents()");
                        if (MyRenderProxy.EnableAppEventsCall)
                        {
                            Application.DoEvents();
                        }
#endif
                        m_processStopwatch.Reset();
                    }
                    m_processStopwatch.Start();
                }
            }

            frame.RenderInput.RemoveAll(item => item == null);
            frame.Processed = true;
        }
Пример #11
0
        internal static void ProcessMessageQueue()
        {
            //MyRenderProxy.AssertRenderThread();

            bool ok = true;

            while (ok)
            {
                bool          isPreFrame;
                MyUpdateFrame frame = SharedData.GetRenderFrame(out isPreFrame);
                if (frame == null)
                {
                    return;
                }

                CurrentUpdateTime = frame.UpdateTimestamp;


                if (isPreFrame)
                {
                    MyRender11.GetRenderProfiler().StartProfilingBlock("ProcessPreFrame");

                    ProcessPreFrame(frame);

                    MyRender11.GetRenderProfiler().EndProfilingBlock();

                    SharedData.ReturnPreFrame(frame);
                }
                else
                {
                    MyRender11.GetRenderProfiler().StartProfilingBlock("ProcessRenderFrame");

                    ProcessRenderFrame(frame);

                    MyRender11.GetRenderProfiler().EndProfilingBlock();

                    MyRender11.GetRenderProfiler().StartProfilingBlock("MyClipmapHandler.UpdateQueued");

                    MyClipmapHandler.UpdateQueued();

                    MyRender11.GetRenderProfiler().EndProfilingBlock();

                    ok = false;
                }
            }
        }
        private static void ProcessRenderFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            int processCtr = 0;
            m_processStopwatch.Restart();

            for (int i = 0; i < frame.RenderInput.Count; i++)
            {
                var msg = frame.RenderInput[i];

                if (msg == null)
                    continue;

                if ((filter == null || filter(msg.MessageType)))
                {
                    ProcessMessage(msg);
                    processCtr++;

                    if (msg.MessageClass == MyRenderMessageType.StateChangeOnce)
                    {
                        frame.RenderInput[i] = null;
                        MyRenderProxy.MessagePool.Return(msg);
                    }
                }

                if ((processCtr % 1000) == 0)
                {
                    m_processStopwatch.Stop();
                    if (m_processStopwatch.Elapsed.TotalSeconds > 0.5f)
                    {
#if !XB1
                        //Debug.WriteLine("DoEvents()");
                        if (MyRenderProxy.EnableAppEventsCall)
                        {
                            Application.DoEvents();
                        }
#endif
						m_processStopwatch.Reset();
					}
                    m_processStopwatch.Start();
                }
            }

            frame.RenderInput.RemoveAll(item => item == null);
            frame.Processed = true;
        }
        private static void ProcessRenderFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            for (int i = 0; i < frame.RenderInput.Count; i++)
            {
                var msg = frame.RenderInput[i];

                if (msg == null)
                    continue;

                if ((filter == null || filter(msg.MessageType)))
                {
                    ProcessMessage(msg);

                    if (msg.MessageClass == MyRenderMessageType.StateChangeOnce)
                    {
                        // TODO: Remove from render input, don't just set to null
                        frame.RenderInput[i] = null;
                        MyRenderProxy.MessagePool.Return(msg);
                    }
                }                
            }
            frame.Processed = true;
        }
Пример #14
0
 /// <summary>
 /// PreFrame must be empty in this place
 /// </summary>
 public void ReturnPreFrame(MyUpdateFrame frame)
 {
     Debug.Assert(frame.RenderInput.Count == 0);
     m_frameDataPool.Return(frame);
 }
        private static void ProcessPreFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            int processCtr = 0;
            m_processStopwatch.Restart();

            if (!frame.Processed)
            {
                foreach (var msg in frame.RenderInput)
                {
                    if (msg == null)
                        continue;

                    if ((filter == null || filter(msg.MessageType)) && msg.MessageClass != MyRenderMessageType.Draw && msg.MessageClass != MyRenderMessageType.DebugDraw)
                    {
                        processCtr++;
                        ProcessMessage(msg);
                    }

                    if ((processCtr % 1000) == 0)
                    {
                        m_processStopwatch.Stop();
                        if (m_processStopwatch.Elapsed.TotalSeconds > 0.5f)
                        {
#if !XB1
                            //Debug.WriteLine("DoEvents()");
                            if (MyRenderProxy.EnableAppEventsCall)
                            {
                                Application.DoEvents();
                            }
#endif
							m_processStopwatch.Reset();
                        }
                        m_processStopwatch.Start();
                    }
                }
            }

            // Return messages
            foreach (var msg in frame.RenderInput)
            {
                if (msg != null)
                {
                    MyRenderProxy.MessagePool.Return(msg);
                }
            }

            frame.RenderInput.Clear();
        }
Пример #16
0
 public void ReturnPreFrame(MyUpdateFrame frame)
 {
     m_inputRenderMessages.ReturnPreFrame(frame);
 }
Пример #17
0
 public void ReturnPreFrame(MyUpdateFrame frame)
 {
     m_inputRenderMessages.ReturnPreFrame(frame);
 }
Пример #18
0
 /// <summary>
 /// Commits current frame as atomic operation and prepares new frame
 /// </summary>
 public void CommitUpdateFrame()
 {
     CurrentUpdateFrame.Processed = false;
     m_updateDataQueue.Enqueue(CurrentUpdateFrame);
     CurrentUpdateFrame = m_frameDataPool.Get();
 }
        private static void ProcessPreFrame(MyUpdateFrame frame, MessageFilterDelegate filter = null)
        {
            if (!frame.Processed)
            {
                foreach (var msg in frame.RenderInput)
                {
                    if (msg == null)
                        continue;

                    if ((filter == null || filter(msg.MessageType)) && msg.MessageClass != MyRenderMessageType.Draw)
                    {
                        ProcessMessage(msg);
                    }
                }

                Debug.Assert(m_drawMessages.Count == 0 && m_debugDrawMessages.Count == 0, "Draw messages was skipped, but there's draw messages!");
            }
        
            // Return messages
            foreach (var msg in frame.RenderInput)
            {
                if (msg != null)
                {
                    MyRenderProxy.MessagePool.Return(msg);
                }
            }
            frame.RenderInput.Clear();
        }
Пример #20
0
 /// <summary>
 /// PreFrame must be empty in this place
 /// </summary>
 public void ReturnPreFrame(MyUpdateFrame frame)
 {
     Debug.Assert(frame.RenderInput.Count == 0);
     m_frameDataPool.Return(frame);
 }
Пример #21
0
 /// <summary>
 /// Commits current frame as atomic operation and prepares new frame
 /// </summary>
 public void CommitUpdateFrame()
 {
     CurrentUpdateFrame.Processed = false;
     m_updateDataQueue.Enqueue(CurrentUpdateFrame);
     CurrentUpdateFrame = m_frameDataPool.Get();
 }