// Copyright © Amer Koleci and Contributors. // Licensed under the MIT License (MIT). See LICENSE in the repository root for more information. using static Win32.Graphics.Direct3D11.Apis; namespace Win32.Graphics.Direct3D11; public unsafe partial struct DepthStencilDescription { /// /// A built-in description with settings for not using a depth stencil buffer. /// public static readonly DepthStencilDescription None = new(false, DepthWriteMask.Zero); /// /// A built-in description with default settings for using a depth stencil buffer. /// public static readonly DepthStencilDescription Default = new(true, DepthWriteMask.All); /// /// A built-in description with settings for enabling a read-only depth stencil buffer. /// public static readonly DepthStencilDescription DepthRead = new(true, DepthWriteMask.Zero); /// /// A built-in description with settings for using a reverse depth stencil buffer. /// public static readonly DepthStencilDescription DepthReverseZ = new(true, DepthWriteMask.All, ComparisonFunction.GreaterEqual); /// /// A built-in description with settings for enabling a read-only reverse depth stencil buffer. /// public static readonly DepthStencilDescription DepthReadReverseZ = new(true, DepthWriteMask.Zero, ComparisonFunction.GreaterEqual); /// /// Initializes a new instance of the struct. /// /// Enable depth testing. /// Identify a portion of the depth-stencil buffer that can be modified by depth data. /// A function that compares depth data against existing depth data. public DepthStencilDescription( bool depthEnable, DepthWriteMask depthWriteMask, ComparisonFunction depthFunc = ComparisonFunction.LessEqual) { DepthEnable = depthEnable; DepthWriteMask = depthWriteMask; DepthFunc = depthFunc; StencilEnable = false; StencilReadMask = (byte)D3D11_DEFAULT_STENCIL_READ_MASK; StencilWriteMask = (byte)D3D11_DEFAULT_STENCIL_WRITE_MASK; FrontFace = DepthStencilOperationDescription.Default; BackFace = DepthStencilOperationDescription.Default; } /// /// Initializes a new instance of the struct. /// /// Specifies whether to enable depth testing. Set this member to true to enable depth testing. /// Specifies a value that identifies a portion of the depth-stencil buffer that can be modified by depth data. /// A value that identifies a function that compares depth data against existing depth data. /// Specifies whether to enable stencil testing. Set this member to true to enable stencil testing. /// Identify a portion of the depth-stencil buffer for reading stencil data. /// Identify a portion of the depth-stencil buffer for writing stencil data. /// /// /// /// /// /// /// /// public DepthStencilDescription( bool depthEnable, bool depthWriteEnable, ComparisonFunction depthFunc, bool stencilEnable, byte stencilReadMask, byte stencilWriteMask, StencilOperation frontStencilFailOp, StencilOperation frontStencilDepthFailOp, StencilOperation frontStencilPassOp, ComparisonFunction frontStencilFunc, StencilOperation backStencilFailOp, StencilOperation backStencilDepthFailOp, StencilOperation backStencilPassOp, ComparisonFunction backStencilFunc) { DepthEnable = depthEnable; DepthWriteMask = depthWriteEnable ? DepthWriteMask.All : DepthWriteMask.Zero; DepthFunc = depthFunc; StencilEnable = stencilEnable; StencilReadMask = stencilReadMask; StencilWriteMask = stencilWriteMask; FrontFace.StencilFailOp = frontStencilFailOp; FrontFace.StencilDepthFailOp = frontStencilDepthFailOp; FrontFace.StencilPassOp = frontStencilPassOp; FrontFace.StencilFunc = frontStencilFunc; BackFace.StencilFailOp = backStencilFailOp; BackFace.StencilDepthFailOp = backStencilDepthFailOp; BackFace.StencilPassOp = backStencilPassOp; BackFace.StencilFunc = backStencilFunc; } }