[Bf-blender-cvs] [6d137fd489c] cycles_path_guiding: Guiding: Adding functionality to automatically check if at least SIMD4 support is available to activate guiding

Sebastian Herholz noreply at git.blender.org
Tue Sep 6 20:07:56 CEST 2022


Commit: 6d137fd489c11f6c814d88b8d407e83fe65131c4
Author: Sebastian Herholz
Date:   Tue Sep 6 20:07:37 2022 +0200
Branches: cycles_path_guiding
https://developer.blender.org/rB6d137fd489c11f6c814d88b8d407e83fe65131c4

Guiding: Adding functionality to automatically check if at least SIMD4 support is available to activate guiding

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

M	intern/cycles/blender/python.cpp
M	intern/cycles/device/cpu/device.cpp
M	intern/cycles/device/cpu/device_impl.cpp
M	intern/cycles/util/CMakeLists.txt
A	intern/cycles/util/guiding.h

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

diff --git a/intern/cycles/blender/python.cpp b/intern/cycles/blender/python.cpp
index ee5b106261c..32fc2496954 100644
--- a/intern/cycles/blender/python.cpp
+++ b/intern/cycles/blender/python.cpp
@@ -15,6 +15,7 @@
 
 #include "util/debug.h"
 #include "util/foreach.h"
+#include "util/guiding.h"
 #include "util/log.h"
 #include "util/md5.h"
 #include "util/opengl.h"
@@ -1008,13 +1009,14 @@ void *CCL_python_module_init()
   PyModule_AddStringConstant(mod, "osl_version_string", "unknown");
 #endif
 
-#ifdef WITH_PATH_GUIDING
+if (ccl::guiding_supported()) {
   PyModule_AddObject(mod, "with_path_guiding", Py_True);
   Py_INCREF(Py_True);
-#else  /* WITH_PATH_GUIDING */
+}
+else {
   PyModule_AddObject(mod, "with_path_guiding", Py_False);
   Py_INCREF(Py_False);
-#endif /* WITH_PATH_GUIDING */
+}
 
 #ifdef WITH_EMBREE
   PyModule_AddObject(mod, "with_embree", Py_True);
diff --git a/intern/cycles/device/cpu/device.cpp b/intern/cycles/device/cpu/device.cpp
index 9505bf1a956..779ff1efae5 100644
--- a/intern/cycles/device/cpu/device.cpp
+++ b/intern/cycles/device/cpu/device.cpp
@@ -8,6 +8,7 @@
 /* TODO(sergey): The denoisers are probably to be moved completely out of the device into their
  * own class. But until then keep API consistent with how it used to work before. */
 #include "util/openimagedenoise.h"
+#include "util/guiding.h"
 
 CCL_NAMESPACE_BEGIN
 
@@ -27,11 +28,12 @@ void device_cpu_info(vector<DeviceInfo> &devices)
   info.has_osl = true;
   info.has_nanovdb = true;
   info.has_profiling = true;
-#ifdef WITH_PATH_GUIDING
-  info.has_guiding = true;
-#else
-  info.has_guiding = false;
-#endif
+  if(guiding_supported()) {
+    info.has_guiding = true;
+  }
+  else {
+    info.has_guiding = false;
+  }
   if (openimagedenoise_supported()) {
     info.denoisers |= DENOISER_OPENIMAGEDENOISE;
   }
diff --git a/intern/cycles/device/cpu/device_impl.cpp b/intern/cycles/device/cpu/device_impl.cpp
index d89aea2c0e7..642c68df64e 100644
--- a/intern/cycles/device/cpu/device_impl.cpp
+++ b/intern/cycles/device/cpu/device_impl.cpp
@@ -287,9 +287,18 @@ void *CPUDevice::get_guiding_device() const
 {
 #ifdef WITH_PATH_GUIDING
   if (!guiding_device) {
-    // TODO(sherholz): we need to replace this with PGL_DEVICE_TYPE_CPU_AUTO
-    guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_4);
+#if defined(__ARM_NEON)
+    guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_8);
+#else
+    if(system_cpu_support_avx2()) {
+      guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_8);
+    } else if(system_cpu_support_sse41()) {
+      guiding_device = make_unique<openpgl::cpp::Device>(PGL_DEVICE_TYPE_CPU_4);
+    } else {
+      guiding_device = nullptr;
+    }
   }
+#endif
   return guiding_device.get();
 #else
   return nullptr;
diff --git a/intern/cycles/util/CMakeLists.txt b/intern/cycles/util/CMakeLists.txt
index 997d574a3b0..57628f99e35 100644
--- a/intern/cycles/util/CMakeLists.txt
+++ b/intern/cycles/util/CMakeLists.txt
@@ -49,6 +49,7 @@ set(SRC_HEADERS
   foreach.h
   function.h
   guarded_allocator.h
+  guiding.h
   half.h
   hash.h
   ies.h
diff --git a/intern/cycles/util/guiding.h b/intern/cycles/util/guiding.h
new file mode 100644
index 00000000000..d22cc3d4aa4
--- /dev/null
+++ b/intern/cycles/util/guiding.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: Apache-2.0
+ * Copyright 2022 Blender Foundation */
+
+#ifndef __UTIL_GUIDING_H__
+#define __UTIL_GUIDING_H__
+
+#include "util/system.h"
+
+CCL_NAMESPACE_BEGIN
+
+static inline bool guiding_supported()
+{
+#ifdef WITH_PATH_GUIDING
+#if defined(__ARM_NEON)
+    return true;
+#else
+    return system_cpu_support_sse41();
+#endif
+#else
+    return false;
+#endif
+}
+
+CCL_NAMESPACE_END
+
+#endif /* __UTIL_GUIDING_H__ */



More information about the Bf-blender-cvs mailing list