The D3D11_TEXTURE3D_DESC
structure describes a three‑dimensional texture resource. It is used with ID3D11Device::CreateTexture3D
and related functions.
Syntax
typedef struct D3D11_TEXTURE3D_DESC {
UINT Width;
UINT Height;
UINT Depth;
UINT MipLevels;
DXGI_FORMAT Format;
D3D11_USAGE Usage;
UINT BindFlags;
UINT CPUAccessFlags;
UINT MiscFlags;
} D3D11_TEXTURE3D_DESC;
Members
Member | Type | Description |
---|---|---|
Width |
UINT | Width of the texture in texels. Must be ≤ D3D11_REQ_TEXTURE3D_U_OR_V_DIMENSION . |
Height |
UINT | Height of the texture in texels. Same size limit as Width . |
Depth |
UINT | Depth of the texture in texels. Must be ≤ D3D11_REQ_TEXTURE3D_W_DIMENSION . |
MipLevels |
UINT | Number of mipmap levels. 0 creates a full mipmap chain. |
Format |
DXGI_FORMAT | Pixel format. Must be a valid 3‑D texture format. |
Usage |
D3D11_USAGE | How the texture will be used (default, immutable, dynamic, staging). |
BindFlags |
UINT | Combination of D3D11_BIND_FLAG values (e.g., D3D11_BIND_SHADER_RESOURCE ). |
CPUAccessFlags |
UINT | Flags that describe CPU access (e.g., D3D11_CPU_ACCESS_WRITE ). |
MiscFlags |
UINT | Miscellaneous flags (e.g., D3D11_RESOURCE_MISC_GENERATE_MIPS ). |
Example Usage
#include <d3d11.h>
#include <dxgi.h>
D3D11_TEXTURE3D_DESC texDesc = {};
texDesc.Width = 128;
texDesc.Height = 128;
texDesc.Depth = 64;
texDesc.MipLevels = 0; // full mip chain
texDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
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;
ID3D11Texture3D* pTex3D = nullptr;
HRESULT hr = device->CreateTexture3D(&texDesc, nullptr, &pTex3D);
if (SUCCEEDED(hr)) {
// Texture ready for use
}