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

The round-half-away-from-zero recipe, as a function any IR program can declare. More...

#include <string_view>
#include "donner/gpu/shader/IrModule.h"
Include dependency graph for RoundHalfAwayFromZero.h:

Namespaces

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

Functions

ShaderStatus donner::gpu::shader::programs::AddRoundHalfAwayFromZero (ModuleBuilder &builder)
 Declares round_half_away_from_zero(x: f32) -> f32 on builder, ready to be called by name.

Variables

constexpr std::string_view donner::gpu::shader::programs::kRoundHalfAwayFromZeroName = "round_half_away_from_zero"
 Name the recipe is declared under, spelled the same by every module that declares it.

Detailed Description

The round-half-away-from-zero recipe, as a function any IR program can declare.

WGSL's round is round-half-to-even, so it disagrees with the CPU filter path's std::round on exact half values. Comparing the fractional magnitude with 0.5 avoids rounding the preceding representable value upward while computing the rounding decision.

Function Documentation

◆ AddRoundHalfAwayFromZero()

ShaderStatus donner::gpu::shader::programs::AddRoundHalfAwayFromZero ( ModuleBuilder & builder)

Declares round_half_away_from_zero(x: f32) -> f32 on builder, ready to be called by name.

Declare it before the function that calls it: a module emits its functions in declaration order, and a call to a function declared later would not compile.

Parameters
builderModule to declare the function on.