[Bf-blender-cvs] [3e472d87a8d] blender-v2.93-release: Cycles OpenCL: disable AO preview kernels

Brecht Van Lommel noreply at git.blender.org
Wed May 19 18:33:10 CEST 2021


Commit: 3e472d87a8d13aee078e156d584cf2171ed2d8a3
Author: Brecht Van Lommel
Date:   Wed May 19 00:14:23 2021 +0200
Branches: blender-v2.93-release
https://developer.blender.org/rB3e472d87a8d13aee078e156d584cf2171ed2d8a3

Cycles OpenCL: disable AO preview kernels

These seem to be causing some stability issues, and really are just not that
useful in practice. Compiling them is slow already, so it does not improve
the user experience much to show an AO preview if it's not nearly instant.

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

M	intern/cycles/device/device.h
M	intern/cycles/device/device_multi.cpp
M	intern/cycles/device/opencl/device_opencl.h
M	intern/cycles/device/opencl/device_opencl_impl.cpp
M	intern/cycles/kernel/kernel_types.h
M	intern/cycles/render/scene.cpp
M	intern/cycles/render/session.cpp

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

diff --git a/intern/cycles/device/device.h b/intern/cycles/device/device.h
index b5468248e5a..3c697b350a2 100644
--- a/intern/cycles/device/device.h
+++ b/intern/cycles/device/device.h
@@ -61,7 +61,6 @@ enum DeviceTypeMask {
 };
 
 enum DeviceKernelStatus {
-  DEVICE_KERNEL_WAITING_FOR_FEATURE_KERNEL = 0,
   DEVICE_KERNEL_FEATURE_KERNEL_AVAILABLE,
   DEVICE_KERNEL_USING_FEATURE_KERNEL,
   DEVICE_KERNEL_FEATURE_KERNEL_INVALID,
diff --git a/intern/cycles/device/device_multi.cpp b/intern/cycles/device/device_multi.cpp
index 35faadcbec5..85ffa5fcd52 100644
--- a/intern/cycles/device/device_multi.cpp
+++ b/intern/cycles/device/device_multi.cpp
@@ -232,10 +232,6 @@ class MultiDevice : public Device {
     foreach (SubDevice &sub, devices) {
       DeviceKernelStatus subresult = sub.device->get_active_kernel_switch_state();
       switch (subresult) {
-        case DEVICE_KERNEL_WAITING_FOR_FEATURE_KERNEL:
-          result = subresult;
-          break;
-
         case DEVICE_KERNEL_FEATURE_KERNEL_INVALID:
         case DEVICE_KERNEL_FEATURE_KERNEL_AVAILABLE:
           return subresult;
diff --git a/intern/cycles/device/opencl/device_opencl.h b/intern/cycles/device/opencl/device_opencl.h
index 2d6c6d04214..a65e764b0d4 100644
--- a/intern/cycles/device/opencl/device_opencl.h
+++ b/intern/cycles/device/opencl/device_opencl.h
@@ -269,7 +269,6 @@ class OpenCLDevice : public Device {
   cl_device_id cdDevice;
   cl_int ciErr;
   int device_num;
-  bool use_preview_kernels;
 
   class OpenCLProgram {
    public:
@@ -369,8 +368,7 @@ class OpenCLDevice : public Device {
     /* Load the kernels and put the created kernels in the given
      * `programs` parameter. */
     void load_kernels(vector<OpenCLProgram *> &programs,
-                      const DeviceRequestedFeatures &requested_features,
-                      bool is_preview = false);
+                      const DeviceRequestedFeatures &requested_features);
   };
 
   DeviceSplitKernel *split_kernel;
@@ -382,7 +380,6 @@ class OpenCLDevice : public Device {
   OpenCLProgram denoising_program;
 
   OpenCLSplitPrograms kernel_programs;
-  OpenCLSplitPrograms preview_programs;
 
   typedef map<string, device_vector<uchar> *> ConstMemMap;
   typedef map<string, device_ptr> MemMap;
@@ -412,7 +409,6 @@ class OpenCLDevice : public Device {
   string device_md5_hash(string kernel_custom_build_options = "");
   bool load_kernels(const DeviceRequestedFeatures &requested_features);
   void load_required_kernels(const DeviceRequestedFeatures &requested_features);
-  void load_preview_kernels();
 
   bool wait_for_availability(const DeviceRequestedFeatures &requested_features);
   DeviceKernelStatus get_active_kernel_switch_state();
@@ -422,8 +418,7 @@ class OpenCLDevice : public Device {
   /* Get the program file name to compile (*.cl) for the given kernel */
   const string get_opencl_program_filename(const string &kernel_name);
   string get_build_options(const DeviceRequestedFeatures &requested_features,
-                           const string &opencl_program_name,
-                           bool preview_kernel = false);
+                           const string &opencl_program_name);
   /* Enable the default features to reduce recompilation events */
   void enable_default_features(DeviceRequestedFeatures &features);
 
diff --git a/intern/cycles/device/opencl/device_opencl_impl.cpp b/intern/cycles/device/opencl/device_opencl_impl.cpp
index b1d6284171a..715213175c9 100644
--- a/intern/cycles/device/opencl/device_opencl_impl.cpp
+++ b/intern/cycles/device/opencl/device_opencl_impl.cpp
@@ -107,8 +107,7 @@ void OpenCLDevice::enable_default_features(DeviceRequestedFeatures &features)
 }
 
 string OpenCLDevice::get_build_options(const DeviceRequestedFeatures &requested_features,
-                                       const string &opencl_program_name,
-                                       bool preview_kernel)
+                                       const string &opencl_program_name)
 {
   /* first check for non-split kernel programs */
   if (opencl_program_name == "base" || opencl_program_name == "denoising") {
@@ -185,13 +184,7 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures &requested_
   enable_default_features(nofeatures);
 
   /* Add program specific optimized compile directives */
-  if (preview_kernel) {
-    DeviceRequestedFeatures preview_features;
-    preview_features.use_hair = true;
-    build_options += "-D__KERNEL_AO_PREVIEW__ ";
-    build_options += preview_features.get_build_options();
-  }
-  else if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) {
+  if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) {
     build_options += nofeatures.get_build_options();
   }
   else {
@@ -238,9 +231,7 @@ OpenCLDevice::OpenCLSplitPrograms::~OpenCLSplitPrograms()
 }
 
 void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
-    vector<OpenCLProgram *> &programs,
-    const DeviceRequestedFeatures &requested_features,
-    bool is_preview)
+    vector<OpenCLProgram *> &programs, const DeviceRequestedFeatures &requested_features)
 {
   if (!requested_features.use_baking) {
 #  define ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(kernel_name) \
@@ -251,7 +242,7 @@ void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
         device, \
         program_name_##kernel_name, \
         "kernel_" #kernel_name ".cl", \
-        device->get_build_options(requested_features, program_name_##kernel_name, is_preview)); \
+        device->get_build_options(requested_features, program_name_##kernel_name)); \
     program_##kernel_name.add_kernel(ustring("path_trace_" #kernel_name)); \
     programs.push_back(&program_##kernel_name);
 
@@ -259,7 +250,7 @@ void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
     ADD_SPLIT_KERNEL_PROGRAM(subsurface_scatter);
     ADD_SPLIT_KERNEL_PROGRAM(direct_lighting);
     ADD_SPLIT_KERNEL_PROGRAM(indirect_background);
-    if (requested_features.use_volume || is_preview) {
+    if (requested_features.use_volume) {
       ADD_SPLIT_KERNEL_PROGRAM(do_volume);
     }
     ADD_SPLIT_KERNEL_PROGRAM(shader_eval);
@@ -274,7 +265,7 @@ void OpenCLDevice::OpenCLSplitPrograms::load_kernels(
         device,
         "split_bundle",
         "kernel_split_bundle.cl",
-        device->get_build_options(requested_features, "split_bundle", is_preview));
+        device->get_build_options(requested_features, "split_bundle"));
 
     ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(data_init);
     ADD_SPLIT_KERNEL_BUNDLE_PROGRAM(state_buffer_size);
@@ -403,7 +394,7 @@ class OpenCLSplitKernel : public DeviceSplitKernel {
         device,
         program_name,
         device->get_opencl_program_filename(kernel_name),
-        device->get_build_options(requested_features, program_name, device->use_preview_kernels));
+        device->get_build_options(requested_features, program_name));
 
     kernel->program.add_kernel(ustring("path_trace_" + kernel_name));
     kernel->program.load();
@@ -617,7 +608,6 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
     : Device(info, stats, profiler, background),
       load_kernel_num_compiling(0),
       kernel_programs(this),
-      preview_programs(this),
       memory_manager(this),
       texture_info(this, "__texture_info", MEM_GLOBAL)
 {
@@ -627,7 +617,6 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
   cqCommandQueue = NULL;
   device_initialized = false;
   textures_need_update = true;
-  use_preview_kernels = !background;
 
   vector<OpenCLPlatformDevice> usable_devices;
   OpenCLInfo::get_usable_devices(&usable_devices);
@@ -683,9 +672,6 @@ OpenCLDevice::OpenCLDevice(DeviceInfo &info, Stats &stats, Profiler &profiler, b
   device_initialized = true;
 
   split_kernel = new OpenCLSplitKernel(this);
-  if (use_preview_kernels) {
-    load_preview_kernels();
-  }
 }
 
 OpenCLDevice::~OpenCLDevice()
@@ -776,7 +762,7 @@ bool OpenCLDevice::load_kernels(const DeviceRequestedFeatures &requested_feature
   load_required_kernels(requested_features);
 
   vector<OpenCLProgram *> programs;
-  kernel_programs.load_kernels(programs, requested_features, false);
+  kernel_programs.load_kernels(programs, requested_features);
 
   if (!requested_features.use_baking && requested_features.use_denoising) {
     denoising_program = OpenCLProgram(
@@ -854,19 +840,6 @@ void OpenCLDevice::load_required_kernels(const DeviceRequestedFeatures &requeste
   }
 }
 
-void OpenCLDevice::load_preview_kernels()
-{
-  DeviceRequestedFeatures no_features;
-  vector<OpenCLProgram *> programs;
-  preview_programs.load_kernels(programs, no_features, true);
-
-  foreach (OpenCLProgram *program, programs) {
-    if (!program->load()) {
-      load_required_kernel_task_pool.push(function_bind(&OpenCLProgram::compile, program));
-    }
-  }
-}
-
 bool OpenCLDevice::wait_for_availability(const DeviceRequestedFeatures &requested_features)
 {
   if (requested_features.use_baking) {
@@ -874,59 +847,18 @@ bool OpenCLDevice::wait_for_availability(const DeviceRequestedFeatures &requeste
     return true;
   }
 
-  if (background) {
-    load_kernel_task_pool.wait_work();
-    use_preview_kernels = false;
-  }
-  else {
-    /* We use a device setting to determine to load preview kernels or not
-     * Better to check on device level than per kernel as mixing preview and
-     * non-preview kernels does not work due to different data types */
-    if (use_preview_kernels) {
-      use_preview_kernels = load_kernel_num_compiling.load() > 0;
-    }
-  }
+  load_kernel_task_pool.wait_work();
   return split_kernel->load_kernels(requested_features);
 }
 
 OpenCLDevice::OpenCLSplitPrograms *OpenCLDevice::get_split_programs()
 {
-  return use_preview_kernels ? &preview_programs : &kernel_programs;
+  return &kernel_programs;
 }
 
 DeviceKernelStatus OpenCLDevice::get_active_kernel_switch_state()
 {
-  /* Do not switch kernels for background renderings
-   * We do foreground rendering but use the preview kernels
-   * Check for the optimized kernels
-   *
-   * This works also the other way around, where we are using
-   * optimized kernels but new ones are being compiled due
-   * to 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list