Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
SubregionClip.h File Reference

The subregion-clip compute program, expressed in the donner::gpu::shader IR. More...

Include dependency graph for SubregionClip.h:

Namespaces

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

Enumerations

enum class  donner::gpu::shader::programs::SubregionClipBinding : uint32_t {
  InputTexture = 0 ,
  OutputTexture = 1 ,
  Params = 2
}
 Bind group indices of the subregion-clip compute program, shared by the IR builder and every host that creates its bind group layout. More...

Functions

ShaderResult< IrModuledonner::gpu::shader::programs::BuildSubregionClipModule ()
 Builds the subregion-clip compute program: one @compute @workgroup_size(8, 8, 1) entry point named cs_main that copies texels inside a rectangle and writes transparent black outside it.

Variables

constexpr uint32_t donner::gpu::shader::programs::kSubregionClipWorkgroupSize = 8
 Workgroup size the subregion-clip entry point declares. Hosts divide the destination extent by this to compute dispatch counts.

Detailed Description

The subregion-clip compute program, expressed in the donner::gpu::shader IR.

Enumeration Type Documentation

◆ SubregionClipBinding

Bind group indices of the subregion-clip compute program, shared by the IR builder and every host that creates its bind group layout.

Enumerator
InputTexture 

Sampled texture_2d<f32> source.

OutputTexture 

texture_storage_2d<rgba8unorm, write> destination.

Params 

Uniform buffer holding the inverse transform and the user-space rectangle to keep.

Function Documentation

◆ BuildSubregionClipModule()

ShaderResult< IrModule > donner::gpu::shader::programs::BuildSubregionClipModule ( )

Builds the subregion-clip compute program: one @compute @workgroup_size(8, 8, 1) entry point named cs_main that copies texels inside a rectangle and writes transparent black outside it.

The rectangle is axis-aligned in user space, not in the destination's pixel space, so the test runs on the pixel center mapped back through the uniform's inverse transform. That is what makes the clip correct under a rotated transform, where a pixel-space rectangle would not describe the same region. The rectangle is half-open on both axes: a coordinate equal to the low edge is inside, one equal to the high edge is outside, so abutting subregions neither overlap nor leave a seam.

Invocations outside the destination extent return without writing, so a dispatch rounded up to whole workgroups is safe.