[Bf-blender-cvs] [aeb42cf8ab2] master: Cycles/Optix: Support building the optix kernels on demand.

Ray Molenkamp noreply at git.blender.org
Sat Apr 11 20:59:28 CEST 2020


Commit: aeb42cf8ab2f9c8a7066748ff4889bc8a387dc0d
Author: Ray Molenkamp
Date:   Sat Apr 11 12:59:21 2020 -0600
Branches: master
https://developer.blender.org/rBaeb42cf8ab2f9c8a7066748ff4889bc8a387dc0d

Cycles/Optix: Support building the optix kernels on demand.

CMake: `WITH_CYCLES_DEVICE_OPTIX` did not respect `WITH_CYCLES_CUDA_BINARIES` causing the optix kernel to be always build at build time.

Code: `device_optix.cpp` did not count on the optix kernel not existing in the default location.

For this to work, one should have before starting blender

1) working nvcc environment
2) Optix SDK installed and the OPTIX_ROOT_DIR environment variable pointing to it which is not set by default

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

Reviewed By: Brecht

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

M	intern/cycles/device/device_optix.cpp
M	intern/cycles/kernel/CMakeLists.txt

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

diff --git a/intern/cycles/device/device_optix.cpp b/intern/cycles/device/device_optix.cpp
index 42d7b00314c..37d6ae3d041 100644
--- a/intern/cycles/device/device_optix.cpp
+++ b/intern/cycles/device/device_optix.cpp
@@ -383,7 +383,13 @@ class OptiXDevice : public CUDADevice {
 
     {  // Load and compile PTX module with OptiX kernels
       string ptx_data, ptx_filename = path_get("lib/kernel_optix.ptx");
-      if (use_adaptive_compilation()) {
+      if (use_adaptive_compilation() || path_file_size(ptx_filename) == -1) {
+        if (!getenv("OPTIX_ROOT_DIR")) {
+          set_error(
+              "OPTIX_ROOT_DIR environment variable not set, must be set with the path to the "
+              "Optix SDK in order to compile the Optix kernel on demand.");
+          return false;
+        }
         ptx_filename = compile_kernel(requested_features, "kernel_optix", "optix", true);
       }
       if (ptx_filename.empty() || !path_read_text(ptx_filename, ptx_data)) {
diff --git a/intern/cycles/kernel/CMakeLists.txt b/intern/cycles/kernel/CMakeLists.txt
index 3264b5afea2..ac3a85089c2 100644
--- a/intern/cycles/kernel/CMakeLists.txt
+++ b/intern/cycles/kernel/CMakeLists.txt
@@ -507,7 +507,7 @@ endif()
 
 # OptiX PTX modules
 
-if(WITH_CYCLES_DEVICE_OPTIX)
+if(WITH_CYCLES_DEVICE_OPTIX AND WITH_CYCLES_CUDA_BINARIES)
   foreach(input ${SRC_OPTIX_KERNELS})
     get_filename_component(input_we ${input} NAME_WE)
 
@@ -677,7 +677,7 @@ source_group("svm" FILES ${SRC_SVM_HEADERS})
 if(WITH_CYCLES_CUDA)
   add_dependencies(cycles_kernel cycles_kernel_cuda)
 endif()
-if(WITH_CYCLES_DEVICE_OPTIX)
+if(WITH_CYCLES_DEVICE_OPTIX AND WITH_CYCLES_CUDA_BINARIES)
   add_dependencies(cycles_kernel cycles_kernel_optix)
 endif()



More information about the Bf-blender-cvs mailing list