From 4d9b00fbd992166b3efd4df5e2d84f070128d96f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20=C3=96dmark?= Date: Fri, 28 Apr 2023 18:42:55 +0200 Subject: [PATCH 1/2] Fixes bug where shader crashes on Adreno GPUs using WebGL --- crates/bevy_pbr/src/render/light.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 1e73198a8744d..26b9a9375bf66 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -216,7 +216,14 @@ pub struct GpuLights { // NOTE: this must be kept in sync with the same constants in pbr.frag pub const MAX_UNIFORM_BUFFER_POINT_LIGHTS: usize = 256; + +//NOTE: When running bevy on Adreno GPU chipsets in WebGL, any value above 1 will result in a crash +// when loading the wgsl "pbr_functions.wgsl" in the function apply_fog. +#[cfg(feature = "webgl")] +pub const MAX_DIRECTIONAL_LIGHTS: usize = 1; +#[cfg(not(feature = "webgl"))] pub const MAX_DIRECTIONAL_LIGHTS: usize = 10; + #[cfg(not(feature = "webgl"))] pub const MAX_CASCADES_PER_LIGHT: usize = 4; #[cfg(feature = "webgl")] From 3943a51e6a29ee17a553e4695bbe72274f90dc13 Mon Sep 17 00:00:00 2001 From: Carter Anderson Date: Wed, 28 Jun 2023 21:10:15 -0700 Subject: [PATCH 2/2] Update crates/bevy_pbr/src/render/light.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: François --- crates/bevy_pbr/src/render/light.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_pbr/src/render/light.rs b/crates/bevy_pbr/src/render/light.rs index 8b355ca816afd..00beb05b5e91f 100644 --- a/crates/bevy_pbr/src/render/light.rs +++ b/crates/bevy_pbr/src/render/light.rs @@ -219,9 +219,9 @@ pub const MAX_UNIFORM_BUFFER_POINT_LIGHTS: usize = 256; //NOTE: When running bevy on Adreno GPU chipsets in WebGL, any value above 1 will result in a crash // when loading the wgsl "pbr_functions.wgsl" in the function apply_fog. -#[cfg(feature = "webgl")] +#[cfg(all(feature = "webgl", target_arch = "wasm32"))] pub const MAX_DIRECTIONAL_LIGHTS: usize = 1; -#[cfg(not(feature = "webgl"))] +#[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))] pub const MAX_DIRECTIONAL_LIGHTS: usize = 10; #[cfg(any(not(feature = "webgl"), not(target_arch = "wasm32")))] pub const MAX_CASCADES_PER_LIGHT: usize = 4;