Esempio n. 1
0
    /// <summary>
    /// Initializes a new instance of the <see cref="ShaderResourceViewDescription1"/> struct.
    /// </summary>
    /// <param name="texture"></param>
    /// <param name="format"></param>
    /// <param name="mostDetailedMip"></param>
    /// <param name="mipLevels"></param>
    public ShaderResourceViewDescription1(
        ID3D11Texture3D texture,
        Format format       = Format.Unknown,
        int mostDetailedMip = 0,
        int mipLevels       = -1)
        : this()
    {
        ViewDimension = ShaderResourceViewDimension.Texture3D;
        if (format == Format.Unknown || mipLevels == -1)
        {
            var textureDesc = texture.Description;
            if (format == Format.Unknown)
            {
                format = textureDesc.Format;
            }
            if (mipLevels == -1)
            {
                mipLevels = textureDesc.MipLevels - mostDetailedMip;
            }
        }

        Format = format;
        Texture3D.MostDetailedMip = mostDetailedMip;
        Texture3D.MipLevels       = mipLevels;
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="RenderTargetViewDescription"/> struct.
    /// </summary>
    /// <param name="texture"></param>
    /// <param name="format"></param>
    /// <param name="mipSlice"></param>
    /// <param name="firstWSlice"></param>
    /// <param name="wSize"></param>
    public RenderTargetViewDescription(
        ID3D11Texture3D texture,
        Format format   = Format.Unknown,
        int mipSlice    = 0,
        int firstWSlice = 0,
        int wSize       = -1)
        : this()
    {
        ViewDimension = RenderTargetViewDimension.Texture3D;
        if (format == Format.Unknown || wSize == -1)
        {
            var textureDesc = texture.Description;
            if (format == Format.Unknown)
            {
                format = textureDesc.Format;
            }
            if (wSize == -1)
            {
                wSize = textureDesc.Depth - firstWSlice;
            }
        }

        Format                = format;
        Texture3D.MipSlice    = mipSlice;
        Texture3D.FirstWSlice = firstWSlice;
        Texture3D.WSize       = wSize;
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="UnorderedAccessViewDescription"/> struct.
    /// </summary>
    /// <param name="texture"></param>
    /// <param name="viewDimension"></param>
    /// <param name="format"></param>
    /// <param name="mipSlice"></param>
    /// <param name="firstWSlice"></param>
    /// <param name="wSize"></param>
    public UnorderedAccessViewDescription(
        ID3D11Texture3D texture,
        UnorderedAccessViewDimension viewDimension,
        Format format   = Format.Unknown,
        int mipSlice    = 0,
        int firstWSlice = 0,
        int wSize       = -1) : this()
    {
        ViewDimension = viewDimension;

        if (format == Format.Unknown || wSize == -1)
        {
            Texture3DDescription textureDesc = texture.Description;
            if (format == Format.Unknown)
            {
                format = textureDesc.Format;
            }
            if (wSize == -1)
            {
                wSize = textureDesc.Depth - firstWSlice;
            }
        }
        Format                = format;
        Texture3D.MipSlice    = mipSlice;
        Texture3D.FirstWSlice = firstWSlice;
        Texture3D.WSize       = wSize;
    }
    public unsafe Span <T> AsSpan <T>(ID3D11Texture3D resource, int mipSlice, int arraySlice) where T : unmanaged
    {
        resource.CalculateSubResourceIndex(mipSlice, arraySlice, out int mipSize);
        Span <byte> source = new(DataPointer.ToPointer(), mipSize *DepthPitch);

        return(MemoryMarshal.Cast <byte, T>(source));
    }
 internal D3D11Texture3D(ID3D11Texture3D texture3D)
 {
     this.texture3D = texture3D;
 }
 internal D3D11Texture3D(ID3D11Texture3D texture3D)
 {
     this.texture3D = texture3D;
 }