Expand description
Texture-based resampling using wgpu hardware samplers.
This module provides a TextureResampler that performs raster resampling
using a wgpu::Sampler and a texture_2d<f32> binding rather than a flat
array<f32> storage buffer. The hardware sampler handles filtering in
a single texel-fetch instruction, which is dramatically faster than
evaluating a bilinear/bicubic interpolation in WGSL.
§When to use this path
| Resampling method | Hardware-sampled? | Recommendation |
|---|---|---|
NearestNeighbor | yes (Nearest) | use this module |
Bilinear | yes (Linear) | use this module |
Bicubic | fallback (Linear) | use this module if speed > Q |
Lanczos { a } | no | use the compute-buffer path |
For high-quality bicubic and Lanczos resampling, prefer the compute-buffer
path in kernels::resampling which implements the full kernel mathematics.
§Workflow
- Upload source data as a sampleable
wgpu::Texturewithnew_input_texture_r32float. - Construct a
TextureResamplerwith the desired filter mode and destination format. - Create a destination storage texture with
crate::storage_texture::new_storage_texture. - Dispatch the resampler with
TextureResampler::dispatch. - Optionally download the result with
crate::storage_texture::read_texture_to_vec_f32.
Structs§
- Texture
Resampler - A compiled compute kernel that resamples a sampleable source texture into a destination storage texture using a hardware sampler.
Enums§
- Texture
Filter Method - Hardware-sampler filtering mode for
TextureResampler.
Functions§
- make_
texture_ resample_ shader_ source - Generate WGSL source for a texture-based resampling compute shader.
- new_
input_ texture_ r32float - Create a sampleable R32Float
wgpu::Textureand uploaddatainto it. - texture_
filter_ for_ resampling - Maps a
ResamplingMethodto the hardware-sampler filter that best approximates it.