/// <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>
 public D3D11DepthStencilViewDesc(
     D3D11Texture2D texture,
     D3D11DsvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue, D3D11DepthStencilViewOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11RenderTargetViewDesc(
     D3D11Texture2D texture,
     D3D11RtvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11UnorderedAccessViewDesc(
     D3D11Texture2D texture,
     D3D11UavDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, 0, uint.MaxValue)
 {
 }
Exemple #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Texture2D texture,
     D3D11SrvDimension viewDimension,
     DxgiFormat format)
     : this(texture, viewDimension, format, 0, uint.MaxValue, 0, uint.MaxValue)
 {
 }
 /// <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>
 public D3D11DepthStencilViewDesc(
     D3D11Texture2D texture,
     D3D11DsvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice)
     : this(texture, viewDimension, format, mipSlice, firstArraySlice, uint.MaxValue, D3D11DepthStencilViewOptions.None)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource 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="firtArraySlice">The index of the first element to use in an array of elements.</param>
 public D3D11RenderTargetViewDesc(
     D3D11Texture2D texture,
     D3D11RtvDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firtArraySlice)
     : this(texture, viewDimension, format, mipSlice, firtArraySlice, uint.MaxValue)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11UnorderedAccessViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource 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>
 public D3D11UnorderedAccessViewDesc(
     D3D11Texture2D texture,
     D3D11UavDimension viewDimension,
     DxgiFormat format,
     uint mipSlice,
     uint firstArraySlice)
     : this(texture, viewDimension, format, mipSlice, firstArraySlice, uint.MaxValue)
 {
 }
Exemple #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="viewDimension">The resource type of the view.</param>
 /// <param name="format">The viewing format.</param>
 /// <param name="mostDetailedMip">The index of the most detailed mipmap level to use.</param>
 /// <param name="mipLevels">The maximum number of mipmap levels for the view.</param>
 public D3D11ShaderResourceViewDesc(
     D3D11Texture2D texture,
     D3D11SrvDimension viewDimension,
     DxgiFormat format,
     uint mostDetailedMip,
     uint mipLevels)
     : this(texture, viewDimension, format, mostDetailedMip, mipLevels, 0, uint.MaxValue)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11Viewport"/> struct.
        /// </summary>
        /// <param name="texture">A 2D texture.</param>
        /// <param name="view">The render-target view.</param>
        /// <param name="topLeftX">The X position of the left hand side of the viewport.</param>
        /// <param name="topLeftY">The Y position of the top of the viewport.</param>
        /// <param name="minDepth">The minimum depth of the viewport.</param>
        /// <param name="maxDepth">The maximum depth of the viewport.</param>
        public D3D11Viewport(D3D11Texture2D texture, D3D11RenderTargetView view, float topLeftX, float topLeftY, float minDepth, float maxDepth)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            if (view == null)
            {
                throw new ArgumentNullException("view");
            }

            var textureDescription = texture.Description;
            var viewDescription    = view.Description;

            uint mipSlice;

            switch (viewDescription.ViewDimension)
            {
            case D3D11RtvDimension.Texture2D:
                mipSlice = viewDescription.Texture2D.MipSlice;
                break;

            case D3D11RtvDimension.Texture2DArray:
                mipSlice = viewDescription.Texture2DArray.MipSlice;
                break;

            case D3D11RtvDimension.Texture2DMs:
            case D3D11RtvDimension.Texture2DMsArray:
                mipSlice = 0;
                break;

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

            uint subResourceWidth  = textureDescription.Width / (uint)(1 << (int)mipSlice);
            uint subResourceHeight = textureDescription.Height / (uint)(1 << (int)mipSlice);

            this.topLeftX = topLeftX;
            this.topLeftY = topLeftY;
            this.width    = (subResourceWidth != 0 ? subResourceWidth : 1) - topLeftX;
            this.height   = (subResourceHeight != 0 ? subResourceHeight : 1) - topLeftY;
            this.minDepth = minDepth;
            this.maxDepth = maxDepth;
        }
        /// <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="D3D11Viewport"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="view">The render-target view.</param>
 /// <param name="topLeftX">The X position of the left hand side of the viewport.</param>
 /// <param name="topLeftY">The Y position of the top of the viewport.</param>
 public D3D11Viewport(D3D11Texture2D texture, D3D11RenderTargetView view, float topLeftX, float topLeftY)
     : this(texture, view, topLeftX, topLeftY, 0.0f, 1.0f)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="D3D11Viewport"/> struct.
 /// </summary>
 /// <param name="texture">A 2D texture.</param>
 /// <param name="view">The render-target view.</param>
 public D3D11Viewport(D3D11Texture2D texture, D3D11RenderTargetView view)
     : this(texture, view, 0.0f, 0.0f, 0.0f, 1.0f)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11RenderTargetViewDesc"/> struct.
        /// </summary>
        /// <param name="texture">A 2D texture.</param>
        /// <param name="viewDimension">The resource 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="firtArraySlice">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>
        public D3D11RenderTargetViewDesc(
            D3D11Texture2D texture,
            D3D11RtvDimension viewDimension,
            DxgiFormat format,
            uint mipSlice,
            uint firtArraySlice,
            uint arraySize)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            this.buffer           = new D3D11BufferRtv();
            this.texture1D        = new D3D11Texture1DRtv();
            this.texture1DArray   = new D3D11Texture1DArrayRtv();
            this.texture2D        = new D3D11Texture2DRtv();
            this.texture2DArray   = new D3D11Texture2DArrayRtv();
            this.texture2DMs      = new D3D11Texture2DMsRtv();
            this.texture2DMsArray = new D3D11Texture2DMsArrayRtv();
            this.texture3D        = new D3D11Texture3DRtv();

            this.viewDimension = viewDimension;

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

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

                if (arraySize == uint.MaxValue)
                {
                    arraySize = description.ArraySize - firtArraySlice;
                }
            }

            this.format = format;

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

            case D3D11RtvDimension.Texture2DArray:
                this.texture2DArray = new D3D11Texture2DArrayRtv
                {
                    MipSlice        = mipSlice,
                    FirstArraySlice = firtArraySlice,
                    ArraySize       = arraySize
                };
                break;

            case D3D11RtvDimension.Texture2DMs:
                this.texture2DMs = new D3D11Texture2DMsRtv
                {
                };
                break;

            case D3D11RtvDimension.Texture2DMsArray:
                this.texture2DMsArray = new D3D11Texture2DMsArrayRtv
                {
                    FirstArraySlice = firtArraySlice,
                    ArraySize       = arraySize
                };
                break;

            default:
                throw new ArgumentOutOfRangeException("viewDimension");
            }
        }
Exemple #14
0
        /// <summary>
        /// Initializes a new instance of the <see cref="D3D11ShaderResourceViewDesc"/> struct.
        /// </summary>
        /// <param name="texture">A 2D texture.</param>
        /// <param name="viewDimension">The resource type of the view.</param>
        /// <param name="format">The viewing format.</param>
        /// <param name="mostDetailedMip">The index of the most detailed mipmap level to use.</param>
        /// <param name="mipLevels">The maximum number of mipmap levels for the view.</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>
        public D3D11ShaderResourceViewDesc(
            D3D11Texture2D texture,
            D3D11SrvDimension viewDimension,
            DxgiFormat format,
            uint mostDetailedMip,
            uint mipLevels,
            uint firstArraySlice,
            uint arraySize)
        {
            if (texture == null)
            {
                throw new ArgumentNullException("texture");
            }

            this.buffer           = new D3D11BufferSrv();
            this.texture1D        = new D3D11Texture1DSrv();
            this.texture1DArray   = new D3D11Texture1DArraySrv();
            this.texture2D        = new D3D11Texture2DSrv();
            this.texture2DArray   = new D3D11Texture2DArraySrv();
            this.texture2DMs      = new D3D11Texture2DMsSrv();
            this.texture2DMsArray = new D3D11Texture2DMsArraySrv();
            this.texture3D        = new D3D11Texture3DSrv();
            this.textureCube      = new D3D11TextureCubeSrv();
            this.textureCubeArray = new D3D11TextureCubeArraySrv();
            this.bufferEx         = new D3D11BufferExSrv();

            this.viewDimension = viewDimension;

            if (format == DxgiFormat.Unknown ||
                (mipLevels == uint.MaxValue &&
                 viewDimension != D3D11SrvDimension.Texture2DMs &&
                 viewDimension != D3D11SrvDimension.Texture2DMsArray) ||
                (arraySize == uint.MaxValue &&
                 viewDimension != D3D11SrvDimension.Texture2DArray &&
                 viewDimension != D3D11SrvDimension.Texture2DMsArray &&
                 viewDimension != D3D11SrvDimension.TextureCubeArray))
            {
                var description = texture.Description;

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

                if (mipLevels == uint.MaxValue)
                {
                    mipLevels = description.MipLevels - mostDetailedMip;
                }

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

                    if (viewDimension == D3D11SrvDimension.TextureCubeArray)
                    {
                        arraySize /= 6;
                    }
                }
            }

            this.format = format;

            switch (viewDimension)
            {
            case D3D11SrvDimension.Texture2D:
                this.texture2D = new D3D11Texture2DSrv
                {
                    MostDetailedMip = mostDetailedMip,
                    MipLevels       = mipLevels
                };
                break;

            case D3D11SrvDimension.Texture2DArray:
                this.texture2DArray = new D3D11Texture2DArraySrv
                {
                    MostDetailedMip = mostDetailedMip,
                    MipLevels       = mipLevels,
                    FirstArraySlice = firstArraySlice,
                    ArraySize       = arraySize
                };
                break;

            case D3D11SrvDimension.Texture2DMs:
                this.texture2DMs = new D3D11Texture2DMsSrv
                {
                };
                break;

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

            case D3D11SrvDimension.TextureCube:
                this.textureCube = new D3D11TextureCubeSrv
                {
                    MostDetailedMip = mostDetailedMip,
                    MipLevels       = mipLevels
                };
                break;

            case D3D11SrvDimension.TextureCubeArray:
                this.textureCubeArray = new D3D11TextureCubeArraySrv
                {
                    MostDetailedMip  = mostDetailedMip,
                    MipLevels        = mipLevels,
                    First2DArrayFace = firstArraySlice,
                    NumCubes         = arraySize
                };
                break;

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