From 1f5a55ea1397e9b24ed8a3e932b5ba2d6611d46f Mon Sep 17 00:00:00 2001 From: Nils Hasenbanck Date: Sat, 20 Jun 2020 17:32:06 +0200 Subject: [PATCH] Fix the default lod_max_clamp value for the SamplerDescriptor The current default value for the lod_max_clamp of a sampler is 0. This would deactivate mipmapping alltogether. Setting it to f32::MAX makes sure to always enable it. It's the default value apple uses in Metal, it seems to be valid usage in Vulkan (maxLod in VkSamplerCreateInfo) and in DX12 (MaxLOD in D3D12_SAMPLER_DESC). --- wgpu-types/src/lib.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index b388f7d76..87e53faba 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -1474,7 +1474,7 @@ impl Default for FilterMode { } /// Describes a [`Sampler`] -#[derive(Default, Clone, Debug, PartialEq)] +#[derive(Clone, Debug, PartialEq)] #[cfg_attr(feature = "trace", derive(Serialize))] #[cfg_attr(feature = "replay", derive(Deserialize))] pub struct SamplerDescriptor { @@ -1507,6 +1507,25 @@ pub struct SamplerDescriptor { pub _non_exhaustive: NonExhaustive, } +impl Default for SamplerDescriptor { + fn default() -> Self { + Self { + label: Default::default(), + address_mode_u: Default::default(), + address_mode_v: Default::default(), + address_mode_w: Default::default(), + mag_filter: Default::default(), + min_filter: Default::default(), + mipmap_filter: Default::default(), + lod_min_clamp: 0.0, + lod_max_clamp: f32::MAX, + compare: Default::default(), + anisotropy_clamp: Default::default(), + _non_exhaustive: Default::default(), + } + } +} + impl SamplerDescriptor { pub fn map_label(&self, fun: impl FnOnce(&L) -> K) -> SamplerDescriptor { SamplerDescriptor {