[Bf-blender-cvs] [298dabc79b9] blender2.7: Cycles/OpenCL: Reduce How Often Kernel Recompilations Are Needed

Jeroen Bakker noreply at git.blender.org
Tue Mar 12 14:09:08 CET 2019


Commit: 298dabc79b9aa335cf7f3e0aa7f7f0fd702c8efd
Author: Jeroen Bakker
Date:   Tue Mar 12 13:58:39 2019 +0100
Branches: blender2.7
https://developer.blender.org/rB298dabc79b9aa335cf7f3e0aa7f7f0fd702c8efd

Cycles/OpenCL: Reduce How Often Kernel Recompilations Are Needed

This patch will reduce the number of times that we need to
recompile kernels. It does this by (en/dis)abling features
by default. So when the user needs them that the kernels are
already available.

Other features are enabled by default for background and foreground
rendering. When in background rendering the user wants the best
render performance. When in foreground rendering the user wants
the least amount of recompilations.

Enabling volumetrics or subdivision evaluation will still trigger
a recompilation during foreground rendering.

Reviewed By: #cycles, brecht

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

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

M	intern/cycles/device/opencl/opencl.h
M	intern/cycles/device/opencl/opencl_split.cpp
M	intern/cycles/render/session.cpp

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

diff --git a/intern/cycles/device/opencl/opencl.h b/intern/cycles/device/opencl/opencl.h
index 4ecf71e116e..2a4e07419ac 100644
--- a/intern/cycles/device/opencl/opencl.h
+++ b/intern/cycles/device/opencl/opencl.h
@@ -374,6 +374,8 @@ public:
 	/* 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);
+	/* Enable the default features to reduce recompilation events */
+	void enable_default_features(DeviceRequestedFeatures& features);
 
 	void mem_alloc(device_memory& mem);
 	void mem_copy_to(device_memory& mem);
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp
index b575b008fe0..422813c2e07 100644
--- a/intern/cycles/device/opencl/opencl_split.cpp
+++ b/intern/cycles/device/opencl/opencl_split.cpp
@@ -73,6 +73,25 @@ const string OpenCLDevice::get_opencl_program_filename(const string& kernel_name
 	}
 }
 
+/* Enable features that we always want to compile to reduce recompilation events */
+void OpenCLDevice::enable_default_features(DeviceRequestedFeatures& features)
+{
+	features.use_transparent = true;
+	features.use_shadow_tricks = true;
+	features.use_principled = true;
+	features.use_denoising = true;
+
+	if (!background)
+	{
+		features.max_nodes_group = NODE_GROUP_LEVEL_MAX;
+		features.nodes_features = NODE_FEATURE_ALL;
+		features.use_hair = true;
+		features.use_subsurface = true;
+		features.use_camera_motion = false;
+		features.use_object_motion = false;
+	}
+}
+
 string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_features, const string& opencl_program_name)
 {
 	/* first check for non-split kernel programs */
@@ -84,15 +103,22 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
 		 * displace and background are always requested.
 		 * `__SPLIT_KERNEL__` must not be present in the compile directives for bake */
 		DeviceRequestedFeatures features(requested_features);
+		enable_default_features(features);
 		features.use_denoising = false;
 		features.use_object_motion = false;
 		features.use_camera_motion = false;
+		features.use_hair = true;
+		features.use_subsurface = true;
+		features.max_nodes_group = NODE_GROUP_LEVEL_MAX;
+		features.nodes_features = NODE_FEATURE_ALL;
+		features.use_integrator_branched = false;
 		return features.get_build_options();
 	}
 	else if (opencl_program_name == "displace") {
 		/* As displacement does not use any nodes from the Shading group (eg BSDF).
 		 * We disable all features that are related to shading. */
 		DeviceRequestedFeatures features(requested_features);
+		enable_default_features(features);
 		features.use_denoising = false;
 		features.use_object_motion = false;
 		features.use_camera_motion = false;
@@ -104,13 +130,17 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
 		features.nodes_features &= ~NODE_FEATURE_VOLUME;
 		features.use_denoising = false;
 		features.use_principled = false;
+		features.use_integrator_branched = false;
 		return features.get_build_options();
 	}
 	else if (opencl_program_name == "background") {
 		/* Background uses Background shading
 		 * It is save to disable shadow features, subsurface and volumetric. */
 		DeviceRequestedFeatures features(requested_features);
+		enable_default_features(features);
 		features.use_baking = false;
+		features.use_object_motion = false;
+		features.use_camera_motion = false;
 		features.use_transparent = false;
 		features.use_shadow_tricks = false;
 		features.use_denoising = false;
@@ -120,11 +150,13 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
 		features.nodes_features &= ~NODE_FEATURE_VOLUME;
 		features.use_subsurface = false;
 		features.use_volume = false;
+		features.use_shader_raytrace = false;
+		features.use_patch_evaluation = false;
+		features.use_integrator_branched = false;
 		return features.get_build_options();
 	}
 
 	string build_options = "-D__SPLIT_KERNEL__ ";
-	DeviceRequestedFeatures nofeatures;
 	/* Set compute device build option. */
 	cl_device_type device_type;
 	OpenCLInfo::get_device_type(this->cdDevice, &device_type, &this->ciErr);
@@ -133,17 +165,16 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
 		build_options += "-D__COMPUTE_DEVICE_GPU__ ";
 	}
 
+	DeviceRequestedFeatures nofeatures;
+	enable_default_features(nofeatures);
+
 	/* Add program specific optimized compile directives */
 	if (opencl_program_name == "split_do_volume" && !requested_features.use_volume) {
 		build_options += nofeatures.get_build_options();
 	}
-	else if (opencl_program_name == "split_subsurface_scatter" && !requested_features.use_subsurface) {
-		/* When subsurface is off, the kernel updates indexes and does not need any
-		 * Compile directives */
-		build_options += nofeatures.get_build_options();
-	}
 	else {
 		DeviceRequestedFeatures features(requested_features);
+		enable_default_features(features);
 
 		/* Always turn off baking at this point. Baking is only usefull when building the bake kernel.
 		 * this also makes sure that the kernels that are build during baking can be reused
@@ -155,6 +186,7 @@ string OpenCLDevice::get_build_options(const DeviceRequestedFeatures& requested_
 		if (opencl_program_name == "split_bundle") {
 			features.max_nodes_group = 0;
 			features.nodes_features = 0;
+			features.use_shader_raytrace = false;
 		}
 
 		/* No specific settings, just add the regular ones */
diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp
index 87c46ec44c8..dea50d52cfa 100644
--- a/intern/cycles/render/session.cpp
+++ b/intern/cycles/render/session.cpp
@@ -658,11 +658,6 @@ DeviceRequestedFeatures Session::get_requested_device_features()
 	scene->shader_manager->get_requested_features(
 	        scene,
 	        &requested_features);
-	if(!params.background) {
-		/* Avoid too much re-compilations for viewport render. */
-		requested_features.max_nodes_group = NODE_GROUP_LEVEL_MAX;
-		requested_features.nodes_features = NODE_FEATURE_ALL;
-	}
 
 	/* This features are not being tweaked as often as shaders,
 	 * so could be done selective magic for the viewport as well.



More information about the Bf-blender-cvs mailing list