mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Split MipmapFilterMode from FilterMode (#8314)
This commit is contained in:
parent
8ff1eb995d
commit
a8f51f8fd1
13
CHANGELOG.md
13
CHANGELOG.md
@ -54,6 +54,19 @@ This is a breaking change
|
||||
|
||||
By @R-Cramer4 in [#8230](https://github.com/gfx-rs/wgpu/pull/8230)
|
||||
|
||||
#### `MipmapFilterMode` is split from `FilterMode`
|
||||
|
||||
This is a breaking change that aligns wgpu with spec.
|
||||
|
||||
```diff
|
||||
SamplerDescriptor {
|
||||
...
|
||||
- mipmap_filter: FilterMode::Nearest
|
||||
+ mipmap_filter: MipmapFilterMode::Nearest
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
## v27.0.2 (2025-10-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@ -66,8 +66,8 @@ pub(super) struct GPUSamplerDescriptor {
|
||||
pub mag_filter: GPUFilterMode,
|
||||
#[webidl(default = GPUFilterMode::Nearest)]
|
||||
pub min_filter: GPUFilterMode,
|
||||
#[webidl(default = GPUFilterMode::Nearest)]
|
||||
pub mipmap_filter: GPUFilterMode,
|
||||
#[webidl(default = GPUMipmapFilterMode::Nearest)]
|
||||
pub mipmap_filter: GPUMipmapFilterMode,
|
||||
|
||||
#[webidl(default = 0.0)]
|
||||
pub lod_min_clamp: f32,
|
||||
@ -99,7 +99,6 @@ impl From<GPUAddressMode> for wgpu_types::AddressMode {
|
||||
}
|
||||
}
|
||||
|
||||
// Same as GPUMipmapFilterMode
|
||||
#[derive(WebIDL)]
|
||||
#[webidl(enum)]
|
||||
pub(crate) enum GPUFilterMode {
|
||||
@ -116,6 +115,22 @@ impl From<GPUFilterMode> for wgpu_types::FilterMode {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(WebIDL)]
|
||||
#[webidl(enum)]
|
||||
pub(crate) enum GPUMipmapFilterMode {
|
||||
Nearest,
|
||||
Linear,
|
||||
}
|
||||
|
||||
impl From<GPUMipmapFilterMode> for wgpu_types::MipmapFilterMode {
|
||||
fn from(value: GPUMipmapFilterMode) -> Self {
|
||||
match value {
|
||||
GPUMipmapFilterMode::Nearest => Self::Nearest,
|
||||
GPUMipmapFilterMode::Linear => Self::Linear,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(WebIDL)]
|
||||
#[webidl(enum)]
|
||||
pub(crate) enum GPUCompareFunction {
|
||||
|
||||
@ -278,7 +278,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -117,7 +117,7 @@ impl Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@ -268,7 +268,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::Repeat,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Linear,
|
||||
..Default::default()
|
||||
});
|
||||
let mx_total = Self::generate_matrix(config.width as f32 / config.height as f32);
|
||||
|
||||
@ -121,7 +121,7 @@ impl MultiTargetRenderer {
|
||||
address_mode_w: wgpu::AddressMode::Repeat,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@ -240,7 +240,7 @@ impl TargetRenderer {
|
||||
address_mode_w: wgpu::AddressMode::Repeat,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -200,7 +200,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -189,7 +189,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -257,7 +257,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: Default::default(),
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
lod_min_clamp: 1.0,
|
||||
lod_max_clamp: 1.0,
|
||||
compare: None,
|
||||
|
||||
@ -366,7 +366,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
compare: Some(wgpu::CompareFunction::LessEqual),
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
@ -263,7 +263,7 @@ impl crate::framework::Example for Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Linear,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -217,7 +217,7 @@ impl Example {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..Default::default()
|
||||
});
|
||||
|
||||
|
||||
@ -192,7 +192,7 @@ static BIND_GROUP_NONFILTERING_LAYOUT_NONFILTERING_SAMPLER: GpuTestConfiguration
|
||||
label: Some("bind_group_non_filtering_layout_nonfiltering_sampler"),
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..wgpu::SamplerDescriptor::default()
|
||||
},
|
||||
true,
|
||||
@ -210,7 +210,7 @@ static BIND_GROUP_NONFILTERING_LAYOUT_MIN_SAMPLER: GpuTestConfiguration =
|
||||
label: Some("bind_group_non_filtering_layout_min_sampler"),
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..wgpu::SamplerDescriptor::default()
|
||||
},
|
||||
false,
|
||||
@ -228,7 +228,7 @@ static BIND_GROUP_NONFILTERING_LAYOUT_MAG_SAMPLER: GpuTestConfiguration =
|
||||
label: Some("bind_group_non_filtering_layout_mag_sampler"),
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
..wgpu::SamplerDescriptor::default()
|
||||
},
|
||||
false,
|
||||
@ -246,7 +246,7 @@ static BIND_GROUP_NONFILTERING_LAYOUT_MIPMAP_SAMPLER: GpuTestConfiguration =
|
||||
label: Some("bind_group_non_filtering_layout_mipmap_sampler"),
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Linear,
|
||||
..wgpu::SamplerDescriptor::default()
|
||||
},
|
||||
false,
|
||||
|
||||
@ -120,7 +120,7 @@ async fn binding_array_samplers(ctx: TestingContext, partially_bound: bool) {
|
||||
address_mode_w: AddressMode::ClampToEdge,
|
||||
mag_filter: FilterMode::Linear,
|
||||
min_filter: FilterMode::Linear,
|
||||
mipmap_filter: FilterMode::Linear,
|
||||
mipmap_filter: MipmapFilterMode::Linear,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 1000.0,
|
||||
compare: None,
|
||||
@ -134,7 +134,7 @@ async fn binding_array_samplers(ctx: TestingContext, partially_bound: bool) {
|
||||
address_mode_w: AddressMode::ClampToEdge,
|
||||
mag_filter: FilterMode::Nearest,
|
||||
min_filter: FilterMode::Nearest,
|
||||
mipmap_filter: FilterMode::Nearest,
|
||||
mipmap_filter: MipmapFilterMode::Nearest,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 1000.0,
|
||||
compare: None,
|
||||
|
||||
@ -37,7 +37,7 @@ fn sampler_deduplication(ctx: TestingContext) {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 100.0,
|
||||
compare: None,
|
||||
@ -52,7 +52,7 @@ fn sampler_deduplication(ctx: TestingContext) {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Linear,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 100.0,
|
||||
compare: None,
|
||||
@ -96,7 +96,7 @@ fn sampler_creation_failure(ctx: TestingContext) {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Nearest,
|
||||
min_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 100.0,
|
||||
compare: None,
|
||||
@ -397,7 +397,7 @@ fn sampler_bind_group(ctx: TestingContext, group_type: GroupType) {
|
||||
address_mode_w: wgpu::AddressMode::ClampToEdge,
|
||||
mag_filter: wgpu::FilterMode::Linear,
|
||||
min_filter: wgpu::FilterMode::Linear,
|
||||
mipmap_filter: wgpu::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu::MipmapFilterMode::Nearest,
|
||||
lod_min_clamp: 0.0,
|
||||
lod_max_clamp: 100.0,
|
||||
compare: None,
|
||||
|
||||
@ -1951,9 +1951,9 @@ impl Device {
|
||||
},
|
||||
);
|
||||
}
|
||||
if !matches!(desc.mipmap_filter, wgt::FilterMode::Linear) {
|
||||
if !matches!(desc.mipmap_filter, wgt::MipmapFilterMode::Linear) {
|
||||
return Err(
|
||||
resource::CreateSamplerError::InvalidFilterModeWithAnisotropy {
|
||||
resource::CreateSamplerError::InvalidMipmapFilterModeWithAnisotropy {
|
||||
filter_type: resource::SamplerFilterErrorType::MipmapFilter,
|
||||
filter_mode: desc.mipmap_filter,
|
||||
anisotropic_clamp: desc.anisotropy_clamp,
|
||||
@ -1999,7 +1999,7 @@ impl Device {
|
||||
comparison: desc.compare.is_some(),
|
||||
filtering: desc.min_filter == wgt::FilterMode::Linear
|
||||
|| desc.mag_filter == wgt::FilterMode::Linear
|
||||
|| desc.mipmap_filter == wgt::FilterMode::Linear,
|
||||
|| desc.mipmap_filter == wgt::MipmapFilterMode::Linear,
|
||||
};
|
||||
|
||||
let sampler = Arc::new(sampler);
|
||||
|
||||
@ -1908,7 +1908,7 @@ pub struct SamplerDescriptor<'a> {
|
||||
/// How to filter the texture when it needs to be minified (made smaller)
|
||||
pub min_filter: wgt::FilterMode,
|
||||
/// How to filter between mip map levels
|
||||
pub mipmap_filter: wgt::FilterMode,
|
||||
pub mipmap_filter: wgt::MipmapFilterMode,
|
||||
/// Minimum level of detail (i.e. mip level) to use
|
||||
pub lod_min_clamp: f32,
|
||||
/// Maximum level of detail (i.e. mip level) to use
|
||||
@ -1989,6 +1989,12 @@ pub enum CreateSamplerError {
|
||||
filter_mode: wgt::FilterMode,
|
||||
anisotropic_clamp: u16,
|
||||
},
|
||||
#[error("Invalid filter mode for {filter_type:?}: {filter_mode:?}. When anistropic clamp is not 1 (it is {anisotropic_clamp}), all filter modes must be linear.")]
|
||||
InvalidMipmapFilterModeWithAnisotropy {
|
||||
filter_type: SamplerFilterErrorType,
|
||||
filter_mode: wgt::MipmapFilterMode,
|
||||
anisotropic_clamp: u16,
|
||||
},
|
||||
#[error(transparent)]
|
||||
MissingFeatures(#[from] MissingFeatures),
|
||||
}
|
||||
@ -2008,7 +2014,8 @@ impl WebGpuError for CreateSamplerError {
|
||||
Self::InvalidLodMinClamp(_)
|
||||
| Self::InvalidLodMaxClamp { .. }
|
||||
| Self::InvalidAnisotropy(_)
|
||||
| Self::InvalidFilterModeWithAnisotropy { .. } => return ErrorType::Validation,
|
||||
| Self::InvalidFilterModeWithAnisotropy { .. }
|
||||
| Self::InvalidMipmapFilterModeWithAnisotropy { .. } => return ErrorType::Validation,
|
||||
};
|
||||
e.webgpu_error_type()
|
||||
}
|
||||
|
||||
@ -385,7 +385,7 @@ impl<A: hal::Api> Example<A> {
|
||||
address_modes: [wgpu_types::AddressMode::ClampToEdge; 3],
|
||||
mag_filter: wgpu_types::FilterMode::Linear,
|
||||
min_filter: wgpu_types::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu_types::FilterMode::Nearest,
|
||||
mipmap_filter: wgpu_types::MipmapFilterMode::Nearest,
|
||||
lod_clamp: 0.0..32.0,
|
||||
compare: None,
|
||||
anisotropy_clamp: 1,
|
||||
|
||||
@ -85,6 +85,13 @@ pub fn map_filter_mode(mode: wgt::FilterMode) -> Direct3D12::D3D12_FILTER_TYPE {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_mipmap_filter_mode(mode: wgt::MipmapFilterMode) -> Direct3D12::D3D12_FILTER_TYPE {
|
||||
match mode {
|
||||
wgt::MipmapFilterMode::Nearest => Direct3D12::D3D12_FILTER_TYPE_POINT,
|
||||
wgt::MipmapFilterMode::Linear => Direct3D12::D3D12_FILTER_TYPE_LINEAR,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_comparison(func: wgt::CompareFunction) -> Direct3D12::D3D12_COMPARISON_FUNC {
|
||||
use wgt::CompareFunction as Cf;
|
||||
match func {
|
||||
|
||||
@ -726,7 +726,7 @@ impl crate::Device for super::Device {
|
||||
let mut filter = Direct3D12::D3D12_FILTER(
|
||||
(conv::map_filter_mode(desc.min_filter).0 << Direct3D12::D3D12_MIN_FILTER_SHIFT)
|
||||
| (conv::map_filter_mode(desc.mag_filter).0 << Direct3D12::D3D12_MAG_FILTER_SHIFT)
|
||||
| (conv::map_filter_mode(desc.mipmap_filter).0
|
||||
| (conv::map_mipmap_filter_mode(desc.mipmap_filter).0
|
||||
<< Direct3D12::D3D12_MIP_FILTER_SHIFT)
|
||||
| (reduction.0 << Direct3D12::D3D12_FILTER_REDUCTION_TYPE_SHIFT),
|
||||
);
|
||||
|
||||
@ -238,9 +238,10 @@ pub(super) fn describe_vertex_format(vertex_format: wgt::VertexFormat) -> super:
|
||||
pub fn map_filter_modes(
|
||||
min: wgt::FilterMode,
|
||||
mag: wgt::FilterMode,
|
||||
mip: wgt::FilterMode,
|
||||
mip: wgt::MipmapFilterMode,
|
||||
) -> (u32, u32) {
|
||||
use wgt::FilterMode as Fm;
|
||||
use wgt::MipmapFilterMode as Mfm;
|
||||
|
||||
let mag_filter = match mag {
|
||||
Fm::Nearest => glow::NEAREST,
|
||||
@ -248,10 +249,10 @@ pub fn map_filter_modes(
|
||||
};
|
||||
|
||||
let min_filter = match (min, mip) {
|
||||
(Fm::Nearest, Fm::Nearest) => glow::NEAREST_MIPMAP_NEAREST,
|
||||
(Fm::Nearest, Fm::Linear) => glow::NEAREST_MIPMAP_LINEAR,
|
||||
(Fm::Linear, Fm::Nearest) => glow::LINEAR_MIPMAP_NEAREST,
|
||||
(Fm::Linear, Fm::Linear) => glow::LINEAR_MIPMAP_LINEAR,
|
||||
(Fm::Nearest, Mfm::Nearest) => glow::NEAREST_MIPMAP_NEAREST,
|
||||
(Fm::Nearest, Mfm::Linear) => glow::NEAREST_MIPMAP_LINEAR,
|
||||
(Fm::Linear, Mfm::Nearest) => glow::LINEAR_MIPMAP_NEAREST,
|
||||
(Fm::Linear, Mfm::Linear) => glow::LINEAR_MIPMAP_LINEAR,
|
||||
};
|
||||
|
||||
(min_filter, mag_filter)
|
||||
|
||||
@ -1948,7 +1948,7 @@ pub struct SamplerDescriptor<'a> {
|
||||
pub address_modes: [wgt::AddressMode; 3],
|
||||
pub mag_filter: wgt::FilterMode,
|
||||
pub min_filter: wgt::FilterMode,
|
||||
pub mipmap_filter: wgt::FilterMode,
|
||||
pub mipmap_filter: wgt::MipmapFilterMode,
|
||||
pub lod_clamp: Range<f32>,
|
||||
pub compare: Option<wgt::CompareFunction>,
|
||||
// Must in the range [1, 16].
|
||||
|
||||
@ -566,11 +566,11 @@ impl crate::Device for super::Device {
|
||||
descriptor.set_min_filter(conv::map_filter_mode(desc.min_filter));
|
||||
descriptor.set_mag_filter(conv::map_filter_mode(desc.mag_filter));
|
||||
descriptor.set_mip_filter(match desc.mipmap_filter {
|
||||
wgt::FilterMode::Nearest if desc.lod_clamp == (0.0..0.0) => {
|
||||
wgt::MipmapFilterMode::Nearest if desc.lod_clamp == (0.0..0.0) => {
|
||||
MTLSamplerMipFilter::NotMipmapped
|
||||
}
|
||||
wgt::FilterMode::Nearest => MTLSamplerMipFilter::Nearest,
|
||||
wgt::FilterMode::Linear => MTLSamplerMipFilter::Linear,
|
||||
wgt::MipmapFilterMode::Nearest => MTLSamplerMipFilter::Nearest,
|
||||
wgt::MipmapFilterMode::Linear => MTLSamplerMipFilter::Linear,
|
||||
});
|
||||
|
||||
let [s, t, r] = desc.address_modes;
|
||||
|
||||
@ -697,10 +697,10 @@ pub fn map_filter_mode(mode: wgt::FilterMode) -> vk::Filter {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_mip_filter_mode(mode: wgt::FilterMode) -> vk::SamplerMipmapMode {
|
||||
pub fn map_mip_filter_mode(mode: wgt::MipmapFilterMode) -> vk::SamplerMipmapMode {
|
||||
match mode {
|
||||
wgt::FilterMode::Nearest => vk::SamplerMipmapMode::NEAREST,
|
||||
wgt::FilterMode::Linear => vk::SamplerMipmapMode::LINEAR,
|
||||
wgt::MipmapFilterMode::Nearest => vk::SamplerMipmapMode::NEAREST,
|
||||
wgt::MipmapFilterMode::Linear => vk::SamplerMipmapMode::LINEAR,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -6587,7 +6587,7 @@ pub struct SamplerDescriptor<L> {
|
||||
/// How to filter the texture when it needs to be minified (made smaller)
|
||||
pub min_filter: FilterMode,
|
||||
/// How to filter between mip map levels
|
||||
pub mipmap_filter: FilterMode,
|
||||
pub mipmap_filter: MipmapFilterMode,
|
||||
/// Minimum level of detail (i.e. mip level) to use
|
||||
pub lod_min_clamp: f32,
|
||||
/// Maximum level of detail (i.e. mip level) to use
|
||||
@ -6692,12 +6692,32 @@ pub enum AddressMode {
|
||||
pub enum FilterMode {
|
||||
/// Nearest neighbor sampling.
|
||||
///
|
||||
/// This creates a pixelated effect when used as a mag filter
|
||||
/// This creates a pixelated effect.
|
||||
#[default]
|
||||
Nearest = 0,
|
||||
/// Linear Interpolation
|
||||
///
|
||||
/// This makes textures smooth but blurry when used as a mag filter.
|
||||
/// This makes textures smooth but blurry.
|
||||
Linear = 1,
|
||||
}
|
||||
|
||||
/// Texel mixing mode when sampling between texels.
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUMipmapFilterMode`](
|
||||
/// https://gpuweb.github.io/gpuweb/#enumdef-gpumipmapfiltermode).
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug, Default, Hash, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
|
||||
pub enum MipmapFilterMode {
|
||||
/// Nearest neighbor sampling.
|
||||
///
|
||||
/// Return the value of the texel nearest to the texture coordinates.
|
||||
#[default]
|
||||
Nearest = 0,
|
||||
/// Linear Interpolation
|
||||
///
|
||||
/// Select two texels in each dimension and return a linear interpolation between their values.
|
||||
Linear = 1,
|
||||
}
|
||||
|
||||
|
||||
@ -675,10 +675,10 @@ fn map_filter_mode(mode: wgt::FilterMode) -> webgpu_sys::GpuFilterMode {
|
||||
}
|
||||
}
|
||||
|
||||
fn map_mipmap_filter_mode(mode: wgt::FilterMode) -> webgpu_sys::GpuMipmapFilterMode {
|
||||
fn map_mipmap_filter_mode(mode: wgt::MipmapFilterMode) -> webgpu_sys::GpuMipmapFilterMode {
|
||||
match mode {
|
||||
wgt::FilterMode::Nearest => webgpu_sys::GpuMipmapFilterMode::Nearest,
|
||||
wgt::FilterMode::Linear => webgpu_sys::GpuMipmapFilterMode::Linear,
|
||||
wgt::MipmapFilterMode::Nearest => webgpu_sys::GpuMipmapFilterMode::Nearest,
|
||||
wgt::MipmapFilterMode::Linear => webgpu_sys::GpuMipmapFilterMode::Linear,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -98,17 +98,17 @@ pub use wgt::{
|
||||
ExternalTextureTransferFunction, Face, Features, FeaturesWGPU, FeaturesWebGPU, FilterMode,
|
||||
FrontFace, GlBackendOptions, GlFenceBehavior, Gles3MinorVersion, HalCounters,
|
||||
ImageSubresourceRange, IndexFormat, InstanceDescriptor, InstanceFlags, InternalCounters,
|
||||
Limits, MemoryBudgetThresholds, MemoryHints, MultisampleState, NoopBackendOptions, Origin2d,
|
||||
Origin3d, PipelineStatisticsTypes, PollError, PollStatus, PolygonMode, PowerPreference,
|
||||
PredefinedColorSpace, PresentMode, PresentationTimestamp, PrimitiveState, PrimitiveTopology,
|
||||
PushConstantRange, QueryType, RenderBundleDepthStencil, RequestAdapterError,
|
||||
SamplerBindingType, SamplerBorderColor, ShaderLocation, ShaderModel, ShaderRuntimeChecks,
|
||||
ShaderStages, StencilFaceState, StencilOperation, StencilState, StorageTextureAccess,
|
||||
SurfaceCapabilities, SurfaceStatus, TexelCopyBufferLayout, TextureAspect, TextureDimension,
|
||||
TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures, TextureSampleType,
|
||||
TextureTransition, TextureUsages, TextureUses, TextureViewDimension, Trace, VertexAttribute,
|
||||
VertexFormat, VertexStepMode, WasmNotSend, WasmNotSendSync, WasmNotSync, COPY_BUFFER_ALIGNMENT,
|
||||
COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
|
||||
Limits, MemoryBudgetThresholds, MemoryHints, MipmapFilterMode, MultisampleState,
|
||||
NoopBackendOptions, Origin2d, Origin3d, PipelineStatisticsTypes, PollError, PollStatus,
|
||||
PolygonMode, PowerPreference, PredefinedColorSpace, PresentMode, PresentationTimestamp,
|
||||
PrimitiveState, PrimitiveTopology, PushConstantRange, QueryType, RenderBundleDepthStencil,
|
||||
RequestAdapterError, SamplerBindingType, SamplerBorderColor, ShaderLocation, ShaderModel,
|
||||
ShaderRuntimeChecks, ShaderStages, StencilFaceState, StencilOperation, StencilState,
|
||||
StorageTextureAccess, SurfaceCapabilities, SurfaceStatus, TexelCopyBufferLayout, TextureAspect,
|
||||
TextureDimension, TextureFormat, TextureFormatFeatureFlags, TextureFormatFeatures,
|
||||
TextureSampleType, TextureTransition, TextureUsages, TextureUses, TextureViewDimension, Trace,
|
||||
VertexAttribute, VertexFormat, VertexStepMode, WasmNotSend, WasmNotSendSync, WasmNotSync,
|
||||
COPY_BUFFER_ALIGNMENT, COPY_BYTES_PER_ROW_ALIGNMENT, MAP_ALIGNMENT, PUSH_CONSTANT_ALIGNMENT,
|
||||
QUERY_RESOLVE_BUFFER_ALIGNMENT, QUERY_SET_MAX_QUERIES, QUERY_SIZE, VERTEX_ALIGNMENT,
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user