Skip to main content

build_storage_texture_kernel

Function build_storage_texture_kernel 

Source
pub fn build_storage_texture_kernel(
    ctx: &GpuContext,
    wgsl_source: &str,
    entry_point: &str,
    output_format: TextureFormat,
) -> GpuResult<StorageTextureKernel>
Expand description

Compile a WGSL compute shader into a StorageTextureKernel.

The shader is looked up in the context’s crate::pipeline_cache::PipelineCache by the FNV-1a hash of wgsl_source, entry_point, and the output texture format. On a cache hit the existing compiled pipeline is returned immediately; on a miss the shader is compiled and cached for future calls.

§Parameters

  • ctx — the active GPU context.
  • wgsl_source — full WGSL compute shader text. Use make_storage_texture_shader_source to generate a default copy kernel.
  • entry_point — the @compute function name, usually "main".
  • output_format — the format of the storage texture this kernel will write to. Must be one of the formats accepted by new_storage_texture.

§Errors

Returns GpuError::UnsupportedFormat if output_format is unsupported, or GpuError::PipelineCreation if shader compilation fails.