CD3D11_RESOURCE_DESC class

[This documentation is preliminary and is subject to change.]

Represents a D3D11 resource and provides convenience methods for using these resources in D3D12.

When to implement

Implement this class to reuse DirectX 11 resources in a DirectX 12 app. The initialization methods reference the following methods and enums:

Members

The CD3D11_RESOURCE_DESC class inherits from D3D11_RESOURCE_DESC. CD3D11_RESOURCE_DESC also has these types of members:

Methods

The CD3D11_RESOURCE_DESC class has these methods.

MethodDescription
~CD3D11_RESOURCE_DESC()

Destroys an instance of a CD3D11_RESOURCE_DESC structure.

CD3D11_RESOURCE_DESC()

Instantiates a new instance of an uninitialized CD3D11_RESOURCE_DESC structure.

CD3D11_RESOURCE_DESC(const CD3D11_BUFFER_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a CD3D11_BUFFER_DESC structure.

CD3D11_RESOURCE_DESC(const CD3D11_TEXTURE1D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a CD3D11_TEXTURE1D_DESC structure.

CD3D11_RESOURCE_DESC(const CD3D11_TEXTURE2D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a CD3D11_TEXTURE2D_DESC structure.

CD3D11_RESOURCE_DESC(const CD3D11_TEXTURE3D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a CD3D11_TEXTURE3D_DESC structure.

CD3D11_RESOURCE_DESC(const D3D11_BUFFER_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D11_BUFFER_DESC structure.

CD3D11_RESOURCE_DESC(const D3D11_RESOURCE_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D11_RESOURCE_DESC structure.

CD3D11_RESOURCE_DESC(const D3D11_TEXTURE1D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D11_TEXTURE1D_DESC structure.

CD3D11_RESOURCE_DESC(const D3D11_TEXTURE2D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D11_TEXTURE2D_DESC structure.

CD3D11_RESOURCE_DESC(const D3D11_TEXTURE3D_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D11_TEXTURE3D_DESC structure.

CD3D11_RESOURCE_DESC(const D3D12_RESOURCE_DESC)

Instantiates a new instance of a CD3D11_RESOURCE_DESC structure that is initialized with a D3D12_RESOURCE_DESC structure.

ConvertD3D12Info

Converts Direct3D 12 info to Direct3D 11 bind flags (D3D11_BIND_FLAG) and resource flags (D3D11_RESOURCE_MISC_FLAG).

 

Operators

The CD3D11_RESOURCE_DESC class has these operators.

OperatorDescription
operator CD3D12_RESOURCE_DESC()

This operator returns a CD3D12_RESOURCE_DESC structure that contains data from the CD3D11_RESOURCE_DESC instance.

operator const D3D11_RESOURCE_DESC&()

This operator returns the address of a D3D11_RESOURCE_DESC structure that contains data from the CD3D11_RESOURCE_DESC instance.

operator D3D12_RESOURCE_DESC()

This operator returns a D3D12_RESOURCE_DESC structure that contains data from the CD3D11_RESOURCE_DESC instance.

 

Remarks

Here is how D3D12.h defines CD3D11_RESOURCE_DESC:


struct CD3D11_RESOURCE_DESC : public D3D11_RESOURCE_DESC
{
    CD3D11_RESOURCE_DESC()
    {}
    explicit CD3D11_RESOURCE_DESC( const D3D11_RESOURCE_DESC& o ) :
        D3D11_RESOURCE_DESC( o )
    {}
    void ConvertD3D12Info( D3D12_TEXTURE_LAYOUT layout, D3D12_RESOURCE_MISC_FLAG miscFlags ) { ... }
    CD3D11_RESOURCE_DESC( const D3D12_RESOURCE_DESC& o )
    {
        switch (o.Dimension)
        {
        case D3D12_RESOURCE_DIMENSION_BUFFER: Dimension = D3D11_RESOURCE_DIMENSION_BUFFER; break;
        case D3D12_RESOURCE_DIMENSION_TEXTURE_1D: Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D; break;
        case D3D12_RESOURCE_DIMENSION_TEXTURE_2D: Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D; break;
        case D3D12_RESOURCE_DIMENSION_TEXTURE_3D: Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE3D; break;
        default: Dimension = D3D11_RESOURCE_DIMENSION_UNKNOWN; break;
        }
        Width = UINT( o.Width );
        Height = o.Height;
        Depth = (Dimension == D3D11_RESOURCE_DIMENSION_TEXTURE3D ? o.DepthOrArraySize : 1);
        MipLevels = o.MipLevels;
        ArraySize = (Dimension == D3D11_RESOURCE_DIMENSION_TEXTURE3D ? 1 : o.DepthOrArraySize);
        Format = o.Format;
        SampleDesc = o.SampleDesc;
        Usage = D3D11_USAGE_DEFAULT;
        BindFlags = 0;
        CPUAccessFlags = 0;
        MiscFlags = 0;
        StructureByteStride = 0;
        ConvertD3D12Info( o.Layout, o.MiscFlags );
    }
    CD3D11_RESOURCE_DESC( const D3D11_BUFFER_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_BUFFER;
        Width = o.ByteWidth;
        Height = 1;
        Depth = 1;
        MipLevels = 1;
        ArraySize = 1;
        Format = DXGI_FORMAT_UNKNOWN;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = o.StructureByteStride;
    }
    CD3D11_RESOURCE_DESC( const CD3D11_BUFFER_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_BUFFER;
        Width = o.ByteWidth;
        Height = 1;
        Depth = 1;
        MipLevels = 1;
        ArraySize = 1;
        Format = DXGI_FORMAT_UNKNOWN;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = o.StructureByteStride;
    }
    CD3D11_RESOURCE_DESC( const D3D11_TEXTURE1D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D;
        Width = o.Width;
        Height = 1;
        Depth = 1;
        MipLevels = o.MipLevels;
        ArraySize = o.ArraySize;
        Format = o.Format;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    CD3D11_RESOURCE_DESC( const CD3D11_TEXTURE1D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D;
        Width = o.Width;
        Height = 1;
        Depth = 1;
        MipLevels = o.MipLevels;
        ArraySize = o.ArraySize;
        Format = o.Format;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    CD3D11_RESOURCE_DESC( const D3D11_TEXTURE2D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
        Width = o.Width;
        Height = o.Height;
        Depth = 1;
        MipLevels = o.MipLevels;
        ArraySize = o.ArraySize;
        Format = o.Format;
        SampleDesc = o.SampleDesc;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    CD3D11_RESOURCE_DESC( const CD3D11_TEXTURE2D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE2D;
        Width = o.Width;
        Height = o.Height;
        Depth = 1;
        MipLevels = o.MipLevels;
        ArraySize = o.ArraySize;
        Format = o.Format;
        SampleDesc = o.SampleDesc;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    CD3D11_RESOURCE_DESC( const D3D11_TEXTURE3D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE3D;
        Width = o.Width;
        Height = o.Height;
        Depth = o.Depth;
        MipLevels = o.MipLevels;
        ArraySize = 1;
        Format = o.Format;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    CD3D11_RESOURCE_DESC( const CD3D11_TEXTURE3D_DESC& o )
    {
        Dimension = D3D11_RESOURCE_DIMENSION_TEXTURE3D;
        Width = o.Width;
        Height = o.Height;
        Depth = o.Depth;
        MipLevels = o.MipLevels;
        ArraySize = 1;
        Format = o.Format;
        SampleDesc.Count = 1;
        SampleDesc.Quality = 0;
        Usage = o.Usage;
        BindFlags = o.BindFlags;
        CPUAccessFlags = o.CPUAccessFlags;
        MiscFlags = o.MiscFlags;
        StructureByteStride = 0;
    }
    ~CD3D11_RESOURCE_DESC() {}
    operator const D3D11_RESOURCE_DESC&() const { return *this; }
    operator CD3D12_RESOURCE_DESC() const { ... }
    operator D3D12_RESOURCE_DESC() const { return D3D12_RESOURCE_DESC( this->operator CD3D12_RESOURCE_DESC() ); }
};

Note that the header d3d12.h imports the header d3d11_3.h.

Requirements

Header

D3D12.h

See also

D3D11_RESOURCE_DESC

 

 

Show: