public override void Dispose() { commandList?.Dispose(); pipeline?.Dispose(); vertexBuffer?.Dispose(); indexBuffer?.Dispose(); base.Dispose(); }
public void Dispose() { if (_renderThread.IsAlive) { Stop().Wait(); } _gd?.WaitForIdle(); _controller?.Dispose(); _cl?.Dispose(); _gd?.Dispose(); }
/// <summary> /// Raises the <see cref="E:Closing" /> event. /// </summary> /// <param name="e">The <see cref="System.ComponentModel.CancelEventArgs" /> instance containing the event data.</param> protected override void OnClosing(CancelEventArgs e) { //If we exit here and async tasks are running, we won't ever finish them. That's because they are tied to the shell's command event... if (Interlocked.Read(ref _asyncCount) > 0) { e.Cancel = true; WriteToConsole($"Async tasks are still running {Interlocked.Read(ref _asyncCount)}"); return; } _commandLibraries?.Dispose(); base.OnClosing(e); }
public void Dispose() { imGuiRenderer.Dispose(); pipeline?.Dispose(); DisposeShaders(); resourceSet?.Dispose(); resourceLayout?.Dispose(); DisposeTextures(); commandList?.Dispose(); runtimeDataBuffer?.Dispose(); indexBuffer.Dispose(); vertexBuffer.Dispose(); graphicsDevice.Dispose(); }
public virtual void TearDown() { for (var index = Disposables.Count - 1; index >= 0; --index) { Disposables[index].Dispose(); } Disposables = null; CommandList?.Dispose(); _offscreenView?.Dispose(); Framebuffer?.Dispose(); _offscreenDepth?.Dispose(); _offscreenColor?.Dispose(); GraphicsDevice?.Dispose(); }
void test() { CommandList _commandList = null; try { Debug.WriteLine($"{nameof(test)}(-) 1.001"); GraphicsDevice _graphicsDevice = graphicsDevice; if (_graphicsDevice == null) { return; } Swapchain _swapchain = swapchain; if (_swapchain == null) { return; } _commandList = _graphicsDevice.ResourceFactory.CreateCommandList(); if (_commandList == null) { return; } _commandList.Begin(); _commandList.SetFramebuffer(_swapchain.Framebuffer); _commandList.ClearColorTarget(0, RgbaFloat.Pink); _commandList.End(); _graphicsDevice.SubmitCommands(_commandList); _graphicsDevice.SwapBuffers(_swapchain); _graphicsDevice.WaitForIdle(); } catch (Exception E) { Debug.WriteLine($"{nameof(test)} EXCEPTION={E.Message} {E.StackTrace}"); } finally { _commandList?.Dispose(); Debug.WriteLine($"{nameof(test)}(+)"); } }
protected virtual void Dispose(bool disposing) { if (disposing) { renderThread?.Join(); updateThread?.Join(); rendering?.Dispose(); Program?.Dispose(); commandList?.Dispose(); if (ownDevice) { Device?.Dispose(); } } }
public void Dispose() { if (m_IsDisposed) { return; } m_UiRenderers.Clear(); m_GraphicsDevice?.WaitForIdle(); m_ImguiManager?.Dispose(); m_CommandList?.Dispose(); m_GraphicsDevice?.Dispose(); if (m_Window != null) { m_Window.Resized -= OnWindowResize; m_Window.Close(); } m_IsDisposed = true; }
protected virtual void Dispose(bool disposing) { // Implements the basic dispose pattern. // Ref: https://msdn.microsoft.com/en-us/library/b1yfkh5e(v=vs.110).aspx if (disposing) { FlushCommandQueue(); RtvHeap?.Dispose(); DsvHeap?.Dispose(); SwapChain?.Dispose(); foreach (Resource buffer in _swapChainBuffers) { buffer?.Dispose(); } DepthStencilBuffer?.Dispose(); CommandList?.Dispose(); DirectCmdListAlloc?.Dispose(); CommandQueue?.Dispose(); Fence?.Dispose(); Device?.Dispose(); } }
private void Draw() { Debug.Assert(_window.Exists); int width = _window.Width; int height = _window.Height; if (_windowResized) { _windowResized = false; _gd.ResizeMainWindow((uint)width, (uint)height); _scene.Camera.WindowResized(width, height); _resizeHandled?.Invoke(width, height); CommandList cl = _gd.ResourceFactory.CreateCommandList(); cl.Begin(); _sc.RecreateWindowSizedResources(_gd, cl); cl.End(); _gd.SubmitCommands(cl); cl.Dispose(); } if (_newSampleCount != null) { _sc.MainSceneSampleCount = _newSampleCount.Value; _newSampleCount = null; DestroyAllObjects(); CreateAllObjects(); } _frameCommands.Begin(); CommonMaterials.FlushAll(_frameCommands); _scene.RenderAllStages(_gd, _frameCommands, _sc); _gd.SwapBuffers(); }
virtual public void ExecuteCommandList(CommandList commandList) { m_context.ExecuteCommandList(commandList, true); commandList.Dispose(); }
public void Dispose() { updateCommandList.Dispose(); drawViewCommandList.Dispose(); }
public void Reset() { _commandList?.Dispose(); _commandList = null; _context.ClearState(); }
public void Dispose() { Cl?.Dispose(); Gd?.Dispose(); }
[STAThread] // Needed for ASIOOutput.StartDriver method static void Main(string[] args) { // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice( new WindowCreateInfo(50, 50, 3600, 2000, WindowState.Normal, "Vector Engine Editor"), new GraphicsDeviceOptions(true, null, true), out _window, out _gd); _gd.MainSwapchain.SyncToVerticalBlank = false; _window.Resized += () => { _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height); _controller.WindowResized(_window.Width, _window.Height); }; _cl = _gd.ResourceFactory.CreateCommandList(); _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height); string assetsPath = HostHelper.AssetsPath; FileLoader.Init(assetsPath); FileLoader.LoadAllComponentGroups(); if (_showEditor) { HostHelper.StopGame(true); } else { HostHelper.PlayGame(true); } // Main application loop while (_window.Exists) { GameLoop.Tick(); InputSnapshot snapshot = _window.PumpEvents(); if (!_window.Exists) { break; } foreach (var keypress in snapshot.KeyEvents) { if (keypress.Key == Key.E && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { _showEditor = !_showEditor; } if (keypress.Key == Key.S && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { HostHelper.SaveScene(); } if (keypress.Key == Key.D && keypress.Down && keypress.Modifiers == ModifierKeys.Control) { HostHelper.Duplicate(); } } if (_showEditor) { if (EditorCamera == null) { foreach (var component in EntityAdmin.Instance.Components) { if (component.Entity.Name == EmptyScene.EDITOR_CAM_ENTITY_NAME) { EditorCamera = component.Entity; break; } } } if (midi == null) { midi = new MIDI(); midi.SetupWatchersAndPorts(); while (!midi.SetupComplete) { Thread.Sleep(1); } } IMidiMessage midiMessage; while (midi.MidiMessageQueue.TryDequeue(out midiMessage)) { MidiState.UpdateState(midiMessage); } // TODO: figure out why LastFrameTime makes ImGui run stupid fast... (for things like key repeats) _controller.Update(GameTime.LastFrameTime / 10f, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. EditorUI.SubmitUI(EntityAdmin.Instance); _cl.Begin(); _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(ClearColor.X, ClearColor.Y, ClearColor.Z, 1f)); _controller.Render(_gd, _cl); _cl.End(); _gd.SubmitCommands(_cl); _gd.SwapBuffers(_gd.MainSwapchain); } } if (!HostHelper.PlayingGame) { HostHelper.SaveScene(); } // Clean up Veldrid resources _gd.WaitForIdle(); _controller.Dispose(); _cl.Dispose(); _gd.Dispose(); }
public void Dispose() { Target.Resize -= OnResize; _commandList.Dispose(); }
public override void VTSUpdate(double interpolationHd, float interpolationLd, float elapsedTime) { //For each Pending Initizalion running for (int i = AsyncStateInitResults.Count - 1; i >= 0; i--) { var stateResult = AsyncStateInitResults[i]; //Thread work finished ?? if (stateResult.IsCompleted) { GameState state = stateResult.Result; //Does one component use a deffered loadcontent ? int nbrDefferedContentComponent = state.GameComponents.Count(x => x.IsDefferedLoadContent); if (nbrDefferedContentComponent > 0) { //Apply the loadContext command list on the Immediat context _loadContextCommandList = _loadContext.FinishCommandList(false); //The ExecuteCommandList reset all Setted states from Immediate context if set to false _engine.ImmediateContext.ExecuteCommandList(_loadContextCommandList, true); //Dispose the command list _loadContextCommandList.Dispose(); _loadContextCommandList = null; } //Execute the not deferred loadcontent. if (nbrDefferedContentComponent != state.GameComponents.Count) { foreach (var gc in state.GameComponents.Where(x => x.IsDefferedLoadContent == false && x.IsInitialized == false)) { Thread.Sleep(0); gc.LoadContent(_engine.ImmediateContext); gc.IsInitialized = true; } } //Add the current GameState components to the gamecomponents "initialized" collection state.GameComponents.ForEach(gc => { if (!_game.GameComponents.Contains(gc)) { _game.GameComponents.Add(gc); } }); #if DEBUG logger.Debug("State Initialization finished : {0}", state.Name); #endif state.RaisedInitializedEvent(); //The states is initialized, was it an initialization requested from an activation ? if (state.IsActivationRequested == true) { //Set the State; SetCurrentState(state); } //The init request has been processed, remove its result from result pending list. AsyncStateInitResults.RemoveAt(i); } } }
private void Draw() { Debug.Assert(_window.Exists); int width = _window.Width; int height = _window.Height; int x = _window.X; int y = _window.Y; if (_windowResized) { _windowResized = false; CFG.Current.GFX_Display_Width = width; CFG.Current.GFX_Display_Height = height; _gd.ResizeMainWindow((uint)width, (uint)height); //_scene.Camera.WindowResized(width, height); _resizeHandled?.Invoke(width, height); CommandList cl = _gd.ResourceFactory.CreateCommandList(); cl.Begin(); //_sc.RecreateWindowSizedResources(_gd, cl); RecreateWindowFramebuffers(cl); ImguiRenderer.WindowResized(width, height); MSBEditor.EditorResized(_window, _gd); ModelEditor.EditorResized(_window, _gd); cl.End(); _gd.SubmitCommands(cl); cl.Dispose(); } if (_windowMoved) { _windowMoved = false; CFG.Current.GFX_Display_X = x; CFG.Current.GFX_Display_Y = y; } if (_newSampleCount != null) { //_sc.MainSceneSampleCount = _newSampleCount.Value; _newSampleCount = null; //DestroyAllObjects(); //CreateAllObjects(); } //_frameCommands.Begin(); //CommonMaterials.FlushAll(_frameCommands); //_scene.RenderAllStages(_gd, _frameCommands, _sc); //CommandList cl2 = _gd.ResourceFactory.CreateCommandList(); MainWindowCommandList.Begin(); //cl2.SetFramebuffer(_gd.SwapchainFramebuffer); MainWindowCommandList.SetFramebuffer(_gd.SwapchainFramebuffer); MainWindowCommandList.ClearColorTarget(0, new RgbaFloat(0.176f, 0.176f, 0.188f, 1.0f)); float depthClear = _gd.IsDepthRangeZeroToOne ? 1f : 0f; MainWindowCommandList.ClearDepthStencil(0.0f); MainWindowCommandList.SetFullViewport(0); //MainWindowCommandList.End(); //_gd.SubmitCommands(MainWindowCommandList); //_gd.WaitForIdle(); if (_msbEditorFocused) { MSBEditor.Draw(_gd, MainWindowCommandList); } if (_modelEditorFocused) { ModelEditor.Draw(_gd, MainWindowCommandList); } var fence = Scene.Renderer.Frame(MainWindowCommandList, false); //GuiCommandList.Begin(); //GuiCommandList.SetFramebuffer(_gd.SwapchainFramebuffer); MainWindowCommandList.SetFullViewport(0); MainWindowCommandList.SetFullScissorRects(); ImguiRenderer.Render(_gd, MainWindowCommandList); //GuiCommandList.End(); MainWindowCommandList.End(); _gd.SubmitCommands(MainWindowCommandList, fence); Scene.Renderer.SubmitPostDrawCommandLists(); //Scene.SceneRenderPipeline.TestUpdateView(_gd, MainWindowCommandList, TestWorldView.CameraTransform.CameraViewMatrix); _gd.SwapBuffers(); }
private void OnGraphicsDeviceDestroyed() { _cl.Dispose(); _cl = null; }
public virtual void Dispose() { _cl.Dispose(); }
public void Dispose() { Fence.Dispose(); CommandList.Dispose(); }
static void paint(VeldridView veldridview) { CommandList _commandList = null; try { Debug.WriteLine($"{nameof(paint)}(-) veldridview.Width={veldridview.Width} .Height={veldridview.Height}"); ViewData viewData = ViewData.Find(veldridview); if (viewData == null) { return; } if (viewData.Enabled == false) { return; } ICommandListFactory commandListFactory = viewData.commandListFactory; if (commandListFactory == null) { return; } GraphicsDevice _graphicsDevice = veldridview?.VeldridView0Renderer?.GraphicsDevice; if (_graphicsDevice == null) { return; } Swapchain swapchain = veldridview?.VeldridView0Renderer?.Swapchain; if (swapchain == null) { return; } Framebuffer _framebuffer = swapchain.Framebuffer; if (_framebuffer == null) { return; } Debug.WriteLine($"{nameof(paint)} veldridview.Width={veldridview.Width} .Height={veldridview.Height}"); Debug.WriteLine($"{nameof(paint)} _framebuffer.Width={_framebuffer.Width} .Height={_framebuffer.Height}"); _commandList = commandListFactory.BuildCommandList(_graphicsDevice, _framebuffer); if (_commandList == null) { return; } _graphicsDevice.SubmitCommands(_commandList); _graphicsDevice.SwapBuffers(swapchain); } catch (Exception E) { } finally { _commandList?.Dispose(); Debug.WriteLine($"{nameof(paint)}(+) veldridview.Width={veldridview.Width} .Height={veldridview.Height}"); } }
public void Dispose() { CommandList.Dispose(); GraphicsDevice.Dispose(); }
static void Main() { System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US"); // Create window, GraphicsDevice, and all resources necessary for the demo. VeldridStartup.CreateWindowAndGraphicsDevice(new WindowCreateInfo(50, 50, 1280, 720, WindowState.Normal, "Dantelion FXR3 Editor"), new GraphicsDeviceOptions(true, null, true, ResourceBindingModel.Improved, true, true), GraphicsBackend.Direct3D11, out Window, out Gd); Window.Resized += () => { Gd.MainSwapchain.Resize((uint)Window.Width, (uint)Window.Height); Controller.WindowResized(Window.Width, Window.Height); }; _cl = Gd.ResourceFactory.CreateCommandList(); Controller = new ImGuiController(Gd, Window, Gd.MainSwapchain.Framebuffer.OutputDescription, Window.Width, Window.Height); //Theme Selector Themes.ThemesSelectorPush(_activeTheme); // Main application loop while (Window.Exists) { InputSnapshot snapshot = Window.PumpEvents(); if (!Window.Exists) { break; } Controller.Update(1f / FrameRateForDelta, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui. //SetupMainDockingSpace ImGuiViewportPtr mainViewportPtr = ImGui.GetMainViewport(); mainViewPortDockSpaceID = ImGui.DockSpaceOverViewport(mainViewportPtr); ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.DockingEnable; HotKeyGlobalListener(); if (Controller.GetWindowMinimized(mainViewportPtr) == 0 && !ExceptionManager.TryRenderException()) { SubmitMainMenuBar(); SubmitMainWindowUi(); } SubmitDockableUi(); if (OpenFfXs.Any()) { SelectedFfxWindow.HotkeyListener(); } _cl.Begin(); _cl.SetFramebuffer(Gd.MainSwapchain.Framebuffer); _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f)); Controller.Render(Gd, _cl); _cl.End(); Gd.SubmitCommands(_cl); Gd.SwapBuffers(Gd.MainSwapchain); Controller.SwapExtraWindows(Gd); Thread.Sleep(17); } //Runtime Configs Save TextureDisplaySizeConfig.WriteConfigsIni(TextureDisplaySize); // Clean up Veldrid resources Gd.WaitForIdle(); Controller.Dispose(); _cl.Dispose(); Gd.Dispose(); }
public void Dispose() { _imguiRenderer.Dispose(); _cl.Dispose(); }