public void Dispose() { __session?.Dispose(); __framePool?.Dispose(); __swapChain?.Dispose(); __d3dDevice?.Dispose(); }
public void Dispose() { session?.Dispose(); framePool?.Dispose(); swapChain?.Dispose(); d3dDevice?.Dispose(); }
public void Dispose() { _session?.Dispose(); _framePool?.Dispose(); _swapChain?.Dispose(); _swapChain = null; _framePool = null; _session = null; _item = null; }
private void DisposeDirectXResources() { _textFormat.Dispose(); _dwFactory.Dispose(); _renderTarget.Dispose(); _renderTargetView.Dispose(); _d2DFactory.Dispose(); _swapChain.Dispose(); _d3DDeviceContext.Dispose(); _d3DDevice.Dispose(); }
private void LoadPipeline() { viewport.Width = this.width; viewport.Height = this.height; viewport.MaxDepth = 1.0f; scissorRect.Right = this.width; scissorRect.Bottom = this.height; #if DEBUG // Enable the D3D12 debug layer. { DebugInterface.Get().EnableDebugLayer(); } #endif var fact = new SharpDX.DXGI.Factory1(); SharpDX.DXGI.Adapter adapter = fact.GetAdapter(1); // create device using (var defaultDevice = new Device(adapter, SharpDX.Direct3D.FeatureLevel.Level_12_1)) device = defaultDevice.QueryInterface <SharpDX.Direct3D12.Device2>(); using (var factory = new SharpDX.DXGI.Factory4()) { // Describe and create the command queue. var queueDesc = new CommandQueueDescription(CommandListType.Direct); commandQueue = device.CreateCommandQueue(queueDesc); // Describe and create the swap chain. var swapChainDesc = new SharpDX.DXGI.SwapChainDescription1() { BufferCount = FrameCount, Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm, Height = height, Width = width, SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0), Scaling = SharpDX.DXGI.Scaling.Stretch, Stereo = false, SwapEffect = SharpDX.DXGI.SwapEffect.FlipDiscard, Usage = SharpDX.DXGI.Usage.RenderTargetOutput, }; var tempSwapChain = new SharpDX.DXGI.SwapChain1(factory, commandQueue, ref swapChainDesc); swapChain = tempSwapChain.QueryInterface <SharpDX.DXGI.SwapChain3>(); tempSwapChain.Dispose(); frameIndex = swapChain.CurrentBackBufferIndex; using (SharpDX.DXGI.ISwapChainPanelNative nativeObject = ComObject.As <SharpDX.DXGI.ISwapChainPanelNative>(swapChainPanel)) nativeObject.SwapChain = swapChain; } // Create descriptor heaps. // Describe and create a render target view (RTV) descriptor heap. var rtvHeapDesc = new DescriptorHeapDescription() { DescriptorCount = FrameCount, Flags = DescriptorHeapFlags.None, Type = DescriptorHeapType.RenderTargetView }; renderTargetViewHeap = device.CreateDescriptorHeap(rtvHeapDesc); rtvDescriptorSize = device.GetDescriptorHandleIncrementSize(DescriptorHeapType.RenderTargetView); // Create frame resources. var rtvHandle = renderTargetViewHeap.CPUDescriptorHandleForHeapStart; for (int n = 0; n < FrameCount; n++) { renderTargets[n] = swapChain.GetBackBuffer <Resource>(n); device.CreateRenderTargetView(renderTargets[n], null, rtvHandle); rtvHandle += rtvDescriptorSize; } commandAllocator = device.CreateCommandAllocator(CommandListType.Direct); }