LunarG releases new RelaxedPrecision white paper for SPIR-V developers. This functionality is available along with the Vulkan 220.127.116.11 SDK release. Read on for more information about this new feature or read the details in the Automatic Relaxed Precision Decoration and Conversion in Spirv-opt white paper.
Two new passes have been added to spirv-opt to automatically convert SPIR-V shaders to utilize RelaxedPrecision semantics. These passes allow the developer to take advantage of lower precision computations without having to make changes to the shader source. The first pass can be used to automatically convert a whole SPIR-V shader to use RelaxedPrecision, which can be advantageous on both mobile and desktop GPUs. The second pass can be used to automatically convert a RelaxedPrecision-decorated shader to explicitly use 16-bit precision on devices which do not support RelaxedPrecision, but do support the VK_KHR_shader_float16_int8 extension, such as iOS/MoltenVK.
When a 32-bit floating point (float32) SPIR-V executable instruction is decorated with RelaxedPrecision, the result is still a float32 value, but the driver has permission to only compute 16-bits of precision. This can improve performance and/or reduce power consumption if the application does not require the full precision for that instruction.
However, some Vulkan drivers such as MoltenVK ignore the RelaxedPrecision directive, usually because the underlying implementation (in the case of MoltenVK, Metal), does not support the RelaxedPrecision semantics.
If it is the situation, however, that the underlying implementation does support a true 16-bit floating point type (as it is with Metal), benefits of RelaxedPrecision semantics can be achieved by emulating the RelaxedPrecision instructions using the true 16-bit instructions.
To this end, the –convert-relaxed-to-half pass has been added to spirv-opt. This pass translates all arithmetic float32 instructions decorated with RelaxedPrecision to 16-bit floating point (float16) instructions, adding additional conversion instructions for operands and results where needed.
The –relax-float-ops pass was also added to allow the user to quickly and easily apply the RelaxPrecision decoration to all float32 instructions in a SPIR-V file.
Info about LunarG, Inc.
LunarG’s software engineering experts create software solutions for open source and commercial customers using leading-edge 3D graphics and compute technologies, including Vulkan, OpenXR, SPIR-V, and OpenGL. We have strengths in performance analysis and tuning, runtime and tools development, shader optimizations, driver development, new feature development, and porting engines and applications to Vulkan. Our software engineering team is based in Fort Collins, Colorado. LunarG was founded by software experts who are passionate about 3D graphics.
For more information about LunarG, check out our website.