bevyengine/bevy · critical

Texture format is not supported by the pipeline

Error message

Texture format is not supported by the pipeline

What it means

Mesh2dPipelineKey::from_target_format (mesh2d/mesh.rs:669-676) encodes the view's color target format into a 5-bit field using bevy_render::view::texture_format_to_code, and expects Some. That table (bevy_render/src/view/mod.rs:106-133) covers only WebGPU renderable AND blendable formats (~23). A 2D camera whose render target uses any other format — integer formats, Rgb9e5Ufloat, compressed, etc. — panics here.

Source

Thrown at crates/bevy_sprite_render/src/mesh2d/mesh.rs:674

        - Self::MSAA_MASK_BITS.count_ones() as u64;
    const TONEMAP_METHOD_MASK_BITS: u64 = 0b1111;
    const TONEMAP_METHOD_SHIFT_BITS: u64 =
        Self::MSAA_SHIFT_BITS - Self::TONEMAP_METHOD_MASK_BITS.count_ones() as u64;
    pub const INDEX_FORMAT_MASK_BITS: u64 = 0b11;
    pub const INDEX_FORMAT_SHIFT_BITS: u64 =
        Self::TONEMAP_METHOD_SHIFT_BITS - Self::TONEMAP_METHOD_MASK_BITS.count_ones() as u64;

    pub fn from_msaa_samples(msaa_samples: u32) -> Self {
        let msaa_bits = ((msaa_samples.trailing_zeros() as u64) & Self::MSAA_MASK_BITS)
            << Self::MSAA_SHIFT_BITS;
        Self::from_bits_retain(msaa_bits)
    }

    /// Create a pipeline key from the view's color target format.
    #[inline]
    pub fn from_target_format(format: TextureFormat) -> Self {
        let code = texture_format_to_code(format)
            .expect("Texture format is not supported by the pipeline") as u64;
        Self::from_bits_retain(
            (code & Self::COLOR_TARGET_FORMAT_MASK_BITS) << Self::COLOR_TARGET_FORMAT_SHIFT_BITS,
        )
    }

    /// Color target format of the main pass for this pipeline key.
    #[inline]
    pub fn target_format(&self) -> TextureFormat {
        let code = ((self.bits() >> Self::COLOR_TARGET_FORMAT_SHIFT_BITS)
            & Self::COLOR_TARGET_FORMAT_MASK_BITS) as u8;
        texture_format_from_code(code)
            .expect("Unknown bits in `COLOR_TARGET_FORMAT_MASK_BITS` of the pipeline key")
    }

    pub fn msaa_samples(&self) -> u32 {
        1 << ((self.bits() >> Self::MSAA_SHIFT_BITS) & Self::MSAA_MASK_BITS)
    }

View on GitHub (pinned to 227d3a6c66)

Solutions

  1. Use a format from the supported blendable set for the camera target: Rgba8UnormSrgb, Bgra8UnormSrgb, Rgba16Float, Rgba32Float, Rg11b10Ufloat, etc.
  2. Render the 2D content to a standard target and convert to the special format in a separate pass
  3. Guard with bevy_render::view::texture_format_to_code(format).is_some() before assigning the target

Example fix

// before — uint target is not blendable, mesh2d pipeline key panics
let image = Image::new_fill(
    size,
    bevy_render::render_resource::Extent3d::default(),
    &[0, 0, 0, 255],
    bevy_render::render_resource::TextureFormat::Rgba8Uint,
    RenderAssetUsages::RENDER_WORLD,
);
camera.target = image.clone().into();

// after — use a supported blendable format
let image = Image::new_fill(
    size,
    bevy_render::render_resource::Extent3d::default(),
    &[0, 0, 0, 255],
    bevy_render::render_resource::TextureFormat::Rgba8UnormSrgb,
    RenderAssetUsages::RENDER_WORLD,
);
Defensive patterns

Strategy: validation

Validate before calling

use bevy_render::view::texture_format_to_code;

// run before pointing a 2D camera at a custom target
fn ensure_mesh2d_supported_target(format: TextureFormat) -> bool {
    texture_format_to_code(format).is_some()
}

Type guard

fn is_mesh2d_target_format(format: TextureFormat) -> bool {
    bevy_render::view::texture_format_to_code(format).is_some()
}

Prevention

When it happens

Trigger: A Camera with RenderTarget::Texture rendering mesh2d content into an Image whose TextureFormat is outside the table, e.g. Rgba8Uint for an ID pass, Rgba16Uint, Rgb9e5Ufloat, or a compressed format.

Common situations: Reusing picking/segmentation/ID-pass textures (uint formats) as 2D camera targets; copying exotic formats from compute examples into camera output targets; custom post-processing chains with unusual intermediate formats.

Related errors


AI-assisted analysis of bevyengine/bevy@227d3a6c66 (2026-08-20). Data as JSON: /api/errors/bffaf9c34f1071c6. Report an issue: GitHub.