Enum rokol::gfx::PixelFormat[][src]

#[repr(u32)]
pub enum PixelFormat {
Show 64 variants _Default, Bc1Rgba, Bc2Rgba, Bc3Rgba, Bc4R, Bc4Rsc, Bc5Rg, Bc5Rgsn, Bc6hRgf, Bc6hRgbuf, Bc7Rgba, Bgra8, Depth, DepthStencil, Etc2Rg11, Etc2Rg11Sn, Etc2Rgb8, Etc2Rgb8A1, Etc2Rgba8, None, PvrtcRgba2Bpp, PvrtcRgba24pp, PvrtcRgb2Bpp, PvrtcRgb4Bpp, R8, R8Si, R8Sn, R8Ui, R16, R16F, R16Si, R16Sn, R16Ui, R32F, R32Si, R32Ui, Rg8, Rg8Si, Rg8Sn, Rg8Ui, Rg11B10F, Rg16, Rg16F, Rg16Si, Rg16Sn, Rg16Ui, Rg32F, Rg32Si, Rg32Ui, Rgb10A2, Rgba8, Rgba8Si, Rgba8Sn, Rgba8Ui, Rgba16, Rgba16F, Rgba16Si, Rgba16Sn, Rgba16Ui, Rgba32F, Rgba32Si, Rgba32Ui, _ForceU32, _Num,
}
Expand description

Pixel format

Features

sokol_gfx.h basically uses the same pixel formats as WebGPU, since these are supported on most newer GPUs. GLES2 and WebGL has a much smaller subset of available pixel formats. Call sg_query_pixelformat() to check at runtime if a pixel format supports the desired features.

Naming convension

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)

Supported formats

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 bool members:

  • sample: the pixelformat can be sampled as texture at least with nearest filtering
  • filter: the pixelformat can be samples as texture with linear filtering
  • render: the pixelformat can be used for render targets
  • blend: blending is supported when using the pixelformat for render targets
  • msaa: multisample-antialiasing is supported when using the pixelformat for render targets
  • depth: the pixelformat can be used for depth-stencil attachments

When targeting GLES2/WebGL, the only safe formats to use as texture are SG_PIXELFORMAT_R8 and SG_PIXELFORMAT_RGBA8. For rendering in GLES2/WebGL, only SG_PIXELFORMAT_RGBA8 is safe. All other formats must be checked via sg_query_pixelformats().

Default pixel format

The default pixel format for texture images is SG_PIXELFORMAT_RGBA8.

The default pixel format for render target images is platform-dependent:

  • for Metal and D3D11 it is SG_PIXELFORMAT_BGRA8
  • for GL backends it is SG_PIXELFORMAT_RGBA8

This is mainly because of the default framebuffer which is setup outside of sokol_gfx.h. On some backends, using BGRA for the default frame buffer allows more efficient frame flips. For your own offscreen-render-targets, use whatever renderable pixel format is convenient for you.

Variants

_Default

Bc1Rgba

Bc2Rgba

Bc3Rgba

Bc4R

Bc4Rsc

Bc5Rg

Bc5Rgsn

Bc6hRgf

Bc6hRgbuf

Bc7Rgba

Bgra8

Depth

DepthStencil

Etc2Rg11

Etc2Rg11Sn

Etc2Rgb8

Etc2Rgb8A1

Etc2Rgba8

None

PvrtcRgba2Bpp

PvrtcRgba24pp

PvrtcRgb2Bpp

PvrtcRgb4Bpp

R8

R8Si

R8Sn

R8Ui

R16

R16F

R16Si

R16Sn

R16Ui

R32F

R32Si

R32Ui

Rg8

Rg8Si

Rg8Sn

Rg8Ui

Rg11B10F

Rg16

Rg16F

Rg16Si

Rg16Sn

Rg16Ui

Rg32F

Rg32Si

Rg32Ui

Rgb10A2

Rgba8

Rgba8Si

Rgba8Sn

Rgba8Ui

Rgba16

Rgba16F

Rgba16Si

Rgba16Sn

Rgba16Ui

Rgba32F

Rgba32Si

Rgba32Ui

_ForceU32

_Num

Implementations

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.