From 827298eff53c0b1bf19f8be65734bdbd8cb5c4fd Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 19 Apr 2022 21:32:49 +0200 Subject: [PATCH 1/3] Do a downlevel check for anisotrophy and enable it in the webgl backend --- 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..a0868afc4c 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..a56ec15dbb 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_f32(raw, glow::TEXTURE_MAX_ANISOTROPY, anisotropy.get() as f32); + } //set_param_float(glow::TEXTURE_LOD_BIAS, info.lod_bias.0); From 16d4d9e9f157741128de85f28db3a81e3ab5fabe Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 19 Apr 2022 21:49:49 +0200 Subject: [PATCH 2/3] Run cargo fmt --- wgpu-hal/src/gles/adapter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index a0868afc4c..81898c34be 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -286,7 +286,7 @@ impl super::Adapter { downlevel_flags.set(wgt::DownlevelFlags::FRAGMENT_STORAGE, supports_storage); downlevel_flags.set( wgt::DownlevelFlags::ANISOTROPIC_FILTERING, - extensions.contains("EXT_texture_filter_anisotropic") + extensions.contains("EXT_texture_filter_anisotropic"), ); let mut features = wgt::Features::empty() From 2c04cb0d2fa917e64bd4e53103ef2b1eb4293a70 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Thu, 21 Apr 2022 00:36:44 +0200 Subject: [PATCH 3/3] Change to sample_parameter_i32 --- wgpu-hal/src/gles/device.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wgpu-hal/src/gles/device.rs b/wgpu-hal/src/gles/device.rs index a56ec15dbb..3defc44c0b 100644 --- a/wgpu-hal/src/gles/device.rs +++ b/wgpu-hal/src/gles/device.rs @@ -741,7 +741,7 @@ impl crate::Device for super::Device { } if let Some(anisotropy) = desc.anisotropy_clamp { - gl.sampler_parameter_f32(raw, glow::TEXTURE_MAX_ANISOTROPY, anisotropy.get() as f32); + gl.sampler_parameter_i32(raw, glow::TEXTURE_MAX_ANISOTROPY, anisotropy.get() as i32); } //set_param_float(glow::TEXTURE_LOD_BIAS, info.lod_bias.0);