Table of Contents

Class WebGPUShaderLayerEffect

Namespace
SixLabors.ImageSharp.Drawing.Processing.Backends
Assembly
SixLabors.ImageSharp.Drawing.WebGPU.dll

Defines a layer effect with complete WGSL shader passes and an equivalent ImageSharp CPU fallback.

public abstract class WebGPUShaderLayerEffect : LayerEffect, IWebGPUShaderEffect
Inheritance
WebGPUShaderLayerEffect
Implements
Derived
Inherited Members

Remarks

Instances work with both drawing backends. WebGPU executes the configured WGSL passes, while CPU rendering executes the required fallback effect. Each pass receives the preceding image as its input.

Shader source must define fn layer_effect(position: vec2<f32>) -> vec4<f32>. Position uses effect-local pixel-center coordinates. The return value is associated-alpha RGBA in [0, 1]. ImageSharp supplies layer_load, layer_load_unassociated, layer_sample, and the declared imagesharp_uniforms fields. Each source defines one complete shader pass.

Constructors

WebGPUShaderLayerEffect(LayerEffect, string, WebGPUShaderUniformLayout)

Initializes a new instance of the WebGPUShaderLayerEffect class.

protected WebGPUShaderLayerEffect(LayerEffect fallbackEffect, string shaderSource, WebGPUShaderUniformLayout uniformLayout)

Parameters

fallbackEffect LayerEffect

The equivalent effect used by CPU rendering.

shaderSource string

The complete WGSL source for each pass added by this effect.

uniformLayout WebGPUShaderUniformLayout

The named uniform values available to the shader.

WebGPUShaderLayerEffect(string, WebGPUShaderUniformLayout, Action<IImageProcessingContext>)

Initializes a new instance of the WebGPUShaderLayerEffect class.

protected WebGPUShaderLayerEffect(string shaderSource, WebGPUShaderUniformLayout uniformLayout, Action<IImageProcessingContext> fallback)

Parameters

shaderSource string

The complete WGSL source for each pass added by this effect.

uniformLayout WebGPUShaderUniformLayout

The named uniform values available to the shader.

fallback Action<IImageProcessingContext>

The equivalent operation used by CPU rendering.

Methods

AddShaderPass(BorderWrappingMode, BorderWrappingMode, Action<WebGPUShaderUniformBuilder>)

Configures and adds an invocation whose filtered samples use the supplied border modes.

protected void AddShaderPass(BorderWrappingMode xBorderMode, BorderWrappingMode yBorderMode, Action<WebGPUShaderUniformBuilder> configureUniforms)

Parameters

xBorderMode BorderWrappingMode

The wrapping mode applied beyond the horizontal input borders.

yBorderMode BorderWrappingMode

The wrapping mode applied beyond the vertical input borders.

configureUniforms Action<WebGPUShaderUniformBuilder>

The action that assigns this pass's named uniform values.

AddShaderPass(Action<WebGPUShaderUniformBuilder>)

Configures and adds an invocation of the complete shader source to this effect's ordered pass sequence.

protected void AddShaderPass(Action<WebGPUShaderUniformBuilder> configureUniforms)

Parameters

configureUniforms Action<WebGPUShaderUniformBuilder>

The action that assigns this pass's named uniform values.