Overview
The DXGI_FORMAT
enumeration defines the pixel formats that can be used with DXGI surfaces, textures, and render targets. Each format specifies the number of bits for each channel and the data type of the channel (e.g., UNorm, SNorm, Float).
Enum Values
Value | Name | Channel Composition | Typename | Description |
---|---|---|---|---|
0 | DXGI_FORMAT_UNKNOWN | — | — | Undefined format. |
1 | DXGI_FORMAT_R32G32B32A32_TYPELESS | 4×32‑bit | Typeless | Four 32‑bit components, typeless. |
2 | DXGI_FORMAT_R32G32B32A32_FLOAT | 4×32‑bit | Float | Four 32‑bit floating‑point components. |
3 | DXGI_FORMAT_R32G32B32A32_UINT | 4×32‑bit | UInt32 | Four 32‑bit unsigned integer components. |
4 | DXGI_FORMAT_R32G32B32A32_SINT | 4×32‑bit | SInt32 | Four 32‑bit signed integer components. |
5 | DXGI_FORMAT_R32G32B32_TYPELESS | 3×32‑bit | Typeless | Three 32‑bit components, typeless. |
130 | DXGI_FORMAT_R8G8B8A8_UNORM_SRGB | 4×8‑bit | UNorm (sRGB) | Eight‑bit unsigned normalized sRGB format. |
131 | DXGI_FORMAT_B8G8R8A8_UNORM | 4×8‑bit | UNorm | Blue‑green‑red‑alpha 8‑bit unsigned normalized. |
132 | DXGI_FORMAT_B8G8R8X8_UNORM | 4×8‑bit | UNorm | Blue‑green‑red‑X (unused) 8‑bit unsigned normalized. |
Sample Usage
#include <dxgi.h>
#include <d3d11.h>
DXGI_FORMAT format = DXGI_FORMAT_R8G8B8A8_UNORM;
D3D11_TEXTURE2D_DESC texDesc = {};
texDesc.Width = 1920;
texDesc.Height = 1080;
texDesc.MipLevels = 1;
texDesc.ArraySize = 1;
texDesc.Format = format;
texDesc.SampleDesc.Count = 1;
texDesc.Usage = D3D11_USAGE_DEFAULT;
texDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET;
ID3D11Texture2D* pTexture = nullptr;
HRESULT hr = device->CreateTexture2D(&texDesc, nullptr, &pTexture);
if (SUCCEEDED(hr)) {
// Texture created successfully
}