[Bf-blender-cvs] [b7fb3296c10] blender2.7: Fix T60300, T57774: Cycles OpenCL viewport crash with subsurface scattering.

Brecht Van Lommel noreply at git.blender.org
Wed Jan 9 16:43:44 CET 2019


Commit: b7fb3296c101bf408455352ec9784a8870672c81
Author: Brecht Van Lommel
Date:   Wed Jan 9 16:38:04 2019 +0100
Branches: blender2.7
https://developer.blender.org/rBb7fb3296c101bf408455352ec9784a8870672c81

Fix T60300, T57774: Cycles OpenCL viewport crash with subsurface scattering.

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

M	intern/cycles/device/device_split_kernel.cpp
M	intern/cycles/device/device_split_kernel.h

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

diff --git a/intern/cycles/device/device_split_kernel.cpp b/intern/cycles/device/device_split_kernel.cpp
index efaae8c84f4..ab2c11e904d 100644
--- a/intern/cycles/device/device_split_kernel.cpp
+++ b/intern/cycles/device/device_split_kernel.cpp
@@ -32,10 +32,9 @@ DeviceSplitKernel::DeviceSplitKernel(Device *device)
   ray_state(device, "ray_state", MEM_READ_WRITE),
   queue_index(device, "queue_index"),
   use_queues_flag(device, "use_queues_flag"),
-  work_pool_wgs(device, "work_pool_wgs")
+  work_pool_wgs(device, "work_pool_wgs"),
+  kernel_data_initialized(false)
 {
-	first_tile = true;
-
 	avg_time_per_sample = 0.0;
 
 	kernel_path_init = NULL;
@@ -116,6 +115,9 @@ bool DeviceSplitKernel::load_kernels(const DeviceRequestedFeatures& requested_fe
 
 #undef LOAD_KERNEL
 
+	/* Re-initialiaze kernel-dependent data when kernels change. */
+	kernel_data_initialized = false;
+
 	return true;
 }
 
@@ -137,33 +139,25 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
 		return false;
 	}
 
-	/* Get local size */
-	size_t local_size[2];
-	{
+	/* Allocate all required global memory once. */
+	if(!kernel_data_initialized) {
+		kernel_data_initialized = true;
+
+		/* Set local size */
 		int2 lsize = split_kernel_local_size();
 		local_size[0] = lsize[0];
 		local_size[1] = lsize[1];
-	}
-
-	/* Number of elements in the global state buffer */
-	int num_global_elements = global_size[0] * global_size[1];
 
-	/* Allocate all required global memory once. */
-	if(first_tile) {
-		first_tile = false;
-
-		/* Set gloabl size */
-		{
-			int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task);
+		/* Set global size */
+		int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task);
 
-			/* Make sure that set work size is a multiple of local
-			 * work size dimensions.
-			 */
-			global_size[0] = round_up(gsize[0], local_size[0]);
-			global_size[1] = round_up(gsize[1], local_size[1]);
-		}
+		/* Make sure that set work size is a multiple of local
+		 * work size dimensions.
+		 */
+		global_size[0] = round_up(gsize[0], local_size[0]);
+		global_size[1] = round_up(gsize[1], local_size[1]);
 
-		num_global_elements = global_size[0] * global_size[1];
+		int num_global_elements = global_size[0] * global_size[1];
 		assert(num_global_elements % WORK_POOL_SIZE == 0);
 
 		/* Calculate max groups */
@@ -180,6 +174,9 @@ bool DeviceSplitKernel::path_trace(DeviceTask *task,
 		ray_state.alloc(num_global_elements);
 	}
 
+	/* Number of elements in the global state buffer */
+	int num_global_elements = global_size[0] * global_size[1];
+
 #define ENQUEUE_SPLIT_KERNEL(name, global_size, local_size) \
 		if(device->have_error()) { \
 			return false; \
diff --git a/intern/cycles/device/device_split_kernel.h b/intern/cycles/device/device_split_kernel.h
index 5af4367d1b6..622733b843f 100644
--- a/intern/cycles/device/device_split_kernel.h
+++ b/intern/cycles/device/device_split_kernel.h
@@ -92,10 +92,9 @@ private:
 	/* Work pool with respect to each work group. */
 	device_only_memory<unsigned int> work_pool_wgs;
 
-	/* Marked True in constructor and marked false at the end of path_trace(). */
-	bool first_tile;
-
-	/* Cached global size */
+	/* Cached kernel-dependent data, initialized once. */
+	bool kernel_data_initialized;
+	size_t local_size[2];
 	size_t global_size[2];
 
 public:



More information about the Bf-blender-cvs mailing list