コード例 #1
0
        public override bool Draw()
        {
            if (!base.Draw())
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));
            m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName()));

            m_texts.Add(MyScreenManager.GetGuiScreensForDebug());
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds)));

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

            if (MyFakes.DETECT_LEAKS)
            {
                var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();
                m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count));
            }

            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes"));

            // TODO: OP! Get available texture memory
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB"));

#if PHYSICS_SENSORS_PROFILING
            if (MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D()));

            var tmp = StringBuilderCache;
            MyAudio.Static.WriteDebugInfo(tmp);
            m_texts.Add(tmp);
            for (int i = 0; i < 8; i++)
            {
                m_texts.Add(StringBuilderCache.Clear());
            }

            m_texts.Add(StringBuilderCache.GetFormatedInt("Updating 3D sounds count: ", MyAudio.Static.GetUpdating3DSoundsCount()));
            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Textures 2D Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInPixels));
            m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Textures 2D Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.Textures2DSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.DxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Dxt Compressed Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonDxtCompressedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non Mip Mapped Textures Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.NonMipMappedTexturesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Texture Cubes Size In Pixels: ", VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInPixels));
            m_texts.Add(StringBuilderCache.AppendFormatedDecimal("Texture Cubes Size In Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.TextureCubesSizeInMb, 3));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Non MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.ModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Meshes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsMeshesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Vertexes Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsVertexesCount));
            m_texts.Add(StringBuilderCache.GetFormatedInt("MyModels Triangles Count: ", VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsTrianglesCount));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Vertex Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelVertexBuffersSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of Model Index Buffers in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.ModelIndexBuffersSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Vertex Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelVertexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Size of Voxel Index Buffers in Mb: ", VRageRender.MyPerformanceCounter.PerAppLifetime.VoxelIndexBuffersSize / 1024 / 1024));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Size of loaded Model files in Mb: ", (float)VRageRender.MyPerformanceCounter.PerAppLifetime.MyModelsFilesSize / (1024 * 1024)));
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            if (MySector.MainCamera != null)
            {
                m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position));
            }

            MyInput.Static.GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();
            AddPerformanceCountersToFrameDebugText();

            return(true);
        }
コード例 #2
0
        public override bool Draw()
        {
            if (!base.Draw())
            {
                return(false);
            }

            float rowDistance = MyGuiConstants.DEBUG_STATISTICS_ROW_DISTANCE;
            float textScale   = MyGuiConstants.DEBUG_STATISTICS_TEXT_SCALE;

            m_stringIndex = 0;
            m_texts.Clear();
            m_rightAlignedtexts.Clear();


            m_texts.Add(StringBuilderCache.GetFormatedFloat("FPS: ", MyFpsManager.GetFps()));
            m_texts.Add(new StringBuilder("Renderer: ").Append(MyRenderProxy.RendererInterfaceName()));

            if (MySector.MainCamera != null)
            {
                m_texts.Add(GetFormatedVector3(StringBuilderCache, "Camera pos: ", MySector.MainCamera.Position));
            }

            m_texts.Add(MyScreenManager.GetGuiScreensForDebug());
            m_texts.Add(StringBuilderCache.GetFormatedBool("Paused: ", MySandboxGame.IsPaused));
            m_texts.Add(StringBuilderCache.GetFormatedDateTimeOffset("System Time: ", TimeUtil.LocalTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total GAME-PLAY Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalGamePlayTimeInMilliseconds)));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Session Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.ElapsedPlayTime));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Foot Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnFoot));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Jetpack Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnJetpack));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Small Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnSmallShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Big Ship Time: ", MySession.Static == null ? new TimeSpan(0) : MySession.Static.TimeOnBigShip));
            m_texts.Add(StringBuilderCache.GetFormatedTimeSpan("Total Time: ", TimeSpan.FromMilliseconds(MySandboxGame.TotalTimeInMilliseconds)));

            if (MySession.Static != null && MySession.Static.LocalCharacter != null)
            {
                var physGroup = MyExternalReplicable.FindByObject(MySession.Static.LocalCharacter).FindStateGroup <MyCharacterPhysicsStateGroup>();
                m_texts.Add(StringBuilderCache.GetFormatedBool("Character has support: ", physGroup != null && physGroup.DebugSupport != null));
            }

            m_texts.Add(StringBuilderCache.GetFormatedLong("GC.GetTotalMemory: ", GC.GetTotalMemory(false), " bytes"));

            if (MyFakes.DETECT_LEAKS)
            {
                var o = SharpDX.Diagnostics.ObjectTracker.FindActiveObjects();
                m_texts.Add(StringBuilderCache.GetFormatedInt("SharpDX Active object count: ", o.Count));
            }

            //TODO: I am unable to show this without allocations
            m_texts.Add(StringBuilderCache.GetFormatedLong("Environment.WorkingSet: ", WinApi.WorkingSet, " bytes"));

            // TODO: OP! Get available texture memory
            //m_texts.Add(StringBuilderCache.GetFormatedFloat("Available videomemory: ", MySandboxGame.Static.GraphicsDevice.AvailableTextureMemory / (1024.0f * 1024.0f), " MB"));
            m_texts.Add(StringBuilderCache.GetFormatedFloat("Allocated videomemory: ", 0, " MB"));

#if PHYSICS_SENSORS_PROFILING
            if (MyPhysics.physicsSystem != null)
            {
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - new allocated interactions: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetNewAllocatedInteractionsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - interactions in use MAX: ", MyPhysics.physicsSystem.GetSensorInteractionModule().GetInteractionsInUseCountMax()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - all sensors: ", MyPhysics.physicsSystem.GetSensorModule().SensorsCount()));
                m_texts.Add(StringBuilderCache.GetFormatedInt("Physics sensor - active sensors: ", MyPhysics.physicsSystem.GetSensorModule().ActiveSensors.Count));
            }
#endif

            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 2D: ", MyAudio.Static.GetSoundInstancesTotal2D()));
            m_texts.Add(StringBuilderCache.GetFormatedInt("Sound Instances Total 3D: ", MyAudio.Static.GetSoundInstancesTotal3D()));

            var tmp = StringBuilderCache;
            MyAudio.Static.WriteDebugInfo(tmp);
            m_texts.Add(tmp);
            for (int i = 0; i < 8; i++)
            {
                m_texts.Add(StringBuilderCache.Clear());
            }

            MyInput.Static.GetPressedKeys(m_pressedKeys);
            AddPressedKeys("Current keys              : ", m_pressedKeys);

            m_texts.Add(StringBuilderCache.Clear());
            m_texts.Add(m_frameDebugText);

            m_rightAlignedtexts.Add(m_frameDebugTextRA);

            Vector2 origin             = GetScreenLeftTopPosition();
            Vector2 rightAlignedOrigin = GetScreenRightTopPosition();

            for (int i = 0; i < m_texts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_texts[i], origin + new Vector2(0, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
            for (int i = 0; i < m_rightAlignedtexts.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, m_rightAlignedtexts[i], rightAlignedOrigin + new Vector2(-0.3f, i * rowDistance), textScale,
                                        Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }

            ClearFrameDebugText();
            AddPerformanceCountersToFrameDebugText();

#if DEBUG
            //list of last played sounds
            MyGuiManager.DrawString(MyFontEnum.White, new StringBuilder("Last played sounds:"), rightAlignedOrigin + new Vector2(-0.3f, 0.8f), textScale,
                                    Color.Yellow, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            int colorIndex = (MyCueBank.lastSoundIndex > 0) ? (MyCueBank.lastSoundIndex - 1) : (MyCueBank.lastSounds.Count - 1);//index of last sound
            for (int i = 0; i < MyCueBank.lastSounds.Count; i++)
            {
                MyGuiManager.DrawString(MyFontEnum.White, MyCueBank.lastSounds[i], rightAlignedOrigin + new Vector2(-0.275f, 0.8f + (1 + i) * rowDistance), textScale,
                                        (i == colorIndex ? Color.LightBlue : Color.Yellow), MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_TOP);
            }
#endif

            return(true);
        }