OSDN Git Service

compiler/spirv: use 32-bit polynomial approximation for 16-bit asin()
authorIago Toral Quiroga <itoral@igalia.com>
Thu, 31 May 2018 08:34:03 +0000 (10:34 +0200)
committerIago Toral Quiroga <itoral@igalia.com>
Wed, 2 Jan 2019 06:54:39 +0000 (07:54 +0100)
commitec79069856b05840630da3a2612fdb9ce1debb82
tree867f8a070a503835feb80fbf45afe29854fc0b82
parentfda3f6d4243468dd66f5ec01e69ced538d73af2e
compiler/spirv: use 32-bit polynomial approximation for 16-bit asin()

The 16-bit polynomial execution doesn't meet Khronos precision requirements.
Also, the half-float denorm range starts at 2^(-14) and with asin taking input
values in the range [0, 1], polynomial approximations can lead to flushing
relatively easy.

An alternative is to use the atan2 formula to compute asin, which is the
reference taken by Khronos to determine precision requirements, but that
ends up generating too many additional instructions when compared to the
polynomial approximation. Specifically, for the Intel case, doing this
adds +41 instructions to the program for each asin/acos call, which looks
like an undesirable trade off.

So for now we take the easy way out and fallback to using the 32-bit
polynomial approximation, which is better (faster) than the 16-bit atan2
implementation and gives us better precision that matches Khronos
requirements.

v2:
 - Fallback to 32-bit using recursion (Jason).

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/spirv/vtn_glsl450.c