mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 06:50:59 +01:00
Move SamplerDescriptor to wgpu-types (#6649)
This commit is contained in:
2 files changed
+55
-46
No files matched your search
@@ -6178,6 +6178,60 @@ impl<L, V> TextureDescriptor<L, V> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Describes a `Sampler`.
|
||||
///
|
||||
/// For use with `Device::create_sampler`.
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUSamplerDescriptor`](
|
||||
/// https://gpuweb.github.io/gpuweb/#dictdef-gpusamplerdescriptor).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct SamplerDescriptor<L> {
|
||||
/// Debug label of the sampler. This will show up in graphics debuggers for easy identification.
|
||||
pub label: L,
|
||||
/// How to deal with out of bounds accesses in the u (i.e. x) direction
|
||||
pub address_mode_u: AddressMode,
|
||||
/// How to deal with out of bounds accesses in the v (i.e. y) direction
|
||||
pub address_mode_v: AddressMode,
|
||||
/// How to deal with out of bounds accesses in the w (i.e. z) direction
|
||||
pub address_mode_w: AddressMode,
|
||||
/// How to filter the texture when it needs to be magnified (made larger)
|
||||
pub mag_filter: FilterMode,
|
||||
/// 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,
|
||||
/// 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
|
||||
pub lod_max_clamp: f32,
|
||||
/// If this is enabled, this is a comparison sampler using the given comparison function.
|
||||
pub compare: Option<CompareFunction>,
|
||||
/// Must be at least 1. If this is not 1, all filter modes must be linear.
|
||||
pub anisotropy_clamp: u16,
|
||||
/// Border color to use when address_mode is [`AddressMode::ClampToBorder`]
|
||||
pub border_color: Option<SamplerBorderColor>,
|
||||
}
|
||||
|
||||
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: 32.0,
|
||||
compare: None,
|
||||
anisotropy_clamp: 1,
|
||||
border_color: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Kind of data the texture holds.
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUTextureAspect`](
|
||||
|
||||
+1
-46
@@ -35,50 +35,5 @@ impl Drop for Sampler {
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUSamplerDescriptor`](
|
||||
/// https://gpuweb.github.io/gpuweb/#dictdef-gpusamplerdescriptor).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct SamplerDescriptor<'a> {
|
||||
/// Debug label of the sampler. This will show up in graphics debuggers for easy identification.
|
||||
pub label: Label<'a>,
|
||||
/// How to deal with out of bounds accesses in the u (i.e. x) direction
|
||||
pub address_mode_u: AddressMode,
|
||||
/// How to deal with out of bounds accesses in the v (i.e. y) direction
|
||||
pub address_mode_v: AddressMode,
|
||||
/// How to deal with out of bounds accesses in the w (i.e. z) direction
|
||||
pub address_mode_w: AddressMode,
|
||||
/// How to filter the texture when it needs to be magnified (made larger)
|
||||
pub mag_filter: FilterMode,
|
||||
/// 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,
|
||||
/// 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
|
||||
pub lod_max_clamp: f32,
|
||||
/// If this is enabled, this is a comparison sampler using the given comparison function.
|
||||
pub compare: Option<CompareFunction>,
|
||||
/// Must be at least 1. If this is not 1, all filter modes must be linear.
|
||||
pub anisotropy_clamp: u16,
|
||||
/// Border color to use when address_mode is [`AddressMode::ClampToBorder`]
|
||||
pub border_color: Option<SamplerBorderColor>,
|
||||
}
|
||||
pub type SamplerDescriptor<'a> = wgt::SamplerDescriptor<Label<'a>>;
|
||||
static_assertions::assert_impl_all!(SamplerDescriptor<'_>: Send, Sync);
|
||||
|
||||
impl Default for SamplerDescriptor<'_> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
label: None,
|
||||
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: 32.0,
|
||||
compare: None,
|
||||
anisotropy_clamp: 1,
|
||||
border_color: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user