Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GorgonDepthStencilView"/> class.
        /// </summary>
        /// <param name="resource">The resource to bind to the view.</param>
        /// <param name="format">The format of the view.</param>
        /// <param name="mipSlice">The mip level to use for the view.</param>
        /// <param name="firstArrayIndex">The first array index to use for the view.</param>
        /// <param name="arrayCount">The number of array indices to use for the view.</param>
        /// <param name="flags">Depth/stencil view flags.</param>
        internal GorgonDepthStencilView(GorgonResource resource, BufferFormat format, int mipSlice, int firstArrayIndex, int arrayCount, DepthStencilViewFlags flags)
            : base(resource, format)
        {
            MipSlice        = mipSlice;
            FirstArrayIndex = firstArrayIndex;
            ArrayCount      = arrayCount;
            Flags           = flags;

            switch (resource.ResourceType)
            {
            case ResourceType.Texture1D:
                _depth1D = (GorgonDepthStencil1D)resource;
                break;

            case ResourceType.Texture2D:
                _depth2D = (GorgonDepthStencil2D)resource;
                break;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Function to clean up any internal resources.
        /// </summary>
        protected override void CleanUpResource()
        {
            Gorgon.Log.Print("Destroying GorgonRenderTarget '{0}'...", LoggingLevel.Intermediate, Name);
            GorgonRenderStatistics.RenderTargetCount--;
            GorgonRenderStatistics.RenderTargetSize -= SizeInBytes * (_swapChain == null ? 1 : _swapChain.Settings.BufferCount);

            if (DepthStencilBuffer != null)
            {
                // If the swap chain is resized, we don't want to destroy these objects.
                if (_swapChain == null)
                {
                    Gorgon.Log.Print("GorgonRenderTarget '{0}': Releasing internal depth stencil...",
                                     LoggingLevel.Verbose,
                                     Name);
                    DepthStencilBuffer.Dispose();
                    DepthStencilBuffer = null;
                }
            }

            base.CleanUpResource();
        }
Esempio n. 3
0
        /// <summary>
        /// Function to create the depth/stencil buffer for the target.
        /// </summary>
        private void CreateDepthStencilBuffer()
        {
            // Create the internal depth/stencil.
            if (Settings.DepthStencilFormat == BufferFormat.Unknown)
            {
                return;
            }

            Gorgon.Log.Print("GorgonRenderTarget '{0}': Creating internal depth/stencil...", LoggingLevel.Verbose, Name);

            if (DepthStencilBuffer == null)
            {
                DepthStencilBuffer = new GorgonDepthStencil2D(Graphics,
                                                              Name + "_Internal_DepthStencil_" + Guid.NewGuid(),
                                                              new GorgonDepthStencil2DSettings
                {
                    Format        = Settings.DepthStencilFormat,
                    Width         = Settings.Width,
                    Height        = Settings.Height,
                    Multisampling = Settings.Multisampling,
                    ArrayCount    = Settings.ArrayCount,
                    MipCount      = Settings.MipCount
                });
            }
            else
            {
                DepthStencilBuffer.Settings.Format        = Settings.DepthStencilFormat;
                DepthStencilBuffer.Settings.Width         = Settings.Width;
                DepthStencilBuffer.Settings.Height        = Settings.Height;
                DepthStencilBuffer.Settings.Multisampling = Settings.Multisampling;
            }

#if DEBUG
            Graphics.Output.ValidateDepthStencilSettings(DepthStencilBuffer.Settings);
#endif

            DepthStencilBuffer.Initialize(null);
            DepthStencilBuffer.RenderTarget = this;
        }
Esempio n. 4
0
 /// <summary>
 /// Function to retrieve the depth stencil  view for a depth stencil .
 /// </summary>
 /// <param name="target">Render target to evaluate.</param>
 /// <returns>The depth stencil  view for the swap chain.</returns>
 public static GorgonDepthStencilView ToDepthStencilView(GorgonDepthStencil2D target)
 {
     return(target == null ? null : target._defaultView);
 }