/// <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 GorgonDepthStencil1D(Graphics, Name + "_Internal_DepthStencil_" + Guid.NewGuid(), new GorgonDepthStencil1DSettings { Format = Settings.DepthStencilFormat, Width = Settings.Width, ArrayCount = Settings.ArrayCount, MipCount = Settings.MipCount }); } else { DepthStencilBuffer.Settings.Format = Settings.DepthStencilFormat; DepthStencilBuffer.Settings.Width = Settings.Width; } #if DEBUG Graphics.Output.ValidateDepthStencilSettings(DepthStencilBuffer.Settings); #endif DepthStencilBuffer.Initialize(null); DepthStencilBuffer.RenderTarget = this; }
/// <summary> /// Function to clean up any internal resources. /// </summary> protected override void CleanUpResource() { Gorgon.Log.Print("GorgonRenderTarget '{0}': Releasing D3D11 render target view...", LoggingLevel.Intermediate, Name); GorgonRenderStatistics.RenderTargetCount--; GorgonRenderStatistics.RenderTargetSize -= SizeInBytes; if (DepthStencilBuffer != null) { Gorgon.Log.Print("GorgonRenderTarget '{0}': Releasing internal depth stencil...", LoggingLevel.Verbose, Name); DepthStencilBuffer.RenderTarget = null; DepthStencilBuffer.Dispose(); DepthStencilBuffer = null; } base.CleanUpResource(); }
/// <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; } }
/// <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(GorgonDepthStencil1D target) { return(target == null ? null : target._defaultView); }