From 5b3c2b269fb34616efc26e4860a6493e91b0f9e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois?= Date: Wed, 29 Dec 2021 21:04:28 +0000 Subject: [PATCH] Enable Msaa for webgl by default (#3489) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective - `Msaa` was disabled in webgl due to a bug in wgpu - Bug has been fixed (https://github.com/gfx-rs/wgpu/pull/2307) and backported (https://github.com/gfx-rs/wgpu/pull/2327), and updates for [`wgpu-core`](https://crates.io/crates/wgpu-core/0.12.1) and [`wgpu-hal`](https://crates.io/crates/wgpu-hal/0.12.1) have been released ## Solution - Remove custom config for `Msaa` in webgl - I also changed two options that were using the arch instead of the `webgl` feature. it shouldn't change much for webgl, but could help if someone wants to target wasm but not webgl2 Co-authored-by: François <8672791+mockersf@users.noreply.github.com> --- crates/bevy_render/src/options.rs | 4 ++-- crates/bevy_render/src/view/mod.rs | 7 +------ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/crates/bevy_render/src/options.rs b/crates/bevy_render/src/options.rs index 379abbe708c626..e517140c65fc04 100644 --- a/crates/bevy_render/src/options.rs +++ b/crates/bevy_render/src/options.rs @@ -13,7 +13,7 @@ pub struct WgpuOptions { impl Default for WgpuOptions { fn default() -> Self { - let default_backends = if cfg!(target_arch = "wasm32") { + let default_backends = if cfg!(feature = "webgl") { Backends::GL } else { Backends::PRIMARY @@ -21,7 +21,7 @@ impl Default for WgpuOptions { let backends = wgpu::util::backend_bits_from_env().unwrap_or(default_backends); - let limits = if cfg!(target_arch = "wasm32") { + let limits = if cfg!(feature = "webgl") { wgpu::Limits::downlevel_webgl2_defaults() } else { #[allow(unused_mut)] diff --git a/crates/bevy_render/src/view/mod.rs b/crates/bevy_render/src/view/mod.rs index 89dbfa53aa785c..9914c6fa16bc6c 100644 --- a/crates/bevy_render/src/view/mod.rs +++ b/crates/bevy_render/src/view/mod.rs @@ -49,12 +49,7 @@ pub struct Msaa { impl Default for Msaa { fn default() -> Self { - Self { - #[cfg(feature = "webgl")] - samples: 1, - #[cfg(not(feature = "webgl"))] - samples: 4, - } + Self { samples: 4 } } }