Skip to main content

Module texture_resample

Module texture_resample 

Source
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 methodHardware-sampled?Recommendation
NearestNeighboryes (Nearest)use this module
Bilinearyes (Linear)use this module
Bicubicfallback (Linear)use this module if speed > Q
Lanczos { a }nouse 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

  1. Upload source data as a sampleable wgpu::Texture with new_input_texture_r32float.
  2. Construct a TextureResampler with the desired filter mode and destination format.
  3. Create a destination storage texture with crate::storage_texture::new_storage_texture.
  4. Dispatch the resampler with TextureResampler::dispatch.
  5. Optionally download the result with crate::storage_texture::read_texture_to_vec_f32.

Structs§

TextureResampler
A compiled compute kernel that resamples a sampleable source texture into a destination storage texture using a hardware sampler.

Enums§

TextureFilterMethod
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::Texture and upload data into it.
texture_filter_for_resampling
Maps a ResamplingMethod to the hardware-sampler filter that best approximates it.