Пример #1
0
        /// <summary>Gets the render target view.</summary>
        /// <param name="viewType">Type of the view.</param>
        /// <param name="arrayOrDepthSlice">The array original depth slice.</param>
        /// <param name="mipIndex">Index of the mip.</param>
        /// <returns>TextureView.</returns>
        /// <exception cref="System.NotSupportedException">ViewSlice.MipBand is not supported for render targets</exception>
        internal override TextureView GetRenderTargetView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.RenderTarget) == 0)
            {
                return(null);
            }

            if (viewType == ViewType.MipBand)
            {
                throw new NotSupportedException("ViewSlice.MipBand is not supported for render targets");
            }

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var rtvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.renderTargetViews)
            {
                var rtv = this.renderTargetViews[rtvIndex];

                // Creates the shader resource view
                if (rtv == null)
                {
                    // Create the render target view
                    var rtvDescription = new RenderTargetViewDescription()
                    {
                        Format    = this.Description.Format,
                        Dimension = RenderTargetViewDimension.Texture3D,
                        Texture3D =
                        {
                            DepthSliceCount = arrayCount,
                            FirstDepthSlice = arrayOrDepthSlice,
                            MipSlice        = mipIndex,
                        }
                    };

                    rtv = new TextureView(this, new RenderTargetView(GraphicsDevice, Resource, rtvDescription));
                    this.renderTargetViews[rtvIndex] = ToDispose(rtv);
                }

                return(rtv);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        protected override void InitializeViews()
        {
            if ((this.Description.BindFlags & BindFlags.RenderTarget) != 0)
            {
                this.renderTargetViews = new TextureView[GetViewCount()];
            }

            if (pureRenderTarget)
            {
                renderTargetViews[0] = new TextureView(this, customRenderTargetView);
            }
            else
            {
                // Perform default initialization
                base.InitializeViews();

                if ((this.Description.BindFlags & BindFlags.RenderTarget) != 0)
                {
                    GetRenderTargetView(ViewType.Full, 0, 0);
                }
            }
        }
Пример #3
0
        internal override TextureView GetShaderResourceView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
            {
                return(null);
            }

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var srvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                var srv = this.shaderResourceViews[srvIndex];

                // Creates the shader resource view
                if (srv == null)
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription {
                        Format    = this.Description.Format,
                        Dimension = ShaderResourceViewDimension.Texture3D,
                        Texture3D =
                        {
                            MipLevels       = mipCount,
                            MostDetailedMip = mipIndex
                        }
                    };

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews[srvIndex] = ToDispose(srv);
                }

                return(srv);
            }
        }
Пример #4
0
        /// <summary>Initializes the views.</summary>
        protected override void InitializeViews()
        {
            if ((this.Description.BindFlags & BindFlags.RenderTarget) != 0)
            {
                this.renderTargetViews = new TextureView[GetViewCount()];
            }

            if (pureRenderTarget)
            {
                renderTargetViews[0] = new TextureView(this, customRenderTargetView);
            }
            else
            {
                // Perform default initialization
                base.InitializeViews();

                if ((this.Description.BindFlags & BindFlags.RenderTarget) != 0)
                {
                    GetRenderTargetView(ViewType.Full, 0, 0);
                }
            }
        }
Пример #5
0
        internal override TextureView GetShaderResourceView(Format viewFormat, ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
            {
                return(null);
            }

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var textureViewKey = new TextureViewKey(viewFormat, viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                TextureView srv;
                // Creates the shader resource view
                if (!shaderResourceViews.TryGetValue(textureViewKey, out srv))
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription {
                        Format    = viewFormat,
                        Dimension = ShaderResourceViewDimension.Texture3D,
                        Texture3D =
                        {
                            MipLevels       = mipCount,
                            MostDetailedMip = mipIndex
                        }
                    };

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews.Add(textureViewKey, ToDispose(srv));
                }

                return(srv);
            }
        }
Пример #6
0
        internal override TextureView GetShaderResourceView(Format viewFormat, ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
            {
                return(null);
            }

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var textureViewKey = new TextureViewKey(viewFormat, viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                TextureView srv;
                // Creates the shader resource view
                if (!shaderResourceViews.TryGetValue(textureViewKey, out srv))
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription()
                    {
                        Format = viewFormat
                    };

                    // Initialize for texture arrays or texture cube
                    if (this.Description.ArraySize > 1)
                    {
                        // If texture cube
                        if ((this.Description.OptionFlags & ResourceOptionFlags.TextureCube) != 0)
                        {
                            srvDescription.Dimension                   = ShaderResourceViewDimension.TextureCube;
                            srvDescription.TextureCube.MipLevels       = mipCount;
                            srvDescription.TextureCube.MostDetailedMip = mipIndex;
                        }
                        else
                        {
                            // Else regular Texture2D
                            srvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? ShaderResourceViewDimension.Texture2DMultisampledArray : ShaderResourceViewDimension.Texture2DArray;

                            // Multisample?
                            if (this.Description.SampleDescription.Count > 1)
                            {
                                srvDescription.Texture2DMSArray.ArraySize       = arrayCount;
                                srvDescription.Texture2DMSArray.FirstArraySlice = arrayOrDepthSlice;
                            }
                            else
                            {
                                srvDescription.Texture2DArray.ArraySize       = arrayCount;
                                srvDescription.Texture2DArray.FirstArraySlice = arrayOrDepthSlice;
                                srvDescription.Texture2DArray.MipLevels       = mipCount;
                                srvDescription.Texture2DArray.MostDetailedMip = mipIndex;
                            }
                        }
                    }
                    else
                    {
                        srvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D;
                        if (this.Description.SampleDescription.Count <= 1)
                        {
                            srvDescription.Texture2D.MipLevels       = mipCount;
                            srvDescription.Texture2D.MostDetailedMip = mipIndex;
                        }
                    }

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews.Add(textureViewKey, ToDispose(srv));
                }

                return(srv);
            }
        }
Пример #7
0
        internal override TextureView GetRenderTargetView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.RenderTarget) == 0)
                return null;

            if (viewType == ViewType.MipBand)
                throw new NotSupportedException("ViewSlice.MipBand is not supported for render targets");

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var rtvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.renderTargetViews)
            {
                var rtv = this.renderTargetViews[rtvIndex];

                // Creates the shader resource view
                if (rtv == null)
                {
                    // Create the render target view
                    var rtvDescription = new RenderTargetViewDescription {
                        Format = this.Description.Format,
                        Dimension = RenderTargetViewDimension.Texture2DArray,
                        Texture2DArray = {
                            ArraySize = arrayCount,
                            FirstArraySlice = arrayOrDepthSlice,
                            MipSlice = mipIndex
                        }
                    };

                    rtv = new TextureView(this, new RenderTargetView(GraphicsDevice, Resource, rtvDescription));
                    this.renderTargetViews[rtvIndex] = ToDispose(rtv);
                }

                return rtv;
            }
        }
Пример #8
0
        internal override TextureView GetRenderTargetView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.RenderTarget) == 0)
            {
                return(null);
            }

            if (viewType == ViewType.MipBand)
            {
                throw new NotSupportedException("ViewSlice.MipBand is not supported for render targets");
            }

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var rtvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.renderTargetViews)
            {
                var rtv = this.renderTargetViews[rtvIndex];

                // Creates the shader resource view
                if (rtv == null)
                {
                    // Create the render target view
                    var rtvDescription = new RenderTargetViewDescription()
                    {
                        Format = this.Description.Format
                    };

                    if (this.Description.ArraySize > 1)
                    {
                        rtvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? RenderTargetViewDimension.Texture2DMultisampledArray : RenderTargetViewDimension.Texture2DArray;
                        if (this.Description.SampleDescription.Count > 1)
                        {
                            rtvDescription.Texture2DMSArray.ArraySize       = arrayCount;
                            rtvDescription.Texture2DMSArray.FirstArraySlice = arrayOrDepthSlice;
                        }
                        else
                        {
                            rtvDescription.Texture2DArray.ArraySize       = arrayCount;
                            rtvDescription.Texture2DArray.FirstArraySlice = arrayOrDepthSlice;
                            rtvDescription.Texture2DArray.MipSlice        = mipIndex;
                        }
                    }
                    else
                    {
                        rtvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? RenderTargetViewDimension.Texture2DMultisampled : RenderTargetViewDimension.Texture2D;
                        if (this.Description.SampleDescription.Count <= 1)
                        {
                            rtvDescription.Texture2D.MipSlice = mipIndex;
                        }
                    }

                    rtv = new TextureView(this, new RenderTargetView(GraphicsDevice, Resource, rtvDescription));
                    this.renderTargetViews[rtvIndex] = ToDispose(rtv);
                }

                return(rtv);
            }
        }
Пример #9
0
        /// <summary>
        /// Gets a specific <see cref="DepthStencilView" /> from this texture.
        /// </summary>
        /// <param name="viewType">Type of the view slice.</param>
        /// <param name="arrayOrDepthSlice">The texture array slice index.</param>
        /// <param name="mipIndex">The mip map slice index.</param>
        /// <param name="readOnlyView">Indicates if the view is read-only.</param>
        /// <returns>A <see cref="DepthStencilView" /></returns>
        internal virtual TextureView GetDepthStencilView(ViewType viewType, int arrayOrDepthSlice, int mipIndex, bool readOnlyView)
        {
            if ((this.Description.BindFlags & BindFlags.DepthStencil) == 0)
            {
                return(null);
            }

            if (viewType == ViewType.MipBand)
            {
                throw new NotSupportedException("ViewSlice.MipBand is not supported for depth stencils");
            }

            if (readOnlyView && !HasReadOnlyView)
            {
                return(null);
            }

            var views = readOnlyView ? readOnlyViews : depthStencilViews;

            int arrayCount;
            int mipCount;

            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var dsvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (views)
            {
                var dsv = views[dsvIndex];

                // Creates the shader resource view
                if (dsv == null)
                {
                    // Create the depth stencil view
                    var dsvDescription = new DepthStencilViewDescription()
                    {
                        Format = (Format)DepthFormat
                    };

                    if (this.Description.ArraySize > 1)
                    {
                        dsvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? DepthStencilViewDimension.Texture2DMultisampledArray : DepthStencilViewDimension.Texture2DArray;
                        if (this.Description.SampleDescription.Count > 1)
                        {
                            dsvDescription.Texture2DMSArray.ArraySize       = arrayCount;
                            dsvDescription.Texture2DMSArray.FirstArraySlice = arrayOrDepthSlice;
                        }
                        else
                        {
                            dsvDescription.Texture2DArray.ArraySize       = arrayCount;
                            dsvDescription.Texture2DArray.FirstArraySlice = arrayOrDepthSlice;
                            dsvDescription.Texture2DArray.MipSlice        = mipIndex;
                        }
                    }
                    else
                    {
                        dsvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? DepthStencilViewDimension.Texture2DMultisampled : DepthStencilViewDimension.Texture2D;
                        if (this.Description.SampleDescription.Count <= 1)
                        {
                            dsvDescription.Texture2D.MipSlice = mipIndex;
                        }
                    }

                    if (readOnlyView)
                    {
                        dsvDescription.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                        if (HasStencil)
                        {
                            dsvDescription.Flags |= DepthStencilViewFlags.ReadOnlyStencil;
                        }
                    }

                    dsv             = new TextureView(this, new DepthStencilView(GraphicsDevice, Resource, dsvDescription));
                    views[dsvIndex] = ToDispose(dsv);
                }

                return(dsv);
            }
        }
Пример #10
0
        internal override TextureView GetShaderResourceView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
                return null;

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var srvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                var srv = this.shaderResourceViews[srvIndex];

                // Creates the shader resource view
                if (srv == null)
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription() { Format = GetDefaultViewFormat() };

                    // Initialize for texture arrays or texture cube
                    if (this.Description.ArraySize > 1)
                    {
                        // If texture cube
                        if ((this.Description.OptionFlags & ResourceOptionFlags.TextureCube) != 0)
                        {
                            srvDescription.Dimension = ShaderResourceViewDimension.TextureCube;
                            srvDescription.TextureCube.MipLevels = mipCount;
                            srvDescription.TextureCube.MostDetailedMip = mipIndex;
                        }
                        else
                        {
                            // Else regular Texture2D
                            srvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? ShaderResourceViewDimension.Texture2DMultisampledArray : ShaderResourceViewDimension.Texture2DArray;

                            // Multisample?
                            if (this.Description.SampleDescription.Count > 1)
                            {
                                srvDescription.Texture2DMSArray.ArraySize = arrayCount;
                                srvDescription.Texture2DMSArray.FirstArraySlice = arrayOrDepthSlice;
                            }
                            else
                            {
                                srvDescription.Texture2DArray.ArraySize = arrayCount;
                                srvDescription.Texture2DArray.FirstArraySlice = arrayOrDepthSlice;
                                srvDescription.Texture2DArray.MipLevels = mipCount;
                                srvDescription.Texture2DArray.MostDetailedMip = mipIndex;
                            }
                        }
                    }
                    else
                    {
                        srvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? ShaderResourceViewDimension.Texture2DMultisampled : ShaderResourceViewDimension.Texture2D;
                        if (this.Description.SampleDescription.Count <= 1)
                        {
                            srvDescription.Texture2D.MipLevels = mipCount;
                            srvDescription.Texture2D.MostDetailedMip = mipIndex;
                        }
                    }

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews[srvIndex] = ToDispose(srv);
                }

                return srv;
            }
        }
Пример #11
0
        internal override TextureView GetShaderResourceView(Format viewFormat, ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
                return null;

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var textureViewKey = new TextureViewKey(viewFormat, viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                TextureView srv;
                // Creates the shader resource view
                if (!shaderResourceViews.TryGetValue(textureViewKey, out srv))
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription() { Format = this.Description.Format };

                    // Initialize for texture arrays or texture cube
                    if (this.Description.ArraySize > 1)
                    {
                        // Else regular Texture1D
                        srvDescription.Dimension = ShaderResourceViewDimension.Texture1DArray;
                        srvDescription.Texture1DArray.ArraySize = arrayCount;
                        srvDescription.Texture1DArray.FirstArraySlice = arrayOrDepthSlice;
                        srvDescription.Texture1DArray.MipLevels = mipCount;
                        srvDescription.Texture1DArray.MostDetailedMip = mipIndex;
                    }
                    else
                    {
                        srvDescription.Dimension = ShaderResourceViewDimension.Texture1D;
                        srvDescription.Texture1D.MipLevels = mipCount;
                        srvDescription.Texture1D.MostDetailedMip = mipIndex;
                    }

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews.Add(textureViewKey, ToDispose(srv));
                }

                return srv;
            }
        }
Пример #12
0
        internal override TextureView GetShaderResourceView(Format viewFormat, ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
                return null;

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var textureViewKey = new TextureViewKey(viewFormat, viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                TextureView srv;
                // Creates the shader resource view
                if (!shaderResourceViews.TryGetValue(textureViewKey, out srv))
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription {
                        Format = viewFormat,
                        Dimension = ShaderResourceViewDimension.Texture3D,
                        Texture3D = {
                            MipLevels = mipCount,
                            MostDetailedMip = mipIndex
                        }
                    };

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews.Add(textureViewKey, ToDispose(srv));
                }

                return srv;
            }
        }
Пример #13
0
        internal override TextureView GetShaderResourceView(ViewType viewType, int arrayOrDepthSlice, int mipIndex)
        {
            if ((this.Description.BindFlags & BindFlags.ShaderResource) == 0)
                return null;

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var srvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (this.shaderResourceViews)
            {
                var srv = this.shaderResourceViews[srvIndex];

                // Creates the shader resource view
                if (srv == null)
                {
                    // Create the view
                    var srvDescription = new ShaderResourceViewDescription {
                        Format = this.Description.Format,
                        Dimension = ShaderResourceViewDimension.Texture3D,
                        Texture3D = {
                            MipLevels = mipCount,
                            MostDetailedMip = mipIndex
                        }
                    };

                    srv = new TextureView(this, new ShaderResourceView(this.GraphicsDevice, this.Resource, srvDescription));
                    this.shaderResourceViews[srvIndex] = ToDispose(srv);
                }

                return srv;
            }
        }
Пример #14
0
        /// <summary>
        /// Gets a specific <see cref="DepthStencilView" /> from this texture.
        /// </summary>
        /// <param name="viewType">Type of the view slice.</param>
        /// <param name="arrayOrDepthSlice">The texture array slice index.</param>
        /// <param name="mipMapSlice">The mip map slice index.</param>
        /// <param name="readOnlyView">Indicates if the view is read-only.</param>
        /// <returns>A <see cref="DepthStencilView" /></returns>
        internal virtual TextureView GetDepthStencilView(ViewType viewType, int arrayOrDepthSlice, int mipIndex, bool readOnlyView)
        {
            if ((this.Description.BindFlags & BindFlags.DepthStencil) == 0)
                return null;

            if (viewType == ViewType.MipBand)
                throw new NotSupportedException("ViewSlice.MipBand is not supported for depth stencils");

            if (readOnlyView && !HasReadOnlyView)
                return null;

            var views = readOnlyView ? readOnlyViews : depthStencilViews;

            int arrayCount;
            int mipCount;
            GetViewSliceBounds(viewType, ref arrayOrDepthSlice, ref mipIndex, out arrayCount, out mipCount);

            var dsvIndex = GetViewIndex(viewType, arrayOrDepthSlice, mipIndex);

            lock (views)
            {
                var dsv = views[dsvIndex];

                // Creates the shader resource view
                if (dsv == null)
                {
                    // Create the depth stencil view
                    var dsvDescription = new DepthStencilViewDescription() { Format = (Format)DepthFormat };

                    if (this.Description.ArraySize > 1)
                    {
                        dsvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? DepthStencilViewDimension.Texture2DMultisampledArray : DepthStencilViewDimension.Texture2DArray;
                        if (this.Description.SampleDescription.Count > 1)
                        {
                            dsvDescription.Texture2DMSArray.ArraySize = arrayCount;
                            dsvDescription.Texture2DMSArray.FirstArraySlice = arrayOrDepthSlice;
                        }
                        else
                        {
                            dsvDescription.Texture2DArray.ArraySize = arrayCount;
                            dsvDescription.Texture2DArray.FirstArraySlice = arrayOrDepthSlice;
                            dsvDescription.Texture2DArray.MipSlice = mipIndex;
                        }
                    }
                    else
                    {
                        dsvDescription.Dimension = this.Description.SampleDescription.Count > 1 ? DepthStencilViewDimension.Texture2DMultisampled : DepthStencilViewDimension.Texture2D;
                        if (this.Description.SampleDescription.Count <= 1)
                            dsvDescription.Texture2D.MipSlice = mipIndex;
                    }

                    if (readOnlyView)
                    {
                        dsvDescription.Flags = DepthStencilViewFlags.ReadOnlyDepth;
                        if (HasStencil)
                            dsvDescription.Flags |= DepthStencilViewFlags.ReadOnlyStencil;
                    }

                    dsv = new TextureView(this, new DepthStencilView(GraphicsDevice, Resource, dsvDescription));
                    views[dsvIndex] = ToDispose(dsv);
                }

                return dsv;
            }
        }