BLRuntimeScope Class Referencefinal

Blend2D runtime scope [C++ API].

Runtime scope is a totally optional feature that can be used by Blend2D to setup the current thread's control word in a way to make the behavior of some floating point computations consistent between platforms. Blend2D doesn't rely on any specific behavior, however, for testing purposes and possibly consistency of rendering across different architectures some setup may be necessary.

The runtime scope current only changes FPU control word in 32-bit x86 case to 64-bit precision. This means that if the FPU control word was set to 80-bits the precision of floating computations would be basically lowered, but this is necessary to make sure that intermediate computations match other platforms that don't have extended precision. Blend2D doesn't rely on extended precision in any way and this all is needed only if 100% consistency is required across different platforms.

At the moment BLRuntimeScope is only used by tests to ensure that we can compare reference implementation written in C++ with SIMD optimized implementation written either in C++ or generated at runtime (JIT).

As the name of the class suggests, BLRuntimeScope establishes a scope, so the FPU control word would only be changed temporarily within the life-time of the scope.

Example:

void do_something(BLImage& image) noexcept {
// Establishes a new scope by possibly changing the environment (FPU control word).
BLContext ctx(image);
// ... do something ...
// The scope ends here - the environment is restored.
}

Member Functions

Construction & Destruction
Accessors

Additional Inherited Members

- Public Attributes inherited from BLRuntimeScopeCore

Constructor & Destructor Documentation

BLRuntimeScope::BLRuntimeScope()◆ 

Establishes a new runtime scope by possibly changing the state of FPU control word.

BLRuntimeScope::~BLRuntimeScope()◆ 

Restores the scope to the previous state.