[Bf-blender-cvs] [25be02518ea] cycles-x: Cycle X: Make OptiX debug flag runtime

Sergey Sharybin noreply at git.blender.org
Thu May 27 16:35:18 CEST 2021


Commit: 25be02518eaf6975f182aa88d8a0b4e6bb35ef90
Author: Sergey Sharybin
Date:   Thu May 27 15:33:01 2021 +0200
Branches: cycles-x
https://developer.blender.org/rB25be02518eaf6975f182aa88d8a0b4e6bb35ef90

Cycle X: Make OptiX debug flag runtime

Allows to enable OptiX module debugging without having special build
of Blender.

Note that depending on compilation flags on developer environment this
could affect render times.

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

M	intern/cycles/blender/addon/properties.py
M	intern/cycles/blender/addon/ui.py
M	intern/cycles/blender/blender_python.cpp
M	intern/cycles/device/optix/device_impl.cpp
M	intern/cycles/util/util_debug.cpp
M	intern/cycles/util/util_debug.h

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

diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py
index a6d27b58f24..b8c99952066 100644
--- a/intern/cycles/blender/addon/properties.py
+++ b/intern/cycles/blender/addon/properties.py
@@ -699,6 +699,11 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
     debug_use_cuda_adaptive_compile: BoolProperty(name="Adaptive Compile", default=False)
 
     debug_optix_curves_api: BoolProperty(name="Native OptiX Curve Primitive", default=False)
+    debug_use_optix_debug: BoolProperty(
+        name="OptiX Module Debug",
+        description="Load OptiX module in debug mode: lower logging verbosity level, enable validations, and lower optimization level",
+        default=False
+    )
 
     debug_opencl_kernel_type: EnumProperty(
         name="OpenCL Kernel Type",
diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py
index 1f68e24c357..7a729e49167 100644
--- a/intern/cycles/blender/addon/ui.py
+++ b/intern/cycles/blender/addon/ui.py
@@ -1821,6 +1821,7 @@ class CYCLES_RENDER_PT_debug(CyclesDebugButtonsPanel, Panel):
         col = layout.column()
         col.label(text="OptiX Flags:")
         col.prop(cscene, "debug_optix_curves_api")
+        col.prop(cscene, "debug_use_optix_debug")
 
         col.separator()
 
diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp
index bc482de52d1..0301881607b 100644
--- a/intern/cycles/blender/blender_python.cpp
+++ b/intern/cycles/blender/blender_python.cpp
@@ -91,6 +91,7 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene)
   flags.cuda.adaptive_compile = get_boolean(cscene, "debug_use_cuda_adaptive_compile");
   /* Synchronize OptiX flags. */
   flags.optix.curves_api = get_boolean(cscene, "debug_optix_curves_api");
+  flags.optix.use_debug = get_boolean(cscene, "debug_use_optix_debug");
   /* Synchronize OpenCL device type. */
   switch (get_enum(cscene, "debug_opencl_device_type")) {
     case 0:
diff --git a/intern/cycles/device/optix/device_impl.cpp b/intern/cycles/device/optix/device_impl.cpp
index c759bd4f160..8e81a7133ab 100644
--- a/intern/cycles/device/optix/device_impl.cpp
+++ b/intern/cycles/device/optix/device_impl.cpp
@@ -87,8 +87,10 @@ OptiXDevice::OptiXDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
     }
   };
 #  endif
-#  if OPTIX_ABI_VERSION >= 41 && defined(WITH_CYCLES_DEBUG)
-  options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL;
+#  if OPTIX_ABI_VERSION >= 41
+  if (DebugFlags().optix.use_debug) {
+    options.validationMode = OPTIX_DEVICE_CONTEXT_VALIDATION_MODE_ALL;
+  }
 #  endif
   optix_assert(optixDeviceContextCreate(cuContext, &options, &context));
 #  ifdef WITH_CYCLES_LOGGING
@@ -218,14 +220,14 @@ bool OptiXDevice::load_kernels(const DeviceRequestedFeatures &requested_features
   OptixModuleCompileOptions module_options = {};
   module_options.maxRegisterCount = 0; /* Do not set an explicit register limit. */
 
-  /* TODO(sergey): Make it configurable via `DebugFlags` instead of compile-time. */
-#  ifdef WITH_CYCLES_DEBUG
-  module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_0;
-  module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
-#  else
-  module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
-  module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
-#  endif
+  if (DebugFlags().optix.use_debug) {
+    module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_0;
+    module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
+  }
+  else {
+    module_options.optLevel = OPTIX_COMPILE_OPTIMIZATION_LEVEL_3;
+    module_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
+  }
 
 #  if OPTIX_ABI_VERSION >= 41
   module_options.boundValues = nullptr;
@@ -425,12 +427,13 @@ bool OptiXDevice::load_kernels(const DeviceRequestedFeatures &requested_features
   OptixPipelineLinkOptions link_options = {};
   link_options.maxTraceDepth = 1;
 
-  /* TODO(sergey): Make it configurable via `DebugFlags` instead of compile-time. */
-#  ifdef WITH_CYCLES_DEBUG
-  link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
-#  else
-  link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
-#  endif
+  if (DebugFlags().optix.use_debug) {
+    link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_FULL;
+  }
+  else {
+    link_options.debugLevel = OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO;
+  }
+
 #  if OPTIX_ABI_VERSION < 24
   link_options.overrideUsesMotionBlur = motion_blur;
 #  endif
diff --git a/intern/cycles/util/util_debug.cpp b/intern/cycles/util/util_debug.cpp
index 10c836092e8..e07a10600c3 100644
--- a/intern/cycles/util/util_debug.cpp
+++ b/intern/cycles/util/util_debug.cpp
@@ -73,6 +73,7 @@ DebugFlags::OptiX::OptiX()
 void DebugFlags::OptiX::reset()
 {
   curves_api = false;
+  use_debug = false;
 }
 
 DebugFlags::OpenCL::OpenCL() : device_type(DebugFlags::OpenCL::DEVICE_ALL), debug(false)
@@ -137,7 +138,8 @@ std::ostream &operator<<(std::ostream &os, DebugFlagsConstRef debug_flags)
      << "  Adaptive Compile : " << string_from_bool(debug_flags.cuda.adaptive_compile) << "\n";
 
   os << "OptiX flags:\n"
-     << "  Curves API : " << debug_flags.optix.curves_api << "\n";
+     << "  Curves API : " << debug_flags.optix.curves_api << "\n"
+     << "  Debug : " << string_from_bool(debug_flags.optix.use_debug) << "\n";
 
   const char *opencl_device_type;
   switch (debug_flags.opencl.device_type) {
diff --git a/intern/cycles/util/util_debug.h b/intern/cycles/util/util_debug.h
index 2aac58ebf4a..135d45967a3 100644
--- a/intern/cycles/util/util_debug.h
+++ b/intern/cycles/util/util_debug.h
@@ -102,6 +102,10 @@ class DebugFlags {
 
     /* Use OptiX curves API for hair instead of custom implementation. */
     bool curves_api;
+
+    /* Load OptiX module with debug capabilities. Will lower logging verbosity level, enable
+     * validations, and lower optimization level. */
+    bool use_debug;
   };
 
   /* Descriptor of OpenCL feature-set to be used. */



More information about the Bf-blender-cvs mailing list