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

The color-matrix compute program, expressed in the donner::gpu::shader IR. More...

Include dependency graph for ColorMatrix.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::ColorMatrixBinding : uint32_t {
  InputTexture = 0 ,
  OutputTexture = 1 ,
  Params = 2 ,
  Bias = 3
}
 Bind group indices of the color-matrix compute program, shared by the IR builder and every host that creates its bind group layout. More...

Functions

ShaderResult< IrModuledonner::gpu::shader::programs::BuildColorMatrixModule ()
 Builds the color-matrix compute program: one @compute @workgroup_size(8, 8, 1) entry point named cs_main that reads one texel of a sampled texture, multiplies it by a 4x4 matrix from a uniform buffer, adds a bias vector selected per texel from a read-only storage buffer, saturates the result, and writes it to a write-only storage texture.

Variables

constexpr uint32_t donner::gpu::shader::programs::kColorMatrixWorkgroupSize = 8
 Workgroup size the color-matrix entry point declares. Hosts divide the destination extent by this to compute dispatch counts.
constexpr uint32_t donner::gpu::shader::programs::kColorMatrixBiasCount = 2
 Number of bias vectors the storage buffer must hold.

Detailed Description

The color-matrix compute program, expressed in the donner::gpu::shader IR.

Enumeration Type Documentation

◆ ColorMatrixBinding

Bind group indices of the color-matrix 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 five vec4f: the four per-input-channel multiplier columns and the constant offset column added after them.

Bias 

Read-only storage buffer of per-checker bias vectors.

Function Documentation

◆ BuildColorMatrixModule()

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

Builds the color-matrix compute program: one @compute @workgroup_size(8, 8, 1) entry point named cs_main that reads one texel of a sampled texture, multiplies it by a 4x4 matrix from a uniform buffer, adds a bias vector selected per texel from a read-only storage buffer, saturates the result, and writes it to a write-only storage texture.

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