From 8915acdd5d25708395fae8bbd0bd4bb8495b0a57 Mon Sep 17 00:00:00 2001 From: Nazari Gonzalez Date: Sun, 26 Jan 2025 22:24:27 +0000 Subject: [PATCH] udpated glow to latest version and deny fallback renderers on webgl --- Cargo.lock | 4 ++-- crates/notan_glow/Cargo.toml | 2 +- crates/notan_glow/src/lib.rs | 4 ++-- crates/notan_glow/src/texture.rs | 2 +- crates/notan_glow/src/utils.rs | 9 +++++---- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9a10267d..c2b27e67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1029,9 +1029,9 @@ checksum = "a8d1add55171497b4705a648c6b583acafb01d58050a51727785f0b2c8e0a2b2" [[package]] name = "glow" -version = "0.12.3" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" +checksum = "c5e5ea60d70410161c8bf5da3fdfeaa1c72ed2c15f8bbb9d19fe3a4fad085f08" dependencies = [ "js-sys", "slotmap", diff --git a/crates/notan_glow/Cargo.toml b/crates/notan_glow/Cargo.toml index f9cdb540..3d678957 100644 --- a/crates/notan_glow/Cargo.toml +++ b/crates/notan_glow/Cargo.toml @@ -19,7 +19,7 @@ bytemuck.workspace = true hashbrown.workspace = true image.workspace = true -glow = "0.12.3" +glow = "0.16.0" [target.'cfg(target_arch = "wasm32")'.dependencies] wasm-bindgen.workspace = true diff --git a/crates/notan_glow/src/lib.rs b/crates/notan_glow/src/lib.rs index 694750c5..45a0a0df 100644 --- a/crates/notan_glow/src/lib.rs +++ b/crates/notan_glow/src/lib.rs @@ -575,7 +575,7 @@ impl DeviceBackend for GlowBackend { opts.height as _, texture_format(&opts.format), texture_type(&opts.format), - PixelUnpackData::Slice(bytes), + PixelUnpackData::Slice(Some(bytes)), ); } TextureUpdaterSourceKind::Raw(source) => source.update(self, opts)?, @@ -629,7 +629,7 @@ impl DeviceBackend for GlowBackend { opts.height as _, texture_format(&opts.format), texture_type(&opts.format), - glow::PixelPackData::Slice(bytes), + glow::PixelPackData::Slice(Some(bytes)), ); clean(); diff --git a/crates/notan_glow/src/texture.rs b/crates/notan_glow/src/texture.rs index 0ec647b2..6d284b44 100644 --- a/crates/notan_glow/src/texture.rs +++ b/crates/notan_glow/src/texture.rs @@ -182,7 +182,7 @@ pub(crate) unsafe fn create_texture( 0, format, texture_type(&info.format), - data, + PixelUnpackData::Slice(data), ); post_create_texture(gl, info); diff --git a/crates/notan_glow/src/utils.rs b/crates/notan_glow/src/utils.rs index 728eccfb..eaf88a59 100644 --- a/crates/notan_glow/src/utils.rs +++ b/crates/notan_glow/src/utils.rs @@ -23,6 +23,7 @@ fn webgl_options(antialias: bool, transparent: bool) -> web_sys::WebGlContextAtt opts.set_alpha(transparent); opts.set_antialias(antialias); opts.set_power_preference(web_sys::WebGlPowerPreference::HighPerformance); + opts.set_fail_if_major_performance_caveat(true); opts } @@ -35,9 +36,9 @@ fn create_webgl_context( let gl = win .get_context_with_context_options("webgl", webgl_options(antialias, transparent).as_ref()) .map_err(|e| format!("{e:?}"))? - .ok_or("Cannot adquire the Webgl context. Is the canvas already instantiated?")? + .ok_or("Cannot acquire the Webgl context. Is the canvas already instantiated?")? .dyn_into::() - .map_err(|_| "Cannot adquire WebGL context.")?; + .map_err(|_| "Cannot acquire WebGL context.")?; let ctx = glow::Context::from_webgl1_context(gl); Ok(ctx) @@ -52,9 +53,9 @@ fn create_webgl2_context( let gl = win .get_context_with_context_options("webgl2", webgl_options(antialias, transparent).as_ref()) .map_err(|e| format!("{e:?}"))? - .ok_or("Cannot adquire the Webgl2 context. Is the canvas already instantiated?")? + .ok_or("Cannot acquire the Webgl2 context. Is the canvas already instantiated?")? .dyn_into::() - .map_err(|_| "Cannot adquire WebGL2 context.")?; + .map_err(|_| "Cannot acquire WebGL2 context.")?; let ctx = glow::Context::from_webgl2_context(gl); Ok(ctx)