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).
This commit is contained in:
Nils Hasenbanck 2020-06-20 17:32:06 +02:00
parent 75d2e47849
commit 1f5a55ea13

View File

@ -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<L> {
@ -1507,6 +1507,25 @@ pub struct SamplerDescriptor<L> {
pub _non_exhaustive: NonExhaustive,
}
impl<L: Default> Default for SamplerDescriptor<L> {
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<L> SamplerDescriptor<L> {
pub fn map_label<K>(&self, fun: impl FnOnce(&L) -> K) -> SamplerDescriptor<K> {
SamplerDescriptor {