Beispiel #1
0
        /// <summary>
        /// Function clean up any resources within this interface.
        /// </summary>
        internal void CleanUp()
        {
            if (PixelShader != null)
            {
                PixelShader.CleanUp();
            }

            if (VertexShader != null)
            {
                VertexShader.CleanUp();
            }

            if (GeometryShader != null)
            {
                GeometryShader.CleanUp();
            }

            if (ComputeShader != null)
            {
                ComputeShader.CleanUp();
            }

            if (HullShader != null)
            {
                HullShader.CleanUp();
            }

            if (DomainShader != null)
            {
                DomainShader.CleanUp();
            }

            ComputeShader  = null;
            GeometryShader = null;
            PixelShader    = null;
            VertexShader   = null;
        }
Beispiel #2
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>
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                // Dump any pending rendering.
                _cache.Reset();

                if (_initialState != null)
                {
                    _initialState.Restore(true);
                    _initialState = null;
                }

                TrackedObjects.ReleaseAll();

                if (Effects != null)
                {
                    Effects.FreeEffects();
                    Effects = null;
                }

                if (_currentTarget.SwapChain != null)
                {
                    _currentTarget.SwapChain.AfterSwapChainResized -= target_Resized;
                }

                if (DefaultLayout != null)
                {
                    DefaultLayout.Dispose();
                }

                if (VertexShader != null)
                {
                    VertexShader.CleanUp();
                }

                if (PixelShader != null)
                {
                    PixelShader.CleanUp();
                }

                VertexShader = null;
                PixelShader  = null;

                DefaultVertexBufferBinding.VertexBuffer.Dispose();

                if (DefaultIndexBuffer != null)
                {
                    DefaultIndexBuffer.Dispose();
                }

                if ((_systemCreatedTarget) && (_defaultTarget.Target != null))
                {
                    _defaultTarget.Target.Resource.Dispose();
                    _defaultTarget = default(Gorgon2DTarget);
                }

                Graphics.RemoveTrackedObject(this);
            }

            _disposed = true;
        }