/// <summary>
        /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
        /// </summary>
        /// <param name="texture">A 2D texture.</param>
        /// <param name="viewDimension">The depth-stencil type of the view.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
        /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
        /// <param name="arraySize">The number of elements in the array.</param>
        /// <param name="options">A value that describes whether the texture is read only.</param>
        public D3D11DepthStencilViewDesc(
            D3D11Texture2D texture,
            D3D11DsvDimension viewDimension,
            DxgiFormat format,
            uint mipSlice,
            uint firstArraySlice,
            uint arraySize,
            D3D11DepthStencilViewOptions options)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            this.texture1D        = new D3D11Texture1DDsv();
            this.texture1DArray   = new D3D11Texture1DArrayDsv();
            this.texture2D        = new D3D11Texture2DDsv();
            this.texture2DArray   = new D3D11Texture2DArrayDsv();
            this.texture2DMs      = new D3D11Texture2DMsDsv();
            this.texture2DMsArray = new D3D11Texture2DMsArrayDsv();

            this.viewDimension = viewDimension;
            this.options       = options;

            if (format == DxgiFormat.Unknown ||
                (arraySize == uint.MaxValue &&
                 (viewDimension == D3D11DsvDimension.Texture2DArray ||
                  viewDimension == D3D11DsvDimension.Texture2DMsArray)))
            {
                var desciption = texture.Description;

                if (format == DxgiFormat.Unknown)
                {
                    format = desciption.Format;
                }

                if (arraySize == uint.MaxValue)
                {
                    arraySize = desciption.ArraySize - firstArraySlice;
                }
            }

            this.format = format;

            switch (viewDimension)
            {
            case D3D11DsvDimension.Texture2D:
                this.texture2D = new D3D11Texture2DDsv
                {
                    MipSlice = mipSlice
                };
                break;

            case D3D11DsvDimension.Texture2DArray:
                this.texture2DArray = new D3D11Texture2DArrayDsv
                {
                    MipSlice        = mipSlice,
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            case D3D11DsvDimension.Texture2DMs:
                this.texture2DMs = new D3D11Texture2DMsDsv
                {
                };
                break;

            case D3D11DsvDimension.Texture2DMsArray:
                this.texture2DMsArray = new D3D11Texture2DMsArrayDsv
                {
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            default:
                throw new ArgumentOutOfRangeException("viewDimension");
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11DepthStencilViewDesc"/> struct.
        /// </summary>
        /// <param name="viewDimension">The depth-stencil type of the view.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="mipSlice">The index of the mipmap level to use mip slice.</param>
        /// <param name="firstArraySlice">The index of the first element to use in an array of elements.</param>
        /// <param name="arraySize">The number of elements in the array.</param>
        /// <param name="options">A value that describes whether the texture is read only.</param>
        public D3D11DepthStencilViewDesc(
            D3D11DsvDimension viewDimension,
            DxgiFormat format,
            uint mipSlice,
            uint firstArraySlice,
            uint arraySize,
            D3D11DepthStencilViewOptions options)
        {
            this.texture1D        = new D3D11Texture1DDsv();
            this.texture1DArray   = new D3D11Texture1DArrayDsv();
            this.texture2D        = new D3D11Texture2DDsv();
            this.texture2DArray   = new D3D11Texture2DArrayDsv();
            this.texture2DMs      = new D3D11Texture2DMsDsv();
            this.texture2DMsArray = new D3D11Texture2DMsArrayDsv();

            this.format        = format;
            this.viewDimension = viewDimension;
            this.options       = options;

            switch (viewDimension)
            {
            case D3D11DsvDimension.Texture1D:
                this.texture1D = new D3D11Texture1DDsv
                {
                    MipSlice = mipSlice
                };
                break;

            case D3D11DsvDimension.Texture1DArray:
                this.texture1DArray = new D3D11Texture1DArrayDsv
                {
                    MipSlice        = mipSlice,
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            case D3D11DsvDimension.Texture2D:
                this.texture2D = new D3D11Texture2DDsv
                {
                    MipSlice = mipSlice
                };
                break;

            case D3D11DsvDimension.Texture2DArray:
                this.texture2DArray = new D3D11Texture2DArrayDsv
                {
                    MipSlice        = mipSlice,
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            case D3D11DsvDimension.Texture2DMs:
                this.texture2DMs = new D3D11Texture2DMsDsv
                {
                };
                break;

            case D3D11DsvDimension.Texture2DMsArray:
                this.texture2DMsArray = new D3D11Texture2DMsArrayDsv
                {
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            default:
                throw new ArgumentOutOfRangeException("viewDimension");
            }
        }