Donner 0.5.1
Embeddable browser-grade SVG2 engine
Loading...
Searching...
No Matches
GeodeShaders.h File Reference

WGSL shader sources used by the Slug rendering pipeline. More...

#include <webgpu/webgpu.hpp>
Include dependency graph for GeodeShaders.h:

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Functions

wgpu::ShaderModule donner::geode::createSlugFillShader (const wgpu::Device &device)
 Compile the Slug fill shader for the given device.
wgpu::ShaderModule donner::geode::createSlugGradientShader (const wgpu::Device &device)
 Compile the Slug gradient-fill shader for the given device.
wgpu::ShaderModule donner::geode::createSlugMaskShader (const wgpu::Device &device)
 Compile the path-clip mask shader for the given device.
wgpu::ShaderModule donner::geode::createSlugFillAlphaCoverageShader (const wgpu::Device &device)
 Compile the alpha-coverage variant of the Slug fill shader.
wgpu::ShaderModule donner::geode::createSlugGradientAlphaCoverageShader (const wgpu::Device &device)
 Alpha-coverage variant of createSlugGradientShader.
wgpu::ShaderModule donner::geode::createSlugMaskAlphaCoverageShader (const wgpu::Device &device)
 Alpha-coverage variant of createSlugMaskShader.
wgpu::ShaderModule donner::geode::createImageBlitShader (const wgpu::Device &device)
 Compile the image-blit shader for the given device.
wgpu::ShaderModule donner::geode::createGaussianBlurShader (const wgpu::Device &device)
 Compile the Gaussian blur compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterOffsetShader (const wgpu::Device &device)
 Compile the feOffset compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterColorMatrixShader (const wgpu::Device &device)
 Compile the feColorMatrix compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterFloodShader (const wgpu::Device &device)
 Compile the feFlood compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterMergeShader (const wgpu::Device &device)
 Compile the feMerge alpha-over blit compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterCompositeShader (const wgpu::Device &device)
 Compile the feComposite compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterBlendShader (const wgpu::Device &device)
 Compile the feBlend compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterMorphologyShader (const wgpu::Device &device)
 Compile the feMorphology compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterComponentTransferShader (const wgpu::Device &device)
 Compile the feComponentTransfer compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterConvolveMatrixShader (const wgpu::Device &device)
 Compile the feConvolveMatrix compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterTurbulenceShader (const wgpu::Device &device)
 Compile the feTurbulence compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterDisplacementMapShader (const wgpu::Device &device)
 Compile the feDisplacementMap compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterDiffuseLightingShader (const wgpu::Device &device)
 Compile the feDiffuseLighting compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterSpecularLightingShader (const wgpu::Device &device)
 Compile the feSpecularLighting compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterDropShadowShader (const wgpu::Device &device)
 Compile the feDropShadow compose compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterImageShader (const wgpu::Device &device)
 Compile the feImage compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterTileShader (const wgpu::Device &device)
 Compile the feTile compute shader for the given device.
wgpu::ShaderModule donner::geode::createFilterSubregionClipShader (const wgpu::Device &device)
 Compile the per-primitive subregion clipping compute shader.
wgpu::ShaderModule donner::geode::createFilterColorSpaceConvertShader (const wgpu::Device &device)
 Compile the sRGB↔linearRGB color space conversion compute shader.

Detailed Description

WGSL shader sources used by the Slug rendering pipeline.

Function Documentation

◆ createFilterBlendShader()

wgpu::ShaderModule donner::geode::createFilterBlendShader ( const wgpu::Device & device)

Compile the feBlend compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_blend.wgsl via the embed_resources() Bazel rule. The shader applies one of 16 W3C Compositing 1 blend modes to two premultiplied-alpha input textures, using the same blend formulas as image_blit.wgsl.

Bind group layout:

  • @group(0) @binding(0) var in1_tex: texture_2d<f32>;
  • @group(0) @binding(1) var in2_tex: texture_2d<f32>;
  • @group(0) @binding(2) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(3) var<uniform> params: BlendParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterColorMatrixShader()

wgpu::ShaderModule donner::geode::createFilterColorMatrixShader ( const wgpu::Device & device)

Compile the feColorMatrix compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_color_matrix.wgsl via the embed_resources() Bazel rule. The shader applies a 4x5 color matrix to each pixel's RGBA channels. All type variants (matrix, saturate, hueRotate, luminanceToAlpha) are pre-computed to a 4x5 matrix on the CPU side.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: ColorMatrixParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterColorSpaceConvertShader()

wgpu::ShaderModule donner::geode::createFilterColorSpaceConvertShader ( const wgpu::Device & device)

Compile the sRGB↔linearRGB color space conversion compute shader.

The WGSL source is embedded at build time from shaders/filter_color_space_convert.wgsl via the embed_resources() Bazel rule. The shader converts premultiplied sRGB textures to premultiplied linear (or vice-versa) to implement color-interpolation-filters: linearRGB.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: Params;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterComponentTransferShader()

wgpu::ShaderModule donner::geode::createFilterComponentTransferShader ( const wgpu::Device & device)

Compile the feComponentTransfer compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_component_transfer.wgsl via the embed_resources() Bazel rule. The shader un-premultiplies, applies per-channel 256-entry LUTs, then re-premultiplies.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<storage, read> params: ComponentTransferParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterCompositeShader()

wgpu::ShaderModule donner::geode::createFilterCompositeShader ( const wgpu::Device & device)

Compile the feComposite compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_composite.wgsl via the embed_resources() Bazel rule. The shader applies one of 7 Porter-Duff compositing operators to two premultiplied-alpha input textures.

Bind group layout:

  • @group(0) @binding(0) var in1_tex: texture_2d<f32>;
  • @group(0) @binding(1) var in2_tex: texture_2d<f32>;
  • @group(0) @binding(2) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(3) var<uniform> params: CompositeParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterConvolveMatrixShader()

wgpu::ShaderModule donner::geode::createFilterConvolveMatrixShader ( const wgpu::Device & device)

Compile the feConvolveMatrix compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_convolve_matrix.wgsl via the embed_resources() Bazel rule. The shader applies an NxM kernel convolution with configurable edge mode, divisor, bias, and preserveAlpha.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: ConvolveParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterDiffuseLightingShader()

wgpu::ShaderModule donner::geode::createFilterDiffuseLightingShader ( const wgpu::Device & device)

Compile the feDiffuseLighting compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_diffuse_lighting.wgsl via the embed_resources() Bazel rule. The shader computes Lambertian diffuse lighting from the input's alpha channel used as a height map. Supports distant, point, and spot light sources via uniforms.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<storage, read> params: LightingParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterDisplacementMapShader()

wgpu::ShaderModule donner::geode::createFilterDisplacementMapShader ( const wgpu::Device & device)

Compile the feDisplacementMap compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_displacement_map.wgsl via the embed_resources() Bazel rule. The shader displaces each output pixel from in1 by channel values read from in2.

Bind group layout:

  • @group(0) @binding(0) var in1_tex: texture_2d<f32>;
  • @group(0) @binding(1) var in2_tex: texture_2d<f32>;
  • @group(0) @binding(2) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(3) var<uniform> params: DisplacementParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterDropShadowShader()

wgpu::ShaderModule donner::geode::createFilterDropShadowShader ( const wgpu::Device & device)

Compile the feDropShadow compose compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_drop_shadow.wgsl via the embed_resources() Bazel rule. The shader takes the original source and its pre-blurred counterpart and produces source over flood-tinted-offset-blur, implementing the compose-step of feDropShadow. The blur itself is run through the existing Gaussian blur pipeline before this shader executes.

Bind group layout:

  • @group(0) @binding(0) var in1_tex: texture_2d<f32>; // Source
  • @group(0) @binding(1) var in2_tex: texture_2d<f32>; // Blurred source
  • @group(0) @binding(2) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(3) var<uniform> params: DropShadowParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterFloodShader()

wgpu::ShaderModule donner::geode::createFilterFloodShader ( const wgpu::Device & device)

Compile the feFlood compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_flood.wgsl via the embed_resources() Bazel rule. The shader fills every pixel with a constant color uniform. No input texture is required.

Bind group layout:

  • @group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(1) var<uniform> params: FloodParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterImageShader()

wgpu::ShaderModule donner::geode::createFilterImageShader ( const wgpu::Device & device)

Compile the feImage compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_image.wgsl via the embed_resources() Bazel rule. The shader bilinearly samples a premultiplied-alpha image through a 2×3 image-from-output transform, producing transparent black outside the image bounds. Covers the external-raster and simple in-document fragment reference cases where the caller supplies the image pixels and the placement transform.

Bind group layout:

  • @group(0) @binding(0) var image_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: ImageParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterMergeShader()

wgpu::ShaderModule donner::geode::createFilterMergeShader ( const wgpu::Device & device)

Compile the feMerge alpha-over blit compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_merge.wgsl via the embed_resources() Bazel rule. The shader composites a source texture over a destination texture using Porter-Duff source-over: out = src + dst * (1 - src.a).

Bind group layout:

  • @group(0) @binding(0) var src_tex: texture_2d<f32>;
  • @group(0) @binding(1) var dst_tex: texture_2d<f32>;
  • @group(0) @binding(2) var output_tex: texture_storage_2d<rgba8unorm, write>;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterMorphologyShader()

wgpu::ShaderModule donner::geode::createFilterMorphologyShader ( const wgpu::Device & device)

Compile the feMorphology compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_morphology.wgsl via the embed_resources() Bazel rule. The shader applies a rectangular min/max kernel for erode/dilate.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: MorphologyParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterOffsetShader()

wgpu::ShaderModule donner::geode::createFilterOffsetShader ( const wgpu::Device & device)

Compile the feOffset compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_offset.wgsl via the embed_resources() Bazel rule. The shader shifts input pixels by a uniform (dx, dy) offset with configurable edge-mode handling.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: OffsetParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterSpecularLightingShader()

wgpu::ShaderModule donner::geode::createFilterSpecularLightingShader ( const wgpu::Device & device)

Compile the feSpecularLighting compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_specular_lighting.wgsl via the embed_resources() Bazel rule. The shader computes Phong specular lighting from the input's alpha channel used as a height map. Supports distant, point, and spot light sources via uniforms.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<storage, read> params: LightingParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterSubregionClipShader()

wgpu::ShaderModule donner::geode::createFilterSubregionClipShader ( const wgpu::Device & device)

Compile the per-primitive subregion clipping compute shader.

The WGSL source is embedded at build time from shaders/filter_subregion_clip.wgsl via the embed_resources() Bazel rule. The shader transforms each pixel center to user space via an inverse CTM and zeroes pixels outside the user-space subregion rectangle. Used after each filter primitive dispatch when the node has x/y/width/height overrides or when a non-axis-aligned ancestor transform requires rotation-aware clipping.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: SubregionClipParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterTileShader()

wgpu::ShaderModule donner::geode::createFilterTileShader ( const wgpu::Device & device)

Compile the feTile compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_tile.wgsl via the embed_resources() Bazel rule. The shader tiles an input subregion across the entire output texture with modular (wraparound) sampling.

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: TileParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createFilterTurbulenceShader()

wgpu::ShaderModule donner::geode::createFilterTurbulenceShader ( const wgpu::Device & device)

Compile the feTurbulence compute shader for the given device.

The WGSL source is embedded at build time from shaders/filter_turbulence.wgsl via the embed_resources() Bazel rule. The shader generates Perlin noise / fractal noise patterns per the SVG feTurbulence specification.

Bind group layout:

  • @group(0) @binding(0) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(1) var<storage, read> params: TurbulenceParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createGaussianBlurShader()

wgpu::ShaderModule donner::geode::createGaussianBlurShader ( const wgpu::Device & device)

Compile the Gaussian blur compute shader for the given device.

The WGSL source is embedded at build time from shaders/gaussian_blur.wgsl via the embed_resources() Bazel rule. The shader implements a two-pass separable Gaussian blur with configurable edge-mode handling (None / Duplicate / Wrap).

Bind group layout:

  • @group(0) @binding(0) var input_tex: texture_2d<f32>;
  • @group(0) @binding(1) var output_tex: texture_storage_2d<rgba8unorm, write>;
  • @group(0) @binding(2) var<uniform> params: BlurParams;
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createImageBlitShader()

wgpu::ShaderModule donner::geode::createImageBlitShader ( const wgpu::Device & device)

Compile the image-blit shader for the given device.

The WGSL source is embedded at build time from shaders/image_blit.wgsl via the embed_resources() Bazel rule. The shader expects:

  • @group(0) @binding(0) var<uniform> uniforms: Uniforms;
  • @group(0) @binding(1) var imageSampler: sampler;
  • @group(0) @binding(2) var imageTexture: texture_2d<f32>;

and no vertex buffer — corners are generated from @builtin(vertex_index).

Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createSlugFillAlphaCoverageShader()

wgpu::ShaderModule donner::geode::createSlugFillAlphaCoverageShader ( const wgpu::Device & device)

Compile the alpha-coverage variant of the Slug fill shader.

Identical to createSlugFillShader except the fragment stage has no @builtin(sample_mask) output — coverage is folded into the fragment color as popcount(mask) / 4.0. Used on Intel + Vulkan where writing sample_mask from overlapping band quads hangs Mesa ANV / Xe KMD.

◆ createSlugFillShader()

wgpu::ShaderModule donner::geode::createSlugFillShader ( const wgpu::Device & device)

Compile the Slug fill shader for the given device.

The WGSL source is embedded at build time from shaders/slug_fill.wgsl via the embed_resources() Bazel rule. The shader expects:

  • @group(0) @binding(0) var<uniform> uniforms: Uniforms;
  • @group(0) @binding(1) var<storage, read> bands: array<Band>;
  • @group(0) @binding(2) var<storage, read> curveData: array<f32>;
  • @group(0) @binding(3) var patternTexture: texture_2d<f32>;
  • @group(0) @binding(4) var patternSampler: sampler;

and vertex attributes:

  • @location(0) pos: vec2f — path-space position
  • @location(1) normal: vec2f — outward normal for dilation
  • @location(2) bandIndex: u32 — which band this vertex belongs to
Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createSlugGradientShader()

wgpu::ShaderModule donner::geode::createSlugGradientShader ( const wgpu::Device & device)

Compile the Slug gradient-fill shader for the given device.

Parallel to createSlugFillShader, but bound to a different uniform layout that carries linear-gradient parameters (transform, start/end, spread mode, stops) alongside the Slug coverage machinery. See shaders/slug_gradient.wgsl for the exact struct layout.

Returns
A valid shader module on success, or an empty module if compilation failed (errors go to the device's uncaptured error callback).

◆ createSlugMaskShader()

wgpu::ShaderModule donner::geode::createSlugMaskShader ( const wgpu::Device & device)

Compile the path-clip mask shader for the given device.

Same band/curve encoding as createSlugFillShader but the fragment stage writes clip coverage into an RGBA8Unorm target. The uniform layout is reduced to just the mvp matrix, viewport size, and fill rule — no paint mode, no pattern, no clip polygon. Used by the Phase 3b path-clipping pipeline to materialise a per-pixel clip mask texture that subsequent fill / gradient draws sample as a coverage multiplier.