|
ftz 0.0.1
Fast, reproducible floating-point arithmetic
|
The HLSL 2021 headers provide FTZ arithmetic for shaders, with the same rounding and flushing rules as the C++ types. Compile with DXC to SPIR-V for Vulkan, or translate that SPIR-V to Metal with SPIRV-Cross. Check the compiled shader on the device before selecting hardware flushing; CPU settings do not configure it.
find_package(ftz CONFIG REQUIRED COMPONENTS hlsl) supplies ftz::hlsl, its public shader include directories, and the native::headers dependency. Configure FTZ_BUILD_HOST=OFF to install these without a host compiler. Consumers own shader entry points and compiler invocations; ftz::hlsl is a header library.
HLSL includes <ftz/ftz32.h> and uses ftz::ftz32. Compile in HLSL 2021 mode. ftz::floor, ftz::ceil and ftz::trunc use the corresponding shader intrinsics and preserve the wrapper type without an additional normalization pass. FTZ_FP32_HARDWARE_FTZ=0 retains explicit normalization; =1 selects the admitted hardware path. Choose the compiled shader variant after device qualification, including signed tiny-result add/subtract checks. The hardware path uses native addition/subtraction directly; a failed raw sign check requires the explicit variant. Shader policy selection is independent of the CPU type and thread environment. FTZ_SHADER_INT64 selects native 64-bit integer support where available, with 32-bit word operations as the portable alternative.
The complete shader example shows the public factories and a compute entry point. The installed shader consumer checks exported include roots and header dependency tracking after relocation.
DXC compilation, SPIR-V validation and SPIRV-Cross translation establish a compiler path. The validation guide describes the separate numerical device checks, guards and permitted differences. Translation alone does not establish correct execution or throughput on a GPU.