From ff07716f79fb1d84a895bca9d0534947f024294f Mon Sep 17 00:00:00 2001 From: Ashley Date: Thu, 21 Apr 2022 02:56:16 +0200 Subject: [PATCH] Do a downlevel check for anisotrophy and enable it in the webgl backend (#2616) * Do a downlevel check for anisotrophy and enable it in the webgl backend * Run cargo fmt * Change to sample_parameter_i32 --- wgpu-hal/src/gles/adapter.rs | 4 ++++ wgpu-hal/src/gles/device.rs | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 61dcd56b91..81898c34be 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -284,6 +284,10 @@ impl super::Adapter { && (vertex_shader_storage_blocks != 0 || vertex_ssbo_false_zero), ); downlevel_flags.set(wgt::DownlevelFlags::FRAGMENT_STORAGE, supports_storage); + downlevel_flags.set( + wgt::DownlevelFlags::ANISOTROPIC_FILTERING, + extensions.contains("EXT_texture_filter_anisotropic"), + ); let mut features = wgt::Features::empty() | wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index bc6111077b..3defc44c0b 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -740,8 +740,9 @@ impl crate::Device for super::Device { gl.sampler_parameter_f32(raw, glow::TEXTURE_MAX_LOD, range.end); } - //TODO: `desc.anisotropy_clamp` depends on the downlevel flag - // gl.sampler_parameter_f32(rawow::TEXTURE_MAX_ANISOTROPY, aniso as f32); + if let Some(anisotropy) = desc.anisotropy_clamp { + gl.sampler_parameter_i32(raw, glow::TEXTURE_MAX_ANISOTROPY, anisotropy.get() as i32); + } //set_param_float(glow::TEXTURE_LOD_BIAS, info.lod_bias.0);