mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-21 15:00:57 +01:00
[remote] SamplerDescriptor
Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
1 parent
106c5862a9
commit
e3166286c6
2 files changed
+44
-3
No files matched your search
@@ -81,3 +81,30 @@ pub struct TextureViewDescriptor<'a> {
|
||||
/// Range within the texture that is accessible via this view.
|
||||
pub range: wgt::ImageSubresourceRange,
|
||||
}
|
||||
|
||||
/// Describes a `Sampler`
|
||||
///
|
||||
/// Corresponds to [WebGPU `GPUSamplerDescriptor`](https://gpuweb.github.io/gpuweb/#dictdef-gpusamplerdescriptor).
|
||||
#[derive(Clone, Debug, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
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_modes: [wgt::AddressMode; 3],
|
||||
/// How to filter the texture when it needs to be magnified (made larger)
|
||||
pub mag_filter: wgt::FilterMode,
|
||||
/// 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::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
|
||||
pub lod_max_clamp: f32,
|
||||
/// If this is enabled, this is a comparison sampler using the given comparison function.
|
||||
pub compare: Option<wgt::CompareFunction>,
|
||||
/// Must be at least 1. If this is not 1, all filter modes must be linear.
|
||||
pub anisotropy_clamp: u16,
|
||||
}
|
||||
@@ -4,7 +4,8 @@ use core::ptr::NonNull;
|
||||
use wgpu_core_remote_types::{
|
||||
encoders::RenderBundleDescriptor,
|
||||
pipelines::{ComputePipelineDescriptor, RenderPipelineDescriptor},
|
||||
BufferDescriptor, ExternalTextureDescriptor, TextureDescriptor, TextureViewDescriptor,
|
||||
BufferDescriptor, ExternalTextureDescriptor, SamplerDescriptor, TextureDescriptor,
|
||||
TextureViewDescriptor,
|
||||
};
|
||||
|
||||
use wgpu_core::{
|
||||
@@ -400,7 +401,7 @@ impl Global {
|
||||
pub fn device_create_sampler(
|
||||
&self,
|
||||
device_id: DeviceId,
|
||||
desc: &resource::SamplerDescriptor,
|
||||
desc: &SamplerDescriptor,
|
||||
id_in: id::SamplerId,
|
||||
) {
|
||||
let mut hub = self.hub.borrow_mut();
|
||||
@@ -410,7 +411,20 @@ impl Global {
|
||||
|
||||
let device = devices.get(device_id);
|
||||
|
||||
let sampler = device.create_sampler(desc);
|
||||
let desc = resource::SamplerDescriptor {
|
||||
label: desc.label.as_ref().map(|l| Cow::Borrowed(l.as_ref())),
|
||||
address_modes: desc.address_modes,
|
||||
mag_filter: desc.mag_filter,
|
||||
min_filter: desc.min_filter,
|
||||
mipmap_filter: desc.mipmap_filter,
|
||||
lod_min_clamp: desc.lod_min_clamp,
|
||||
lod_max_clamp: desc.lod_max_clamp,
|
||||
compare: desc.compare,
|
||||
anisotropy_clamp: desc.anisotropy_clamp,
|
||||
border_color: None,
|
||||
};
|
||||
|
||||
let sampler = device.create_sampler(&desc);
|
||||
|
||||
samplers.assign(id_in, sampler);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user