diff --git a/crates/bevy_pbr/src/render_graph/forward_pipeline/mod.rs b/crates/bevy_pbr/src/render_graph/forward_pipeline/mod.rs index 7fb19ae1cf3e3..2de22b657f559 100644 --- a/crates/bevy_pbr/src/render_graph/forward_pipeline/mod.rs +++ b/crates/bevy_pbr/src/render_graph/forward_pipeline/mod.rs @@ -34,7 +34,7 @@ pub(crate) fn build_forward_pipeline(shaders: &mut Assets) -> PipelineDe }, }), color_states: vec![ColorStateDescriptor { - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), color_blend: BlendDescriptor { src_factor: BlendFactor::SrcAlpha, dst_factor: BlendFactor::OneMinusSrcAlpha, diff --git a/crates/bevy_render/src/pipeline/pipeline.rs b/crates/bevy_render/src/pipeline/pipeline.rs index 9f59ca82280dc..a163cc74f82fe 100644 --- a/crates/bevy_render/src/pipeline/pipeline.rs +++ b/crates/bevy_render/src/pipeline/pipeline.rs @@ -91,7 +91,7 @@ impl PipelineDescriptor { }, }), color_states: vec![ColorStateDescriptor { - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), color_blend: BlendDescriptor { src_factor: BlendFactor::SrcAlpha, dst_factor: BlendFactor::OneMinusSrcAlpha, diff --git a/crates/bevy_render/src/render_graph/base.rs b/crates/bevy_render/src/render_graph/base.rs index bc3d68a8d9e39..5bc46a85152cf 100644 --- a/crates/bevy_render/src/render_graph/base.rs +++ b/crates/bevy_render/src/render_graph/base.rs @@ -209,7 +209,7 @@ impl BaseRenderGraphBuilder for RenderGraph { mip_level_count: 1, sample_count: msaa.samples, dimension: TextureDimension::D2, - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), usage: TextureUsage::OUTPUT_ATTACHMENT, }, ), diff --git a/crates/bevy_render/src/texture/texture_dimension.rs b/crates/bevy_render/src/texture/texture_dimension.rs index fc6fb138761ee..77e8b42262b42 100644 --- a/crates/bevy_render/src/texture/texture_dimension.rs +++ b/crates/bevy_render/src/texture/texture_dimension.rs @@ -206,6 +206,17 @@ impl TextureFormat { } } +impl Default for TextureFormat { + fn default() -> Self { + if cfg!(target_os = "android") { + // Bgra8UnormSrgb texture missing on some Android devices + TextureFormat::Rgba8UnormSrgb + } else { + TextureFormat::Bgra8UnormSrgb + } + } +} + bitflags::bitflags! { #[repr(transparent)] pub struct TextureUsage: u32 { diff --git a/crates/bevy_sprite/src/render/mod.rs b/crates/bevy_sprite/src/render/mod.rs index 6dd965345c367..8c17a794a1d11 100644 --- a/crates/bevy_sprite/src/render/mod.rs +++ b/crates/bevy_sprite/src/render/mod.rs @@ -40,7 +40,7 @@ pub fn build_sprite_sheet_pipeline(shaders: &mut Assets) -> PipelineDesc }, }), color_states: vec![ColorStateDescriptor { - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), color_blend: BlendDescriptor { src_factor: BlendFactor::SrcAlpha, dst_factor: BlendFactor::OneMinusSrcAlpha, @@ -88,7 +88,7 @@ pub fn build_sprite_pipeline(shaders: &mut Assets) -> PipelineDescriptor }, }), color_states: vec![ColorStateDescriptor { - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), color_blend: BlendDescriptor { src_factor: BlendFactor::SrcAlpha, dst_factor: BlendFactor::OneMinusSrcAlpha, diff --git a/crates/bevy_ui/src/render/mod.rs b/crates/bevy_ui/src/render/mod.rs index ab03dbc0bc972..6263f2246d91e 100644 --- a/crates/bevy_ui/src/render/mod.rs +++ b/crates/bevy_ui/src/render/mod.rs @@ -42,7 +42,7 @@ pub fn build_ui_pipeline(shaders: &mut Assets) -> PipelineDescriptor { }, }), color_states: vec![ColorStateDescriptor { - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), color_blend: BlendDescriptor { src_factor: BlendFactor::SrcAlpha, dst_factor: BlendFactor::OneMinusSrcAlpha, diff --git a/crates/bevy_wgpu/src/wgpu_type_converter.rs b/crates/bevy_wgpu/src/wgpu_type_converter.rs index 077e50dc7fd1b..3769024c0be0a 100644 --- a/crates/bevy_wgpu/src/wgpu_type_converter.rs +++ b/crates/bevy_wgpu/src/wgpu_type_converter.rs @@ -562,7 +562,7 @@ impl WgpuFrom<&Window> for wgpu::SwapChainDescriptor { fn from(window: &Window) -> Self { wgpu::SwapChainDescriptor { usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT, - format: wgpu::TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default().wgpu_into(), width: window.width(), height: window.height(), present_mode: if window.vsync() { diff --git a/examples/window/multiple_windows.rs b/examples/window/multiple_windows.rs index 4d249f427e456..2916249283798 100644 --- a/examples/window/multiple_windows.rs +++ b/examples/window/multiple_windows.rs @@ -134,7 +134,7 @@ fn setup( mip_level_count: 1, sample_count: msaa.samples, dimension: TextureDimension::D2, - format: TextureFormat::Bgra8UnormSrgb, + format: TextureFormat::default(), usage: TextureUsage::OUTPUT_ATTACHMENT, }, ),