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

Caches the compiled render pipeline that draws the transparency checkerboard behind see-through document regions, plus its bind group layout. More...

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

Classes

struct  Uniforms
 Uniform block consumed by the checkerboard shader. More...

Public Types

enum class  BlendMode {
  Replace ,
  DestinationOver
}
 How the emitted checkerboard combines with whatever is already in the target. More...

Public Member Functions

 GeodeCheckerboardPipeline (GeodeWgpuAdapterDevice &adapterDevice, gpu::TextureFormat colorFormat, BlendMode blendMode=BlendMode::Replace)
 Create the checkerboard pipeline for the given device and target format.
 GeodeCheckerboardPipeline (const GeodeCheckerboardPipeline &)=delete
GeodeCheckerboardPipelineoperator= (const GeodeCheckerboardPipeline &)=delete
 GeodeCheckerboardPipeline (GeodeCheckerboardPipeline &&) noexcept=default
 Move constructor.
GeodeCheckerboardPipelineoperator= (GeodeCheckerboardPipeline &&) noexcept=default
 Move assignment operator.
bool valid () const
 True when the shader, bind group layout, and pipeline all compiled.
const gpu::RenderPipelinepipeline () const
 The compiled render pipeline.
const gpu::BindGroupLayoutbindGroupLayout () const
 Bind group layout used by the pipeline.

Detailed Description

Caches the compiled render pipeline that draws the transparency checkerboard behind see-through document regions, plus its bind group layout.

Owned by GeodeDevice (lazily, via GeodeDevice::checkerboardPipeline() and GeodeDevice::checkerboardUnderlayPipeline()) so every consumer sharing the device reuses one compiled pipeline per blend mode - the backend retains every pipeline ever constructed, so per-consumer construction leaks (issue #575).

Bind group layout:

The pipeline takes no vertex buffer - the shader emits a fullscreen triangle from @builtin(vertex_index). A draw call is pass.draw(3, 1, 0, 0). The caller owns its uniform buffer and bind group; Uniforms pins the layout contract between the two.


Class Documentation

◆ donner::geode::GeodeCheckerboardPipeline::Uniforms

struct donner::geode::GeodeCheckerboardPipeline::Uniforms

Uniform block consumed by the checkerboard shader.

Class Members
float checkerSize Checker cell size in logical pixels.
float darkColor[4] RGBA for odd cells.
float devicePixelRatio Device pixels per logical pixel.
float lightColor[4] RGBA for even cells.
float originOffsetPx[2] Device-pixel offset of the target's top-left from the anchor.
float padding[2] WGSL uniform struct tail padding; must be zero.
float targetSize[2] Render-target size in device pixels.

Member Enumeration Documentation

◆ BlendMode

How the emitted checkerboard combines with whatever is already in the target.

Enumerator
Replace 

Overwrite the target.

Used when the checkerboard is drawn first, before any document pixels land on top of it, which is what the editor's window framebuffer does.

DestinationOver 

Composite the checkerboard under the target's existing premultiplied content: result = dst + checker * (1 - dst.alpha).

For a target that already holds composed document pixels, where the checkerboard has to fill whatever alpha they left behind instead of going in first.

Constructor & Destructor Documentation

◆ GeodeCheckerboardPipeline()

donner::geode::GeodeCheckerboardPipeline::GeodeCheckerboardPipeline ( GeodeWgpuAdapterDevice & adapterDevice,
gpu::TextureFormat colorFormat,
BlendMode blendMode = BlendMode::Replace )

Create the checkerboard pipeline for the given device and target format.

Parameters
adapterDeviceThe Donner GPU device owned by the GeodeDevice.
colorFormatThe pixel format of the render target this pipeline will draw into. Must match the target texture's format at draw time.
blendModeHow the emitted checkerboard combines with the target.

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