MSDN

MSDN Documentation

D3D11_TEXTURE2D_DESC

Synopsis

typedef struct D3D11_TEXTURE2D_DESC {
    UINT               Width;
    UINT               Height;
    UINT               MipLevels;
    UINT               ArraySize;
    DXGI_FORMAT        Format;
    DXGI_SAMPLE_DESC  SampleDesc;
    D3D11_USAGE        Usage;
    UINT               BindFlags;
    UINT               CPUAccessFlags;
    UINT               MiscFlags;
} D3D11_TEXTURE2D_DESC;

Members

MemberTypeDescription
WidthUINTTexture width in texels. Must be greater than zero.
HeightUINTTexture height in texels. Must be greater than zero.
MipLevelsUINTNumber of mipmap levels. Use 0 to generate all levels.
ArraySizeUINTNumber of textures in the array. Use 1 for non‑array textures.
FormatDXGI_FORMATFormat of the texture data (e.g., DXGI_FORMAT_R8G8B8A8_UNORM).
SampleDescDXGI_SAMPLE_DESCMultisampling parameters (Count and Quality).
UsageD3D11_USAGEIntended usage (DEFAULT, IMMUTABLE, DYNAMIC, STAGING).
BindFlagsUINTCombination of D3D11_BIND_ flags indicating bind points.
CPUAccessFlagsUINTCPU access options (D3D11_CPU_ACCESS_READ, D3D11_CPU_ACCESS_WRITE).
MiscFlagsUINTMiscellaneous flags (D3D11_RESOURCE_MISC_GENERATE_MIPS, etc.).

Remarks

The D3D11_TEXTURE2D_DESC structure describes a 2‑dimensional texture. It is used when creating a texture with ID3D11Device::CreateTexture2D. Fields must be set according to the intended usage and hardware capabilities. For multisampled textures, SampleDesc.Count must be greater than 1 and MipLevels must be 1.

Example

// Create a 256x256 texture with 4 mip levels, RGBA8 format
D3D11_TEXTURE2D_DESC texDesc = {};
texDesc.Width = 256;
texDesc.Height = 256;
texDesc.MipLevels = 4;
texDesc.ArraySize = 1;
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
texDesc.SampleDesc.Count = 1;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
texDesc.CPUAccessFlags = 0;
texDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;

ID3D11Texture2D* pTexture = nullptr;
HRESULT hr = device->CreateTexture2D(&texDesc, nullptr, &pTexture);
if (SUCCEEDED(hr)) {
    // Use the texture
}

See Also