Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
donner::geode::GeodeFilterEngine Class Reference

GPU filter-graph executor. More...

#include "donner/svg/renderer/geode/GeodeFilterEngine.h"

Public Member Functions

 GeodeFilterEngine (GeodeDevice &device, bool verbose=false)
 GeodeFilterEngine (const GeodeFilterEngine &)=delete
GeodeFilterEngineoperator= (const GeodeFilterEngine &)=delete
wgpu::Texture execute (const svg::components::FilterGraph &graph, const wgpu::Texture &sourceGraphic, const Box2d &filterRegion, const Transform2d &deviceFromFilter, FilterTextureAllocator &textureAllocator, ScopedWgpuHandle< wgpu::CommandEncoder > &commandEncoder, svg::components::FilterExecutionBudget *executionBudget=nullptr)
 Execute a filter graph against the source-graphic texture.
void beginFrame ()
 Begin a new frame for this engine: reset the frame-scoped chunk pass counter (so the 64-pass command-buffer bound covers every filter graph recorded into the frame's shared encoder, not just one execute() call) and reset the per-frame uniform scratch cursor.

Friends

struct FilterGraphExecution

Detailed Description

GPU filter-graph executor.

Given a FilterGraph and a source-graphic texture (the offscreen layer snapshot captured between pushFilterLayer / popFilterLayer), executes the graph's primitives on the GPU and returns the final output texture.

Intermediate textures between primitives are allocated on demand and keyed by result names.

Currently supports:

  • feGaussianBlur (two-pass separable Gaussian via compute shader)
  • feOffset (pixel shift via compute shader)
  • feColorMatrix (4x5 matrix transform via compute shader)
  • feFlood (constant color fill via compute shader)
  • feMerge (alpha-over composite of N inputs via compute shader)
  • feComposite (Porter-Duff compositing of two inputs via compute shader)
  • feBlend (W3C Compositing 1 blend modes via compute shader)
  • feMorphology (erode / dilate via min / max rectangular kernel)
  • feComponentTransfer (per-channel LUT transform via compute shader)
  • feConvolveMatrix (NxM kernel convolution via compute shader)
  • feTurbulence (Perlin noise / fractal noise via compute shader)
  • feDisplacementMap (per-pixel channel-driven displacement via compute shader)
  • feDiffuseLighting (Lambertian shading with distant/point/spot lights)
  • feSpecularLighting (Phong shading with distant/point/spot lights)
  • feDropShadow (blur alpha + offset + flood-tint + source-over)
  • feImage (Mitchell-Netravali bicubic placement of external raster / in-document fragment)
  • feTile (wraparound tiling of input subregion across filter region)

Unsupported primitives pass the current buffer through unchanged.

Constructor & Destructor Documentation

◆ GeodeFilterEngine()

donner::geode::GeodeFilterEngine::GeodeFilterEngine ( GeodeDevice & device,
bool verbose = false )
explicit
Parameters
deviceThe Geode device (owns wgpu::Device + queue).
verboseIf true, emit one-shot warnings for unsupported primitives.

Member Function Documentation

◆ beginFrame()

void donner::geode::GeodeFilterEngine::beginFrame ( )

Begin a new frame for this engine: reset the frame-scoped chunk pass counter (so the 64-pass command-buffer bound covers every filter graph recorded into the frame's shared encoder, not just one execute() call) and reset the per-frame uniform scratch cursor.

The renderer calls this once per frame from its own beginFrame, BEFORE the filter texture pool runs its stale-bucket eviction, and before any filter pass of the frame records. Uniform slots written after this call reuse stable (buffer, offset) pairs across frames. The cursor itself is mutex-guarded, but callers must still serialize one frame per device at a time: two sibling renderers drawing concurrently on the same device would alias uniform slots and rewind the cursor under recorded passes (the renderer's architecture already serializes the render worker per device).

◆ execute()

wgpu::Texture donner::geode::GeodeFilterEngine::execute ( const svg::components::FilterGraph & graph,
const wgpu::Texture & sourceGraphic,
const Box2d & filterRegion,
const Transform2d & deviceFromFilter,
FilterTextureAllocator & textureAllocator,
ScopedWgpuHandle< wgpu::CommandEncoder > & commandEncoder,
svg::components::FilterExecutionBudget * executionBudget = nullptr )

Execute a filter graph against the source-graphic texture.

The source texture must be RGBA8Unorm with TextureBinding usage. The returned texture is an RGBA8Unorm texture sized to the filter region (or the source dimensions if no region is given). Its lifetime is retained by textureAllocator until the frame command buffer has submitted.

Parameters
graphThe filter graph to execute.
sourceGraphicThe input texture (layer snapshot).
filterRegionThe filter region in user-space coordinates.
deviceFromFilterThe combined transform from filter/user-space to device-pixel coordinates, captured at pushFilterLayer time. Used to derive per-axis scale factors and to project directional parameters (e.g. feOffset dx/dy) through rotation/skew.
textureAllocatorRenderer-owned filter texture pool boundary.
commandEncoderThe frame command encoder slot. Filter compute passes are recorded after the source render pass and before the filtered result is composited. Pathological filter graphs (for example a huge-radius feMorphology decomposing into thousands of passes) chunk this slot: the current command buffer is submitted and a fresh encoder is installed in the slot every 64 passes, so no single command buffer grows without bound while small filters keep the two-submissions-per-frame shape.
executionBudgetOptional shared per-frame budget. Direct callers may omit it to apply only the graph-local limit.
Returns
The filtered output texture (RGBA8Unorm, TextureBinding | CopySrc).

The documentation for this class was generated from the following file: