Skip to main content

make_texture_resample_shader_source

Function make_texture_resample_shader_source 

Source
pub fn make_texture_resample_shader_source(
    filter: TextureFilterMethod,
    dst_fmt: TextureFormat,
) -> String
Expand description

Generate WGSL source for a texture-based resampling compute shader.

The shader binds:

  • binding 0: a sampleable texture_2d<f32> (the source raster).
  • binding 1: a sampler configured with the requested filter mode.
  • binding 2: a write-only texture_storage_2d<{dst_fmt}, write> (the destination raster).

Each invocation maps its destination pixel (gid.x, gid.y) to a normalised uv coordinate at the pixel centre, samples the source texture with textureSampleLevel(..., 0.0), and writes the result to the storage texture.

The filter parameter is not baked into the shader text — the wgpu Sampler binding determines the actual filtering behaviour. The parameter is accepted here for documentation purposes and to enable future shader specialisations.