Example #1
0
        protected override void PlatformDispose()
        {
            // Dispose staging buffers
            foreach (DeviceBuffer buffer in _availableStagingBuffers)
            {
                buffer.Dispose();
            }
            _availableStagingBuffers.Clear();

            _d3d11ResourceFactory.Dispose();
            _mainSwapchain?.Dispose();
            _immediateContext.Dispose();

            ID3D11Debug deviceDebug = _device.QueryInterfaceOrNull <ID3D11Debug>();

            _device.Dispose();
            _dxgiAdapter.Dispose();

            // Report live objects using DXGI if available (DXGIGetDebugInterface1 will fail on pre Windows 8 OS).
            if (VorticeDXGI.DXGIGetDebugInterface1(out IDXGIDebug1 dxgiDebug).Success)
            {
                deviceDebug?.Dispose();
                dxgiDebug.ReportLiveObjects(VorticeDXGI.All, ReportLiveObjectFlags.Summary | ReportLiveObjectFlags.IgnoreInternal);
                dxgiDebug.Dispose();
            }
Example #2
0
        protected override void PlatformDispose()
        {
            // Dispose staging buffers
            foreach (DeviceBuffer buffer in _availableStagingBuffers)
            {
                buffer.Dispose();
            }
            _availableStagingBuffers.Clear();

            _d3d11ResourceFactory.Dispose();
            _mainSwapchain?.Dispose();
            _immediateContext.Dispose();

            ID3D11Debug deviceDebug = _device.QueryInterfaceOrNull <ID3D11Debug>();

            _device.Dispose();
            _dxgiAdapter?.Dispose();

            // Need to enable native debugging to see live objects in VisualStudio console.
            if (deviceDebug != null)
            {
                deviceDebug.ReportLiveDeviceObjects(ReportLiveDeviceObjectFlags.Summary | ReportLiveDeviceObjectFlags.Detail | ReportLiveDeviceObjectFlags.IgnoreInternal);
                deviceDebug.Dispose();
            }
        }
Example #3
0
 public void Dispose()
 {
     _d3d11DeviceContext?.Dispose();
     _d3d11Device?.Dispose();
     _d3d12Device?.Dispose();
     _dxgiFactory.Dispose();
 }
Example #4
0
        /// <inheritdoc/>
        protected override void Destroy()
        {
            Reset();

            _annotation?.Dispose();
            _context1?.Dispose();
            D3D11Context.Dispose();
        }
Example #5
0
 public void Dispose()
 {
     m_dwriteFactory?.Dispose();
     m_d2dContext?.Dispose();
     m_swapchain?.Dispose();
     m_device?.Dispose();
     m_context?.Dispose();
     m_disposed = true;
 }
Example #6
0
 public void Dispose()
 {
     RenderTargetView.Dispose();
     BackBuffer.Dispose();
     DeviceContext.ClearState();
     DeviceContext.Flush();
     DeviceContext.Dispose();
     Device.Dispose();
     SwapChain.Dispose();
     Factory.Dispose();
 }
        public void Dispose()
        {
            RenderTargetView.Dispose();
            BackBuffer.Dispose();
            DeviceContext.ClearState();
            DeviceContext.Flush();
            DeviceContext.Dispose();
            Device.Dispose();
            SwapChain.Dispose();
            Adapter.Dispose();
            Factory.Dispose();

            if (DXGIGetDebugInterface1(out IDXGIDebug1 dxgiDebug).Success)
            {
                dxgiDebug.ReportLiveObjects(All, ReportLiveObjectFlags.Summary | ReportLiveObjectFlags.IgnoreInternal);
                dxgiDebug.Dispose();
            }
        }
Example #8
0
        protected override void PlatformDispose()
        {
            _d3d11ResourceFactory.Dispose();
            _mainSwapchain?.Dispose();
            _immediateContext.Dispose();

            IDXGIDebug deviceDebug = _device.QueryInterfaceOrNull <IDXGIDebug>();

            _device.Dispose();
            _dxgiAdapter?.Dispose();

            if (deviceDebug != null)
            {
                deviceDebug.ReportLiveObjects(DXGI.All, ReportLiveObjectFlags.Summary);
                deviceDebug.ReportLiveObjects(DXGI.All, ReportLiveObjectFlags.Detail);
                deviceDebug.Dispose();
            }
        }
            private void Dispose(bool disposing)
            {
                if (!IsDisposed)
                {
                    if (disposing)
                    {
                        if (!_desktopImageTexture.IsDisposed)
                        {
                            _desktopImageTexture.Dispose();
                        }

                        if (_outputDuplication != null && !_outputDuplication.IsDisposed)
                        {
                            try
                            {
                                _outputDuplication.ReleaseFrame();
                            }
                            catch
                            {
                                // Do Nothing...
                            }

                            _outputDuplication.Dispose();
                        }

                        if (_immediateContext != null && !_immediateContext.IsDisposed)
                        {
                            _immediateContext.Dispose();
                        }

                        if (_d3dDevice != null && !_d3dDevice.IsDisposed)
                        {
                            _d3dDevice.Dispose();
                        }
                    }
                    IsDisposed = true;
                }
            }
Example #10
0
 public void Dispose()
 {
     Device.Dispose();
     Context.Dispose();
 }
Example #11
0
 public void Destroy()
 {
     _context.Dispose();
 }
Example #12
0
        public bool Init(IntPtr WindowHandle)
        {
            var factory            = DXGI.CreateDXGIFactory1 <IDXGIFactory1>();
            var adapter            = factory.GetAdapter1(0);
            var monitor            = adapter.GetOutput(0);
            var modes              = monitor.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced);
            var rational           = new Rational(0, 1);
            var adapterDescription = adapter.Description;

            //VideoCardMemory = adapterDescription.DedicatedVideoMemory >> 10 >> 10;
            //VideoCardDescription = adapterDescription.Description.Trim('\0');
            monitor.Dispose();
            adapter.Dispose();

            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount       = 2,
                BufferDescription = new ModeDescription(1920, 1080, rational, Format.R8G8B8A8_UNorm),
                Usage             = Usage.RenderTargetOutput,
                OutputWindow      = WindowHandle,
                SampleDescription = new SampleDescription(1, 0),
                IsWindowed        = true,
                Flags             = SwapChainFlags.None,
                SwapEffect        = SwapEffect.Discard
            };

            // Create Device and DeviceContext
            ID3D11Device        TempDevice        = null;
            ID3D11DeviceContext TempDeviceContext = null;

            D3D11.D3D11CreateDevice(adapter, DriverType.Hardware, DeviceCreationFlags.None, null, out TempDevice, out TempDeviceContext);

            Device        = TempDevice.QueryInterface <ID3D11Device1>();
            DeviceContext = TempDeviceContext.QueryInterface <ID3D11DeviceContext1>();
            TempDevice.Dispose();
            TempDeviceContext.Dispose();

            // Create SwapChain
            SwapChain = factory.CreateSwapChain(Device, swapChainDesc);
            factory.MakeWindowAssociation(WindowHandle, WindowAssociationFlags.IgnoreAltEnter);

            var backBuffer = SwapChain.GetBuffer <ID3D11Texture2D>(0);

            m_RenderTargetView = Device.CreateRenderTargetView(backBuffer);
            backBuffer.Dispose();

            // Create blend state
            BlendDescription bsd = new BlendDescription()
            {
                AlphaToCoverageEnable  = false,//true,
                IndependentBlendEnable = false,
            };

            bsd.RenderTarget[0].BlendOperationAlpha   = BlendOperation.Add;
            bsd.RenderTarget[0].BlendOperation        = BlendOperation.Add;
            bsd.RenderTarget[0].DestinationBlendAlpha = Blend.One;
            bsd.RenderTarget[0].DestinationBlend      = Blend.InverseSourceAlpha;
            bsd.RenderTarget[0].IsBlendEnabled        = true;
            bsd.RenderTarget[0].RenderTargetWriteMask = ColorWriteEnable.All;
            bsd.RenderTarget[0].SourceBlendAlpha      = Blend.Zero;
            bsd.RenderTarget[0].SourceBlend           = Blend.SourceAlpha;
            bsd.AlphaToCoverageEnable = true;

            ID3D11BlendState bsAlpha = Device.CreateBlendState(bsd);

            // Set Blend State
            DeviceContext.OMSetBlendState(bsAlpha);
            BuildDepthStencilView(1920, 1080);

            // Create rasterizers
            m_RSDesc = new RasterizerDescription()
            {
                AntialiasedLineEnable = false,
                CullMode              = CullMode.Back,
                DepthBias             = 0,
                DepthBiasClamp        = .0f,
                DepthClipEnable       = false,
                FillMode              = FillMode.Solid,
                FrontCounterClockwise = true,
                MultisampleEnable     = true,
                ScissorEnable         = false,
                SlopeScaledDepthBias  = .0f
            };

            m_RSCullSolid     = Device.CreateRasterizerState(m_RSDesc);
            m_RSDesc.CullMode = CullMode.None;
            m_RSSolid         = Device.CreateRasterizerState(m_RSDesc);
            m_RSDesc.FillMode = FillMode.Wireframe;
            m_RSWireFrame     = Device.CreateRasterizerState(m_RSDesc);
            m_RSDesc.CullMode = CullMode.Back;
            m_RSCullWireFrame = Device.CreateRasterizerState(m_RSDesc);

            UpdateRasterizer();
            return(true);
        }