PDA

View Full Version : Log for double precision shaders?



TG1234
09-01-2016, 08:33 PM
Are there any solutions for log support under double pecision shaders?
I converted a single precision float shader to double precision double shader, but it doesn't accept some calls to log I have in it.

GClements
09-01-2016, 10:50 PM
Are there any solutions for log support under double pecision shaders?
Convert the argument to float or write your own double-precision log() function. The latter option is likely to be quite slow, and you can't reasonably leverage the single-precision log() function because it's only accurate to 3 ULP.

The transcendental functions in sections 8.1 (Angle and Trigonometry Functions) and 8.2 (Exponential Functions) don't support the use of double-precision types, other than for sqrt() and inversesqrt().

TG1234
09-02-2016, 03:14 AM
Convert the argument to float

Thanks! That was the trick. Luckily for me the shader code using the log call was still OK with float precision.

For anyone else this means in the double precision shader rather than using doublevar1=log(doublevar2) you can use singlevar1=log(float(doublevar2))