Cycles: use safe compiler flags for OpenCL.
authorHristo Gueorguiev <prem.nirved@gmail.com>
Tue, 25 Apr 2017 18:10:51 +0000 (20:10 +0200)
committerHristo Gueorguiev <prem.nirved@gmail.com>
Tue, 25 Apr 2017 18:10:51 +0000 (20:10 +0200)
Using -cl-fast-relaxed-math assumes no NaN/Inf values in any expression.
This causes problems on overflow, division by zero, square root of negative number.
Comparisons with NaN or infinite value are affected as well.

This patch causes <2% slowdown on benchmark scenes.

Fix T50985: Rendering volume scatter with GPU OpenCL comes to an halt after a few seconds

intern/cycles/device/opencl/opencl_base.cpp

index 52d0662a8e3d67a2cbdc2cf860a4a25f237f2523..22aeaddcde85e410ef67df1db842cc8fa59b5006 100644 (file)
@@ -612,7 +612,7 @@ void OpenCLDeviceBase::shader(DeviceTask& task)
 
 string OpenCLDeviceBase::kernel_build_options(const string *debug_src)
 {
-       string build_options = "-cl-fast-relaxed-math ";
+       string build_options = "-cl-no-signed-zeros -cl-mad-enable ";
 
        if(platform_name == "NVIDIA CUDA") {
                build_options += "-D__KERNEL_OPENCL_NVIDIA__ "