PixelFormat

sg_pixel_format

sokol_gfx.h basically uses the same pixel formats as WebGPU, since these are supported on most newer GPUs.

A pixelformat name consist of three parts:

- components (R, RG, RGB or RGBA) - bit width per component (8, 16 or 32) - component data type: - unsigned normalized (no postfix) - signed normalized (SN postfix) - unsigned integer (UI postfix) - signed integer (SI postfix) - float (F postfix)

Not all pixel formats can be used for everything, call sg_query_pixelformat() to inspect the capabilities of a given pixelformat. The function returns an sg_pixelformat_info struct with the following members:

- sample: the pixelformat can be sampled as texture at least with nearest filtering - filter: the pixelformat can be sampled as texture with linear filtering - render: the pixelformat can be used as render-pass attachment - blend: blending is supported when used as render-pass attachment - msaa: multisample-antialiasing is supported when used as render-pass attachment - depth: the pixelformat can be used for depth-stencil attachments - compressed: this is a block-compressed format - bytes_per_pixel: the numbers of bytes in a pixel (0 for compressed formats)

The default pixel format for texture images is SG_PIXELFORMAT_RGBA8.

The default pixel format for render target images is platform-dependent and taken from the sg_environment struct passed into sg_setup(). Typically the default formats are:

- for the Metal, D3D11 and WebGPU backends: SG_PIXELFORMAT_BGRA8 - for GL backends: SG_PIXELFORMAT_RGBA

Values

ValueMeaning
Default
None
R8
R8sn
R8ui
R8si
R16
R16sn
R16ui
R16si
R16f
Rg8
Rg8sn
Rg8ui
Rg8si
R32ui
R32si
R32f
Rg16
Rg16sn
Rg16ui
Rg16si
Rg16f
Rgba8
Srgb8a8
Rgba8sn
Rgba8ui
Rgba8si
Bgra8
Rgb10a2
Rg11b10f
Rgb9e5
Rg32ui
Rg32si
Rg32f
Rgba16
Rgba16sn
Rgba16ui
Rgba16si
Rgba16f
Rgba32ui
Rgba32si
Rgba32f
Depth
Depth_stencil
Bc1_rgba
Bc2_rgba
Bc3_rgba
Bc3_srgba
Bc4_r
Bc4_rsn
Bc5_rg
Bc5_rgsn
Bc6h_rgbf
Bc6h_rgbuf
Bc7_rgba
Bc7_srgba
Pvrtc_rgb_2bpp
Pvrtc_rgb_4bpp
Pvrtc_rgba_2bpp
Pvrtc_rgba_4bpp
Etc2_rgb8
Etc2_srgb8
Etc2_rgb8a1
Etc2_rgba8
Etc2_srgb8a8
Eac_r11
Eac_r11sn
Eac_rg11
Eac_rg11sn
Astc_4x4_rgba
Astc_4x4_srgba
Num

Meta