Skip to content

Commit

Permalink
Add default for texture format (bevyengine#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
enfipy authored and joshuajbouw committed Oct 24, 2020
1 parent e5750da commit 3aa83fc
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion crates/bevy_pbr/src/render_graph/forward_pipeline/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn build_forward_pipeline(shaders: &mut Assets<Shader>) -> PipelineDe
},
}),
color_states: vec![ColorStateDescriptor {
format: TextureFormat::Bgra8UnormSrgb,
format: TextureFormat::default(),
color_blend: BlendDescriptor {
src_factor: BlendFactor::SrcAlpha,
dst_factor: BlendFactor::OneMinusSrcAlpha,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/pipeline/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_render/src/render_graph/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
),
Expand Down
11 changes: 11 additions & 0 deletions crates/bevy_render/src/texture/texture_dimension.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions crates/bevy_sprite/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ pub fn build_sprite_sheet_pipeline(shaders: &mut Assets<Shader>) -> PipelineDesc
},
}),
color_states: vec![ColorStateDescriptor {
format: TextureFormat::Bgra8UnormSrgb,
format: TextureFormat::default(),
color_blend: BlendDescriptor {
src_factor: BlendFactor::SrcAlpha,
dst_factor: BlendFactor::OneMinusSrcAlpha,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn build_sprite_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor
},
}),
color_states: vec![ColorStateDescriptor {
format: TextureFormat::Bgra8UnormSrgb,
format: TextureFormat::default(),
color_blend: BlendDescriptor {
src_factor: BlendFactor::SrcAlpha,
dst_factor: BlendFactor::OneMinusSrcAlpha,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ui/src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub fn build_ui_pipeline(shaders: &mut Assets<Shader>) -> PipelineDescriptor {
},
}),
color_states: vec![ColorStateDescriptor {
format: TextureFormat::Bgra8UnormSrgb,
format: TextureFormat::default(),
color_blend: BlendDescriptor {
src_factor: BlendFactor::SrcAlpha,
dst_factor: BlendFactor::OneMinusSrcAlpha,
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_wgpu/src/wgpu_type_converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion examples/window/multiple_windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
),
Expand Down

0 comments on commit 3aa83fc

Please sign in to comment.