[Bf-blender-cvs] [b9ed30c25c7] master: Cycles: OpenCL Separate Compilation Debug Flag

Jeroen Bakker noreply at git.blender.org
Fri Aug 30 13:54:01 CEST 2019


Commit: b9ed30c25c703c479dddab1ad6fec2adba558335
Author: Jeroen Bakker
Date:   Thu Aug 29 12:32:27 2019 +0200
Branches: master
https://developer.blender.org/rBb9ed30c25c703c479dddab1ad6fec2adba558335

Cycles: OpenCL Separate Compilation Debug Flag

OpenCL Parallel compilation only works inside Blender. When using cycles in a different setup (standaline or other software) it failed compiling kernels as they don't have the appropriate Python API and command line arguments.

This change introduces a `running_inside_blender` debug flag, that triggers out of process compilation of the kernels. Compilation still happens in subthread that enabled the preview kernels and compilation of the kernels during BVH building

Reviewed By: brecht

Differential Revision: https://developer.blender.org/D5439

===================================================================

M	intern/cycles/blender/CMakeLists.txt
M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/device/opencl/opencl_split.cpp
M	intern/cycles/device/opencl/opencl_util.cpp
M	intern/cycles/util/util_debug.cpp
M	intern/cycles/util/util_debug.h

===================================================================

diff --git a/intern/cycles/blender/CMakeLists.txt b/intern/cycles/blender/CMakeLists.txt
index 7354b1e615e..9658c7b4a62 100644
--- a/intern/cycles/blender/CMakeLists.txt
+++ b/intern/cycles/blender/CMakeLists.txt
@@ -68,7 +68,7 @@ set(ADDON_FILES
 add_definitions(${GL_DEFINITIONS})
 
 if(WITH_CYCLES_DEVICE_OPENCL)
-    add_definitions(-DWITH_OPENCL)
+  add_definitions(-DWITH_OPENCL)
 endif()
 
 if(WITH_CYCLES_NETWORK)
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index 80c6fee9723..9753da71eb4 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -177,6 +177,8 @@ static PyObject *init_func(PyObject * /*self*/, PyObject *args)
 
   BlenderSession::headless = headless;
 
+  DebugFlags().running_inside_blender = true;
+
   VLOG(2) << "Debug flags initialized to:\n" << DebugFlags();
 
   Py_RETURN_NONE;
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index 79474fb0814..eea5cf2fb8a 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -676,7 +676,7 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
   device_initialized = true;
 
   split_kernel = new OpenCLSplitKernel(this);
-  if (!background) {
+  if (use_preview_kernels) {
     load_preview_kernels();
   }
 }
diff --git a/intern/cycles/device/opencl/opencl_util.cpp b/intern/cycles/device/opencl/opencl_util.cpp
index dc9b4072841..3eeff31f8c2 100644
--- a/intern/cycles/device/opencl/opencl_util.cpp
+++ b/intern/cycles/device/opencl/opencl_util.cpp
@@ -619,15 +619,16 @@ void OpenCLDevice::OpenCLProgram::compile()
       debug_src = &clsrc;
     }
 
-    /* If binary kernel exists already, try use it. */
-    if (compile_separate(clbin)) {
+    if (DebugFlags().running_inside_blender && compile_separate(clbin)) {
       add_log(string("Built and loaded program from ") + clbin + ".", true);
       loaded = true;
     }
     else {
-      add_log(string("Separate-process building of ") + clbin +
-                  " failed, will fall back to regular building.",
-              true);
+      if (DebugFlags().running_inside_blender) {
+        add_log(string("Separate-process building of ") + clbin +
+                    " failed, will fall back to regular building.",
+                true);
+      }
 
       /* If does not exist or loading binary failed, compile kernel. */
       if (!compile_kernel(debug_src)) {
diff --git a/intern/cycles/util/util_debug.cpp b/intern/cycles/util/util_debug.cpp
index aabfea7fc49..e52fda26845 100644
--- a/intern/cycles/util/util_debug.cpp
+++ b/intern/cycles/util/util_debug.cpp
@@ -120,7 +120,7 @@ void DebugFlags::OpenCL::reset()
   debug = (getenv("CYCLES_OPENCL_DEBUG") != NULL);
 }
 
-DebugFlags::DebugFlags() : viewport_static_bvh(false)
+DebugFlags::DebugFlags() : viewport_static_bvh(false), running_inside_blender(false)
 {
   /* Nothing for now. */
 }
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index 83d9e96ffa5..5b0004ea768 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -33,6 +33,8 @@ class DebugFlags {
   /* Use static BVH in viewport, to match final render exactly. */
   bool viewport_static_bvh;
 
+  bool running_inside_blender;
+
   /* Descriptor of CPU feature-set to be used. */
   struct CPU {
     CPU();



More information about the Bf-blender-cvs mailing list