From e4eb5b38ecb5646ec354c16ff1128f7e49c0f020 Mon Sep 17 00:00:00 2001 From: Ashley Date: Tue, 18 Jul 2023 00:40:53 +1200 Subject: [PATCH] Fix ASTC feature selection in the webgl backend (#3934) * Update glow to a new minor version, improve gles adapter astc feature selection * Update Cargo.lock * Add changelog entry * Improve cfg flags to filter out emscripten --- CHANGELOG.md | 1 + Cargo.lock | 4 ++-- Cargo.toml | 2 +- wgpu-hal/Cargo.toml | 2 +- wgpu-hal/src/gles/adapter.rs | 23 +++++++++++++++++++++-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0ceb66e24..61482fc9b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ Bottom level categories: - Fix OpenGL/EGL backend not respecting non-sRGB texture formats in `SurfaceConfiguration`. by @liquidev in [#3817](https://github.com/gfx-rs/wgpu/pull/3817) - Make write- and read-only marked buffers match non-readonly layouts. by @fornwall in [#3893](https://github.com/gfx-rs/wgpu/pull/3893) - Fix leaking X11 connections. by @wez in [#3924](https://github.com/gfx-rs/wgpu/pull/3924) +- Fix ASTC feature selection in the webgl backend. by @expenses in [#3934](https://github.com/gfx-rs/wgpu/pull/3934) #### Metal diff --git a/Cargo.lock b/Cargo.lock index 44dfb69f2a..b4db35e6dd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1049,9 +1049,9 @@ checksum = "518faa5064866338b013ff9b2350dc318e14cc4fcd6cb8206d7e7c9886c98815" [[package]] name = "glow" -version = "0.12.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "807edf58b70c0b5b2181dd39fe1839dbdb3ba02645630dc5f753e23da307f762" +checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" dependencies = [ "js-sys", "slotmap", diff --git a/Cargo.toml b/Cargo.toml index d43787f80f..156e4dfe35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -122,7 +122,7 @@ hassle-rs = "0.10.0" # Gles dependencies khronos-egl = "4.1" -glow = "0.12.2" +glow = "0.12.3" glutin = "0.29.1" # wasm32 dependencies diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 46ca5de24b..75b8094dde 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -66,7 +66,7 @@ rustc-hash = "1.1" log = "0.4" # backend: Gles -glow = { version = "0.12.2", optional = true } +glow = { version = "0.12.3", optional = true } [dependencies.wgt] package = "wgpu-types" diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index d7e72619c5..5594dfa237 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -397,8 +397,27 @@ impl super::Adapter { if extensions.contains("WEBGL_compressed_texture_astc") || extensions.contains("GL_OES_texture_compression_astc") { - features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC); - features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR); + #[cfg(all(target_arch = "wasm32", not(target_os = "emscripten")))] + { + if context + .glow_context + .compressed_texture_astc_supports_ldr_profile() + { + features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC); + } + if context + .glow_context + .compressed_texture_astc_supports_hdr_profile() + { + features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR); + } + } + + #[cfg(any(not(target_arch = "wasm32"), target_os = "emscripten"))] + { + features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC); + features.insert(wgt::Features::TEXTURE_COMPRESSION_ASTC_HDR); + } } else { features.set( wgt::Features::TEXTURE_COMPRESSION_ASTC,