Exemplo n.º 1
0
        protected override void CreateImpl()
        {
            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount = (int)Desc.BufferCount,
                ModeDescription = new ModeDescription((int) Desc.Width, (int)Desc.Height, new Rational(0,0), Memory.Enums.ToDXGIFormat[(int)Desc.Format]),
                Usage = Usage.RenderTargetOutput,
                SwapEffect = SwapEffect.FlipDiscard,
                OutputHandle = Desc.WindowHandle,
                SampleDescription = new SampleDescription
                {
                    Count = (int) Desc.SampleCount,
                    Quality = (int) Desc.SampleQuality
                },
                IsWindowed = !Desc.Fullscreen
            };
            using (var factory = new Factory4())
            {
                var tempSwapChain = new SharpDX.DXGI.SwapChain(factory, ((CommandQueue)Desc.AssociatedGraphicsQueue).CommandQueueD3D12, swapChainDesc);
                SwapChainDXGI = tempSwapChain.QueryInterface<SwapChain3>();
                tempSwapChain.Dispose();
                CurrentBackBufferIndex = (uint)SwapChainDXGI.CurrentBackBufferIndex;
            }

            SwapChainDXGI.DebugName = Label;

            Log.Info("Created SwapChain");
        }
 internal void ReleaseDevices()
 {
     IsRendererSuppressed = true;
     RenderTarget.Dispose();
     Backbuffer.Dispose();
     RenderTargetSurface.Dispose();
     RenderTargetView.Dispose();
     D2DDeviceContext.Dispose();
     D2DDevice.Dispose();
     D2DFactory.Dispose();
     DXGIDevice.Dispose();
     D3DDevice.Dispose();
     D3DDefaultDevice.Dispose();
     SwapChain.Dispose();
     SwapChain           = null;
     RenderTarget        = null;
     RenderTargetSurface = null;
     Backbuffer          = null;
     RenderTargetView    = null;
     D2DDeviceContext    = null;
     D2DFactory          = null;
     D2DDevice           = null;
     DXGIDevice          = null;
     D3DDevice           = null;
     D3DDefaultDevice    = null;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Disposes of object resources.
        /// </summary>
        /// <param name="disposeManagedResources">If true, managed resources should be
        /// disposed of in addition to unmanaged resources.</param>
        protected virtual void Dispose(bool disposeManagedResources)
        {
            if (disposeManagedResources)
            {
                _d3d11Device.Dispose();
                _dxgiDevice.Dispose();
                _backBuffer.Dispose();
                _targetBitmap.Dispose();
                _backBuffer2.Dispose();
                _targetBitmap2.Dispose();
                _d2dDevice.Dispose();
                swapChain.Dispose();
                swapChain2.Dispose();
                d2dContext.Dispose();
                d2dContext2.Dispose();
                dw_Factory.Dispose();
            }

            _d3d11Device   = null;
            _dxgiDevice    = null;
            _backBuffer    = null;
            _targetBitmap  = null;
            _backBuffer2   = null;
            _targetBitmap2 = null;
            _d2dDevice     = null;
            swapChain      = null;
            swapChain2     = null;
            d2dContext     = null;
            d2dContext2    = null;
            dw_Factory     = null;
        }
Exemplo n.º 4
0
        protected override void CreateImpl()
        {
            var swapChainDesc = new SwapChainDescription()
            {
                BufferCount       = (int)Desc.BufferCount,
                ModeDescription   = new ModeDescription((int)Desc.Width, (int)Desc.Height, new Rational(0, 0), Memory.Enums.ToDXGIFormat[(int)Desc.Format]),
                Usage             = Usage.RenderTargetOutput,
                SwapEffect        = SwapEffect.FlipDiscard,
                OutputHandle      = Desc.WindowHandle,
                SampleDescription = new SampleDescription
                {
                    Count   = (int)Desc.SampleCount,
                    Quality = (int)Desc.SampleQuality
                },
                IsWindowed = !Desc.Fullscreen
            };

            using (var factory = new Factory4())
            {
                var tempSwapChain = new SharpDX.DXGI.SwapChain(factory, ((CommandQueue)Desc.AssociatedGraphicsQueue).CommandQueueD3D12, swapChainDesc);
                SwapChainDXGI = tempSwapChain.QueryInterface <SwapChain3>();
                tempSwapChain.Dispose();
                CurrentBackBufferIndex = (uint)SwapChainDXGI.CurrentBackBufferIndex;
            }

            SwapChainDXGI.DebugName = Label;

            Log.Info("Created SwapChain");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)                 //Managed here
                {
                    if (d3dRenderTarget != null)
                    {
                        d3dRenderTarget.Dispose();
                    }
                    if (d3dDepthStencil != null)
                    {
                        d3dDepthStencil.Dispose();
                    }
                    if (swapChain != null)
                    {
                        swapChain.Dispose();
                    }
                    if (d3dDevice != null)
                    {
                        d3dDevice.Dispose();
                    }
                    if (d3dContext != null)
                    {
                        d3dContext.Dispose();
                    }
                }
                //Unmanaged here

                disposed = true;
            }
        }
Exemplo n.º 6
0
 public void Dispose()
 {
     backBuffer.Dispose();
     swapChain.Dispose();
     surface.Dispose();
     RenderTarget.Dispose();
     direct2DFactory.Dispose();
     device.Dispose();
 }
Exemplo n.º 7
0
        public void Dispose()
        {
            renderForm.Dispose();
            swapChain.Dispose();
            device.Dispose();
            renderer.Dispose();

            Console.Write(SharpDX.Diagnostics.ObjectTracker.ReportActiveObjects());
        }
Exemplo n.º 8
0
        public void Dispose()
        {
            // Release all resources

            figures.Dispose();

            if (ctx != null)
            {
                ctx.ClearState();
                ctx.Flush();
                ctx.Dispose();
            }

            if (il != null)
            {
                il.Dispose();
            }
            if (effect != null)
            {
                effect.Dispose();
            }

            if (hmd != null)
            {
                keyboard.Dispose();
                directInput.Dispose();

                mtex.Dispose();
                layers.Dispose();

                eye_texes[0].Dispose();
                eye_texes[1].Dispose();

                default_rasterizer_state.Dispose();
                default_depth_stencil_state.Dispose();
                default_blend_state.Dispose();

                ztex_view.Dispose();
                ztex.Dispose();

                buf0_view.Dispose();
                buf0.Dispose();

                swap_chain.Dispose();
                dxgi_factory.Dispose();

                // Disposing the device, before the hmd, will cause the hmd to fail when disposing.
                // Disposing the device, after the hmd, will cause the dispose of the device to fail.
                // It looks as if the hmd steals ownership of the device and destroys it, when it's shutting down.
                // device.Dispose();

                hmd.Dispose();
            }
            oculus.Dispose();
        }
Exemplo n.º 9
0
 public void Dispose()
 {
     if (RenderTarget != null)
     {
         RenderTarget.Dispose();
     }
     if (swapChain != null)
     {
         swapChain.Dispose();
     }
 }
Exemplo n.º 10
0
 public override void Dispose()
 {
     Context.ClearState();
     Context.Flush();
     Context.Dispose();
     states.Dispose();
     backBufferView.Dispose();
     backBuffer.Dispose();
     surface.Dispose();
     swapChain.Dispose();
     OutputRefCountOfLiveObjectsToFindMemoryLeaksInDebugMode();
     nativeDevice.Dispose();
 }
Exemplo n.º 11
0
    public void Dispose()
    {
        m_renderForm.Dispose();
        m_renderTargetView.Dispose();
        m_swapChain.Dispose();
        m_d3d11Device.Dispose();
        m_d3d11DeviceContext.Dispose();

        m_triangleVertexBuffer.Dispose();
        m_vertexShader.Dispose();
        m_pixelShader.Dispose();

        m_inputLayout.Dispose();
        m_inputSignature.Dispose();
    }
Exemplo n.º 12
0
        public void Dispose()
        {
            localHook.ThreadACL.SetInclusiveACL(new int[] { 0 });
            localHook.Dispose();
            localHook = null;

            swapChain.Dispose();
            swapChain = null;

            device.Dispose();
            device = null;

            DestroyWindow(hwnd);
            hwnd = IntPtr.Zero;
        }
Exemplo n.º 13
0
        public void Dispose()
        {
            brush.Dispose();

            wrFactory.Dispose();
            target.Dispose();
            bb.Dispose();
            fac.Dispose();
            d2dDevice.Dispose();
            dxgiFactory2.Dispose();
            dxgiAdapter.Dispose();
            dxgiDevice2.Dispose();
            defDevice.Dispose();
            d3device.Dispose();
            swapChain.Dispose();
            d2dContext.Dispose();
        }
Exemplo n.º 14
0
 private void disposeResources()
 {
     if (renderTarget != null)
     {
         renderTarget.Dispose();
     }
     if (swapChain != null)
     {
         swapChain.Dispose();
     }
     if (backbufferView != null)
     {
         backbufferView.Dispose();
     }
     if (backbuffer != null)
     {
         backbuffer.Dispose();
     }
 }
Exemplo n.º 15
0
        protected override void OnHandleDestroyed(EventArgs e)
        {
            if (_swapChain != null)
            {
                _swapChain.Dispose();
                _swapChain = null;
            }

            if (_d3dDevice != null)
            {
                if (_d3dDevice.ImmediateContext.Rasterizer.State != null)
                {
                    _d3dDevice.ImmediateContext.Rasterizer.State.Dispose();
                }
                _d3dDevice.Dispose();
                _d3dDevice = null;
            }

            base.OnHandleDestroyed(e);
        }
Exemplo n.º 16
0
        public void Dispose()
        {
            foreach (KeyValuePair <string, D2D1.Brush> p in Brushes)
            {
                p.Value.Dispose();
            }
            DashStyle.Dispose();

            D2DTarget.Dispose();
            D2DDevice.Dispose();
            D2DContext.Dispose();
            D2DFactory.Dispose();

            BlackTextureView.Dispose();
            WhiteTextureView.Dispose();
            AnisotropicSampler.Dispose();

            blendStateOpaque.Dispose();
            blendStateTransparent.Dispose();

            rasterizerStateSolidCullBack.Dispose();
            rasterizerStateWireframeCullBack.Dispose();
            rasterizerStateSolidNoCull.Dispose();
            rasterizerStateWireframeNoCull.Dispose();
            depthStencilStateDefault.Dispose();
            depthStencilStateNoDepth.Dispose();

            foreach (Camera c in Cameras)
            {
                c.Dispose();
            }
            constantBuffer.Dispose();

            swapChain.Dispose();
            Device.Dispose();
            Context.Dispose();
        }
Exemplo n.º 17
0
        private List<IntPtr> GetProcAddress()
        {
            var address = new List<IntPtr>();

            _device12 = new SharpDX.Direct3D12.Device(null, SharpDX.Direct3D.FeatureLevel.Level_11_0);
            using (var renderForm = new Form())
            {
                using (var factory = new SharpDX.DXGI.Factory4())
                {
                    _commandQueue
                        = _device12.CreateCommandQueue(new SharpDX.Direct3D12.CommandQueueDescription(SharpDX.Direct3D12.CommandListType.Direct));

                    _commandAllocator
                        = _device12.CreateCommandAllocator(CommandListType.Direct);

                    _commandList
                        = _device12.CreateCommandList(CommandListType.Direct, _commandAllocator, null);

                    var swapChainDesc = new SharpDX.DXGI.SwapChainDescription()
                    {
                        BufferCount = 2,
                        ModeDescription = new SharpDX.DXGI.ModeDescription(100, 100, new SharpDX.DXGI.Rational(60, 1), SharpDX.DXGI.Format.R8G8B8A8_UNorm),
                        Usage = SharpDX.DXGI.Usage.RenderTargetOutput,
                        SwapEffect = SharpDX.DXGI.SwapEffect.FlipDiscard,
                        OutputHandle = renderForm.Handle,
                        Flags = SwapChainFlags.AllowModeSwitch,
                        SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                        IsWindowed = true
                    };

                    var tempSwapChain = new SharpDX.DXGI.SwapChain(factory, _commandQueue, swapChainDesc);
                    _swapChain = tempSwapChain.QueryInterface<SharpDX.DXGI.SwapChain3>();
                    tempSwapChain.Dispose();
                }

                if (_device12 != null && _swapChain != null)
                {
                    address.AddRange(GetVTblAddresses(_device12.NativePointer, 44));
                    address.AddRange(GetVTblAddresses(_commandQueue.NativePointer, 19));
                    address.AddRange(GetVTblAddresses(_commandAllocator.NativePointer, 9));
                    address.AddRange(GetVTblAddresses(_commandList.NativePointer, 60));
                    address.AddRange(GetVTblAddresses(_swapChain.NativePointer, 18));

                    _device12.Dispose();
                    _device12 = null;

                    _commandQueue.Dispose();
                    _commandQueue = null;

                    _commandAllocator.Dispose();
                    _commandAllocator = null;

                    _commandList.Dispose();
                    _commandList = null;

                    _swapChain.Dispose();
                    _swapChain = null;
                }
            }

            return address;
        }
Exemplo n.º 18
0
 public void Dispose()
 {
     chain?.Dispose();
 }