Donner SVG 0.8.0
0.8.0 ยท ebf353960.8.0 main
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
GeodeFilterEngine & operator= (const GeodeFilterEngine &)=delete
FilterExecutionResult execute (const svg::components::FilterGraph &graph, const gpu::Texture &sourceGraphic, const gpu::TextureDescriptor &sourceGraphicDesc, const Box2d &filterRegion, const Transform2d &deviceFromFilter, FilterTextureAllocator &textureAllocator, svg::components::FilterExecutionBudget *executionBudget=nullptr, std::optional< FilterTilePlan > admittedPlan=std::nullopt, FrameCommandBufferSink *frameSink=nullptr)
 Execute a filter graph against the source-graphic texture.
void beginFrame ()
 Begin a new frame for this engine by resetting the per-frame uniform scratch cursor.
uint64_t retainedBufferBytes () const
 Current parameter/table allocation bytes, including buffers awaiting frame completion.
FilterTilePlan executionPlan (const svg::components::FilterGraph &graph, uint32_t width, uint32_t height, const Transform2d &deviceFromFilter) const
 Plans bounded working textures without changing sample coordinates or resolution.
void setMaximumTileExtentForTesting (uint32_t extent)
 Lower the working extent for deterministic tile-boundary tests.
void setChunkSubmittedHookForTesting (std::function< void(size_t)> hook)
 Invokes p hook after each accepted command chunk. Test seam for later-chunk failures.
bool recordPassesForTesting (size_t passCount, FilterTextureAllocator &textureAllocator, FrameCommandBufferSink *frameSink=nullptr)
 Records exactly p passCount transparent-clear passes through the chunking state machine.
FilterExecutionMemory lastExecutionMemory () const
 Observed allocation footprint of the most recent execution; does not own resources.

Friends

struct FilterResourceArena
struct FilterGraphExecution
struct FilterNodeExecution

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 context whose runtime device the engine records and submits through.
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 by resetting 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()

FilterExecutionResult donner::geode::GeodeFilterEngine::execute ( const svg::components::FilterGraph & graph,
const gpu::Texture & sourceGraphic,
const gpu::TextureDescriptor & sourceGraphicDesc,
const Box2d & filterRegion,
const Transform2d & deviceFromFilter,
FilterTextureAllocator & textureAllocator,
svg::components::FilterExecutionBudget * executionBudget = nullptr,
std::optional< FilterTilePlan > admittedPlan = std::nullopt,
FrameCommandBufferSink * frameSink = nullptr )

Execute a filter graph against the source-graphic texture.

The source texture must be sampled-capable. A FilterExecutionResult::Kind::Output result owns an RGBA8Unorm texture sized to the filter region (or the source dimensions if no region is given), which the caller releases through textureAllocator once the frame command buffer has submitted. Every intermediate the execution allocated is released back to textureAllocator before this call returns.

Filter compute, copy and clear commands are recorded into command-encoder chunks this execution owns. With a frame sink, each finished chunk joins the frame's single submission, so no chunk of the graph reaches the queue on its own and crossing the per-command-buffer pass bound costs a command buffer rather than a submission. Without one, each chunk is submitted as it closes. The caller restores its following frame encoder before compositing the result.

Parameters
graphThe filter graph to execute.
sourceGraphicThe input texture (layer snapshot), borrowed for the call.
sourceGraphicDescDescriptor sourceGraphic was allocated with; its extent, format and usage decide the working resolution and whether tiling can copy from the source.
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.
executionBudgetOptional shared per-frame budget. Direct callers may omit it to apply only the graph-local limit.
admittedPlanOptional immutable plan already reserved by the caller. Execution keeps this layout even if shared scratch state or planning preferences change. Invalid plans or failed execution-time budgets fail the execution instead of bypassing the filter.
frameSinkCollection point for the caller's open frame, or null when the execution submits on its own. When given, the caller must have closed its own recording into that frame before the call, so the source rendering this graph samples is ordered ahead of it.
Returns
The outcome of the execution; see FilterExecutionResult.

◆ executionPlan()

FilterTilePlan donner::geode::GeodeFilterEngine::executionPlan ( const svg::components::FilterGraph & graph,
uint32_t width,
uint32_t height,
const Transform2d & deviceFromFilter ) const

Plans bounded working textures without changing sample coordinates or resolution.

Parameters
graphGraph to execute.
widthSource width.
heightSource height.
deviceFromFilterOriginal filter-to-device transform.

◆ setMaximumTileExtentForTesting()

void donner::geode::GeodeFilterEngine::setMaximumTileExtentForTesting ( uint32_t extent)

Lower the working extent for deterministic tile-boundary tests.

Parameters
extentMaximum dimension, between 16 and 512 pixels.

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