Skip to main content

select_surface_format

Function select_surface_format 

Source
pub fn select_surface_format(
    capabilities: &SurfaceCapabilities,
) -> Result<TextureFormat>
Expand description

Picks the swapchain format to configure with: the first format the surface reports that is one of SURFACE_FORMATS.

The preference order is the surface’s, not this module’s — the platform lists its formats best-first, and taking its first supported entry is the selection every shipped frust build has configured its swapchain with (device-gated on Android/Vulkan, iOS/macOS/Metal and Windows). The engine warms its strip pipelines for whichever of the two it is handed, so neither is privileged here; reordering this to prefer Rgba8Unorm would silently change the swapchain format on the platforms that report Bgra8Unorm first.

Errors when the surface supports neither, which no shipping platform does — the engine draws through a render pass into whichever of the two is available and has no third format to fall back on.