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

This commit is contained in:
Brecht Van Lommel 2019-01-09 16:38:04 +01:00
parent 1a6a80270d
commit b7fb3296c1
Notes: blender-bot 2023-02-14 05:02:32 +01:00
Referenced by issue #60300, GPU Fault while rendering scenes with subsurface scattering using OpenCL
Referenced by issue #57774, Subsurface scattering OpenCL Crash
2 changed files with 24 additions and 28 deletions

View File

@ -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];
/* Set global size */
int2 gsize = split_kernel_global_size(kgbuffer, kernel_data, task);
/* Allocate all required global memory once. */
if(first_tile) {
first_tile = false;
/* 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]);
/* Set gloabl 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]);
}
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; \

View File

@ -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: