Esempio n. 1
0
        /// <summary>
        /// Function called if this buffer is attached to a swap chain and it's been resized.
        /// </summary>
        /// <returns>TRUE if this depth buffer was bound to the pipeline, FALSE if not.</returns>
        internal bool OnDepthStencilResize()
        {
            bool result = (Graphics.Output.DepthStencilView != null) && (Graphics.Output.DepthStencilView.Resource == this);

            ReleaseResourceViews();

            D3DResource.Dispose();
            D3DResource = null;

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// Function to clean up the resource object.
        /// </summary>
        protected override void CleanUpResource()
        {
            if (D3DResource == null)
            {
                return;
            }

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

            if (IsRenderTarget)
            {
                GorgonRenderStatistics.RenderTargetCount--;
                GorgonRenderStatistics.RenderTargetSize -= D3DBuffer.Description.SizeInBytes;
            }

            switch (BufferType)
            {
            case BufferType.Constant:
                GorgonRenderStatistics.ConstantBufferCount--;
                GorgonRenderStatistics.ConstantBufferSize -= D3DBuffer.Description.SizeInBytes;
                break;

            case BufferType.Index:
                GorgonRenderStatistics.IndexBufferCount--;
                GorgonRenderStatistics.IndexBufferSize -= D3DBuffer.Description.SizeInBytes;
                break;

            case BufferType.Vertex:
                GorgonRenderStatistics.VertexBufferCount--;
                GorgonRenderStatistics.VertexBufferSize -= D3DBuffer.Description.SizeInBytes;
                break;

            case BufferType.Structured:
                GorgonRenderStatistics.StructuredBufferCount--;
                GorgonRenderStatistics.StructuredBufferSize -= D3DBuffer.Description.SizeInBytes;
                break;

            default:
                GorgonRenderStatistics.BufferCount--;
                GorgonRenderStatistics.BufferSize -= D3DBuffer.Description.SizeInBytes;
                break;
            }

            D3DResource.Dispose();
            D3DResource = null;
            D3DBuffer   = null;

            Gorgon.Log.Print("Destroyed {0} Buffer '{1}'.", LoggingLevel.Verbose, BufferType, Name);
        }
Esempio n. 3
0
        /// <summary>
        /// Function called when the attached swap chain is resized.
        /// </summary>
        /// <returns>TRUE if the swap chain was bound to slot 0, and needs to be rebound.</returns>
        internal bool OnSwapChainResize()
        {
            var  currentTarget = Graphics.Output.GetRenderTarget(0);
            bool result        = currentTarget != null && currentTarget.Resource == this;

            ReleaseResourceViews();

            // Destroy the resource data.
            D3DResource.Dispose();
            D3DResource = null;

            return(result);
        }