Esempio n. 1
0
        /// <summary>
        /// Draws a utility window for interacting with RenderDoc
        /// </summary>
        public static void ShowRenderDocWindow()
        {
            if (RenderDoc.IsLoaded)
            {
                ImGui.SetNextWindowSize(new Vector2(264, 487));
            }
            else
            {
                ImGui.SetNextWindowSize(new Vector2(264, 80));
            }
            if (ImGui.Begin("RenderDoc"))
            {
                if (!RenderDoc.IsLoaded)
                {
                    if (ImGui.Button("Load RenderDoc"))
                    {
                        RenderDoc.Initialise();
                    }
                }
                else
                {
                    if (ImGui.Button("Start Replay UI"))
                    {
                        RenderDoc.LaunchReplayUI();
                    }

                    if (ImGui.Button("Capture Frame"))
                    {
                        RenderDoc.TriggerCapture();
                    }

                    ImGui.Text("Debug");
                    ImGui.BeginChild("Debug", new Vector2(0, 82), true);

                    bufferBool = RenderDoc.APIValidation;
                    ImGui.Checkbox("API Validation", ref bufferBool);
                    RenderDoc.APIValidation = bufferBool;

                    bufferBool = RenderDoc.VerifyBufferAccess;
                    ImGui.Checkbox("Verify Buffer Access", ref bufferBool);
                    RenderDoc.VerifyBufferAccess = bufferBool;

                    bufferBool = RenderDoc.DebugOutputMute;
                    ImGui.Checkbox("Debug Output Mute", ref bufferBool);
                    RenderDoc.DebugOutputMute = bufferBool;

                    ImGui.EndChild();

                    ImGui.Text("Behavior");
                    ImGui.BeginChild("Behavior", new Vector2(0, 160 + (RenderDoc.CaptureCallstacks ? 26 : 0)), true);

                    bufferBool = RenderDoc.AllowFullscreen;
                    ImGui.Checkbox("Allow Fullscreen", ref bufferBool);
                    RenderDoc.AllowFullscreen = bufferBool;

                    bufferBool = RenderDoc.AllowVSync;
                    ImGui.Checkbox("Allow V-Sync", ref bufferBool);
                    RenderDoc.AllowVSync = bufferBool;

                    bufferBool = RenderDoc.RefAllResources;
                    ImGui.Checkbox("Reference All Resources", ref bufferBool);
                    RenderDoc.RefAllResources = bufferBool;

                    bufferBool = RenderDoc.CaptureAllCmdLists;
                    ImGui.Checkbox("Capture All Command Lists", ref bufferBool);
                    RenderDoc.CaptureAllCmdLists = bufferBool;

                    bufferBool = RenderDoc.CaptureCallstacks;
                    ImGui.Checkbox("Capture Callstacks", ref bufferBool);
                    RenderDoc.CaptureCallstacks = bufferBool;

                    if (RenderDoc.CaptureCallstacks)
                    {
                        bufferBool = RenderDoc.CaptureCallstacksOnlyDraws;
                        ImGui.Checkbox("Capture Callstacks (Only Draws)", ref bufferBool);
                        RenderDoc.CaptureCallstacksOnlyDraws = bufferBool;
                    }

                    bufferBool = RenderDoc.HookIntoChildren;
                    ImGui.Checkbox("Hook Into Child Processes", ref bufferBool);
                    RenderDoc.HookIntoChildren = bufferBool;

                    ImGui.EndChild();

                    ImGui.Text("Overlay");
                    ImGui.BeginChild("Overlay", new Vector2(0, 26 + (RenderDoc.OverlayEnabled ? 26 * 3 : 10)), true);

                    bufferBool = RenderDoc.OverlayEnabled;
                    ImGui.Checkbox("Enable Overlay", ref bufferBool);
                    RenderDoc.OverlayEnabled = bufferBool;

                    if (RenderDoc.OverlayEnabled)
                    {
                        bufferBool = RenderDoc.OverlayFrameRate;
                        ImGui.Checkbox("Overlay Framerate", ref bufferBool);
                        RenderDoc.OverlayFrameRate = bufferBool;

                        bufferBool = RenderDoc.OverlayFrameNumber;
                        ImGui.Checkbox("Overlay Frame Number", ref bufferBool);
                        RenderDoc.OverlayFrameNumber = bufferBool;

                        bufferBool = RenderDoc.OverlayCaptureList;
                        ImGui.Checkbox("Overlay Capture List", ref bufferBool);
                        RenderDoc.OverlayCaptureList = bufferBool;
                    }

                    ImGui.EndChild();
                }
                ImGui.End();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Setups the engine and initialises the window
        /// </summary>
        internal void MainLoop()
        {
            VesselLogger.Logger.Info("Initialising Vessel...");

            //Setup the window
            VesselWindow window;

            window = new VesselWindow(GraphicsDevice, config.Name, config.Width, config.Height);
            Window = window;

            // Initialise RenderDoc
            if (config.RenderDoc)
            {
                RenderDoc.Initialise();
            }

            //Initialise the Graphics Device
            GraphicsDevice.Initialise(window, config);
            Window.Invalidate();

            //Callback for the engine
            Initialise();

            VesselLogger.Logger.Info($"Started Vessel using {GraphicsDevice.GraphicsAPI}!");

            //Deltatime variables
            long      previousFrameTicks = 0;
            Stopwatch sw = new Stopwatch();

            sw.Start();

            //Main Loop
            while (Window.Exists)
            {
                Window.ProcessEvents();

                //Calculate delta-time
                long   currentFrameTicks = sw.ElapsedTicks;
                double deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;

                //Wait till next frame if we are locking the target framerate
                while (LimitFrameRate && deltaSeconds < TargetFrameTime)
                {
                    currentFrameTicks = sw.ElapsedTicks;
                    deltaSeconds      = (currentFrameTicks - previousFrameTicks) / (double)Stopwatch.Frequency;
                }

                DeltaTime = (float)deltaSeconds;

                previousFrameTicks = currentFrameTicks;

                //Update method
                Update();

                //Only Draw if the window is still open
                if (!Window.Exists)
                {
                    break;
                }

                GraphicsDevice.OnFrameBegin();

                // Draw the scene
                GraphicsDevice.Debug.PushGroup("Draw Scene");
                Draw();
                GraphicsDevice.Debug.PopGroup();

                // Draw layers + post processing
                GraphicsDevice.Debug.PushGroup("Draw Layers");
                RenderLayers.Draw();
                GraphicsDevice.Debug.PopGroup();

                GraphicsDevice.OnFrameEnd();
            }

            // Cleanup
            VesselLogger.Logger.Info("Shutting down Vessel...");
            Exiting();
        }