diff options
50 files changed, 311 insertions, 240 deletions
diff --git a/intern/cycles/device/opencl/opencl_split.cpp b/intern/cycles/device/opencl/opencl_split.cpp index a09d93c625e..3faae4039e3 100644 --- a/intern/cycles/device/opencl/opencl_split.cpp +++ b/intern/cycles/device/opencl/opencl_split.cpp @@ -346,9 +346,18 @@ public: virtual int2 split_kernel_global_size(device_memory& kg, device_memory& data, DeviceTask */*task*/) { + cl_device_type type; + clGetDeviceInfo(device->cdDevice, CL_DEVICE_TYPE, sizeof(cl_device_type), &type, NULL); + + /* Use small global size on CPU devices as it seems to be much faster. */ + if(type == CL_DEVICE_TYPE_CPU) { + VLOG(1) << "Global size: (64, 64)."; + return make_int2(64, 64); + } + cl_ulong max_buffer_size; clGetDeviceInfo(device->cdDevice, CL_DEVICE_MAX_MEM_ALLOC_SIZE, sizeof(cl_ulong), &max_buffer_size, NULL); - VLOG(1) << "Maximum device allocation side: " + VLOG(1) << "Maximum device allocation size: " << string_human_readable_number(max_buffer_size) << " bytes. (" << string_human_readable_size(max_buffer_size) << ")."; diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h index ba6b1033915..e220d857384 100644 --- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h +++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_impl.h @@ -168,21 +168,28 @@ void KERNEL_FUNCTION_FULL_NAME(shader)(KernelGlobals *kg, kernel_##name(kg); \ } +#define DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(name, type) \ + void KERNEL_FUNCTION_FULL_NAME(name)(KernelGlobals *kg, KernelData* /*data*/) \ + { \ + ccl_local type locals; \ + kernel_##name(kg, &locals); \ + } + DEFINE_SPLIT_KERNEL_FUNCTION(path_init) DEFINE_SPLIT_KERNEL_FUNCTION(scene_intersect) DEFINE_SPLIT_KERNEL_FUNCTION(lamp_emission) DEFINE_SPLIT_KERNEL_FUNCTION(do_volume) -DEFINE_SPLIT_KERNEL_FUNCTION(queue_enqueue) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(queue_enqueue, QueueEnqueueLocals) DEFINE_SPLIT_KERNEL_FUNCTION(indirect_background) -DEFINE_SPLIT_KERNEL_FUNCTION(shader_eval) -DEFINE_SPLIT_KERNEL_FUNCTION(holdout_emission_blurring_pathtermination_ao) -DEFINE_SPLIT_KERNEL_FUNCTION(subsurface_scatter) -DEFINE_SPLIT_KERNEL_FUNCTION(direct_lighting) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(shader_eval, uint) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(holdout_emission_blurring_pathtermination_ao, BackgroundAOLocals) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(subsurface_scatter, uint) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(direct_lighting, uint) DEFINE_SPLIT_KERNEL_FUNCTION(shadow_blocked_ao) DEFINE_SPLIT_KERNEL_FUNCTION(shadow_blocked_dl) -DEFINE_SPLIT_KERNEL_FUNCTION(next_iteration_setup) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(next_iteration_setup, uint) DEFINE_SPLIT_KERNEL_FUNCTION(indirect_subsurface) -DEFINE_SPLIT_KERNEL_FUNCTION(buffer_update) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(buffer_update, uint) void KERNEL_FUNCTION_FULL_NAME(register_functions)(void(*reg)(const char* name, void* func)) { diff --git a/intern/cycles/kernel/kernels/cuda/kernel_split.cu b/intern/cycles/kernel/kernels/cuda/kernel_split.cu index fbdf79697d5..4479a044921 100644 --- a/intern/cycles/kernel/kernels/cuda/kernel_split.cu +++ b/intern/cycles/kernel/kernels/cuda/kernel_split.cu @@ -93,21 +93,30 @@ kernel_cuda_path_trace_data_init( kernel_##name(NULL); \ } +#define DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(name, type) \ + extern "C" __global__ void \ + CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) \ + kernel_cuda_##name() \ + { \ + ccl_local type locals; \ + kernel_##name(NULL, &locals); \ + } + DEFINE_SPLIT_KERNEL_FUNCTION(path_init) DEFINE_SPLIT_KERNEL_FUNCTION(scene_intersect) DEFINE_SPLIT_KERNEL_FUNCTION(lamp_emission) DEFINE_SPLIT_KERNEL_FUNCTION(do_volume) -DEFINE_SPLIT_KERNEL_FUNCTION(queue_enqueue) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(queue_enqueue, QueueEnqueueLocals) DEFINE_SPLIT_KERNEL_FUNCTION(indirect_background) -DEFINE_SPLIT_KERNEL_FUNCTION(shader_eval) -DEFINE_SPLIT_KERNEL_FUNCTION(holdout_emission_blurring_pathtermination_ao) -DEFINE_SPLIT_KERNEL_FUNCTION(subsurface_scatter) -DEFINE_SPLIT_KERNEL_FUNCTION(direct_lighting) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(shader_eval, uint) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(holdout_emission_blurring_pathtermination_ao, BackgroundAOLocals) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(subsurface_scatter, uint) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(direct_lighting, uint) DEFINE_SPLIT_KERNEL_FUNCTION(shadow_blocked_ao) DEFINE_SPLIT_KERNEL_FUNCTION(shadow_blocked_dl) -DEFINE_SPLIT_KERNEL_FUNCTION(next_iteration_setup) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(next_iteration_setup, uint) DEFINE_SPLIT_KERNEL_FUNCTION(indirect_subsurface) -DEFINE_SPLIT_KERNEL_FUNCTION(buffer_update) +DEFINE_SPLIT_KERNEL_FUNCTION_LOCALS(buffer_update, uint) extern "C" __global__ void CUDA_LAUNCH_BOUNDS(CUDA_THREADS_BLOCK_WIDTH, CUDA_KERNEL_MAX_REGISTERS) diff --git a/intern/cycles/kernel/kernels/opencl/kernel_buffer_update.cl b/intern/cycles/kernel/kernels/opencl/kernel_buffer_update.cl index d3058501f27..b61f1cda330 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_buffer_update.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_buffer_update.cl @@ -19,8 +19,9 @@ #include "split/kernel_buffer_update.h" __kernel void kernel_ocl_path_trace_buffer_update( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_buffer_update(kg); + ccl_local unsigned int local_queue_atomics; + kernel_buffer_update((KernelGlobals*)kg, &local_queue_atomics); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl index 1e3c4fa28c7..54d4a577e10 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_data_init.cl @@ -19,7 +19,7 @@ #include "split/kernel_data_init.h" __kernel void kernel_ocl_path_trace_data_init( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data, ccl_global void *split_data_buffer, int num_elements, @@ -40,7 +40,7 @@ __kernel void kernel_ocl_path_trace_data_init( unsigned int num_samples, /* Total number of samples per pixel */ ccl_global float *buffer) { - kernel_data_init(kg, + kernel_data_init((KernelGlobals*)kg, data, split_data_buffer, num_elements, diff --git a/intern/cycles/kernel/kernels/opencl/kernel_direct_lighting.cl b/intern/cycles/kernel/kernels/opencl/kernel_direct_lighting.cl index 5d2f46b319d..374be6cbd05 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_direct_lighting.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_direct_lighting.cl @@ -19,8 +19,9 @@ #include "split/kernel_direct_lighting.h" __kernel void kernel_ocl_path_trace_direct_lighting( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_direct_lighting(kg); + ccl_local unsigned int local_queue_atomics; + kernel_direct_lighting((KernelGlobals*)kg, &local_queue_atomics); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_do_volume.cl b/intern/cycles/kernel/kernels/opencl/kernel_do_volume.cl index 6380e9cb746..08187b0e03e 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_do_volume.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_do_volume.cl @@ -19,8 +19,8 @@ #include "split/kernel_do_volume.h" __kernel void kernel_ocl_path_trace_do_volume( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_do_volume(kg); + kernel_do_volume((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl b/intern/cycles/kernel/kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl index 7724b8a0bdf..351687e2036 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl @@ -19,8 +19,11 @@ #include "split/kernel_holdout_emission_blurring_pathtermination_ao.h" __kernel void kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_holdout_emission_blurring_pathtermination_ao(kg); + ccl_local BackgroundAOLocals locals; + kernel_holdout_emission_blurring_pathtermination_ao( + (KernelGlobals*)kg, + &locals); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_indirect_background.cl b/intern/cycles/kernel/kernels/opencl/kernel_indirect_background.cl index 671501bf237..b18fba4c01f 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_indirect_background.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_indirect_background.cl @@ -19,8 +19,8 @@ #include "split/kernel_indirect_background.h" __kernel void kernel_ocl_path_trace_indirect_background( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_indirect_background(kg); + kernel_indirect_background((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_indirect_subsurface.cl b/intern/cycles/kernel/kernels/opencl/kernel_indirect_subsurface.cl index b5e52e81ebf..ce2e96ad789 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_indirect_subsurface.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_indirect_subsurface.cl @@ -19,8 +19,8 @@ #include "split/kernel_indirect_subsurface.h" __kernel void kernel_ocl_path_trace_indirect_subsurface( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_indirect_subsurface(kg); + kernel_indirect_subsurface((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_lamp_emission.cl b/intern/cycles/kernel/kernels/opencl/kernel_lamp_emission.cl index 2b84d0ea43e..830e4e373ac 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_lamp_emission.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_lamp_emission.cl @@ -19,8 +19,8 @@ #include "split/kernel_lamp_emission.h" __kernel void kernel_ocl_path_trace_lamp_emission( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_lamp_emission(kg); + kernel_lamp_emission((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_next_iteration_setup.cl b/intern/cycles/kernel/kernels/opencl/kernel_next_iteration_setup.cl index e87e367fb9c..fd49ed5def8 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_next_iteration_setup.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_next_iteration_setup.cl @@ -19,8 +19,9 @@ #include "split/kernel_next_iteration_setup.h" __kernel void kernel_ocl_path_trace_next_iteration_setup( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_next_iteration_setup(kg); + ccl_local unsigned int local_queue_atomics; + kernel_next_iteration_setup((KernelGlobals*)kg, &local_queue_atomics); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_path_init.cl b/intern/cycles/kernel/kernels/opencl/kernel_path_init.cl index 7e9e4a02529..8194f5d22ca 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_path_init.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_path_init.cl @@ -19,8 +19,8 @@ #include "split/kernel_path_init.h" __kernel void kernel_ocl_path_trace_path_init( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_path_init(kg); + kernel_path_init((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_queue_enqueue.cl b/intern/cycles/kernel/kernels/opencl/kernel_queue_enqueue.cl index 9ceb6a5c3d8..6dd9d39c4e2 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_queue_enqueue.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_queue_enqueue.cl @@ -19,8 +19,9 @@ #include "split/kernel_queue_enqueue.h" __kernel void kernel_ocl_path_trace_queue_enqueue( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_queue_enqueue(kg); + ccl_local QueueEnqueueLocals locals; + kernel_queue_enqueue((KernelGlobals*)kg, &locals); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_scene_intersect.cl b/intern/cycles/kernel/kernels/opencl/kernel_scene_intersect.cl index 4e083e87d1c..c675640c599 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_scene_intersect.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_scene_intersect.cl @@ -19,8 +19,8 @@ #include "split/kernel_scene_intersect.h" __kernel void kernel_ocl_path_trace_scene_intersect( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_scene_intersect(kg); + kernel_scene_intersect((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_shader_eval.cl b/intern/cycles/kernel/kernels/opencl/kernel_shader_eval.cl index a2b48b15928..71ac2886978 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_shader_eval.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_shader_eval.cl @@ -19,8 +19,9 @@ #include "split/kernel_shader_eval.h" __kernel void kernel_ocl_path_trace_shader_eval( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_shader_eval(kg); + ccl_local unsigned int local_queue_atomics; + kernel_shader_eval((KernelGlobals*)kg, &local_queue_atomics); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_ao.cl b/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_ao.cl index 1c96d67fec2..37824097031 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_ao.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_ao.cl @@ -19,8 +19,8 @@ #include "split/kernel_shadow_blocked_ao.h" __kernel void kernel_ocl_path_trace_shadow_blocked_ao( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_shadow_blocked_ao(kg); + kernel_shadow_blocked_ao((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_dl.cl b/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_dl.cl index 2231f767c0c..4889f49d8dc 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_dl.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_shadow_blocked_dl.cl @@ -19,8 +19,8 @@ #include "split/kernel_shadow_blocked_dl.h" __kernel void kernel_ocl_path_trace_shadow_blocked_dl( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_shadow_blocked_dl(kg); + kernel_shadow_blocked_dl((KernelGlobals*)kg); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_state_buffer_size.cl b/intern/cycles/kernel/kernels/opencl/kernel_state_buffer_size.cl index 4c9bf63ef51..b23ff33786d 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_state_buffer_size.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_state_buffer_size.cl @@ -18,12 +18,12 @@ #include "split/kernel_split_common.h" __kernel void kernel_ocl_path_trace_state_buffer_size( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data, uint num_threads, ccl_global uint64_t *size) { - kg->data = data; - *size = split_data_buffer_size(kg, num_threads); + ((KernelGlobals*)kg)->data = data; + *size = split_data_buffer_size((KernelGlobals*)kg, num_threads); } diff --git a/intern/cycles/kernel/kernels/opencl/kernel_subsurface_scatter.cl b/intern/cycles/kernel/kernels/opencl/kernel_subsurface_scatter.cl index 8dae79bacb0..853bba2efc5 100644 --- a/intern/cycles/kernel/kernels/opencl/kernel_subsurface_scatter.cl +++ b/intern/cycles/kernel/kernels/opencl/kernel_subsurface_scatter.cl @@ -19,8 +19,9 @@ #include "split/kernel_subsurface_scatter.h" __kernel void kernel_ocl_path_trace_subsurface_scatter( - KernelGlobals *kg, + ccl_global char *kg, ccl_constant KernelData *data) { - kernel_subsurface_scatter(kg); + ccl_local unsigned int local_queue_atomics; + kernel_subsurface_scatter((KernelGlobals*)kg, &local_queue_atomics); } diff --git a/intern/cycles/kernel/split/kernel_buffer_update.h b/intern/cycles/kernel/split/kernel_buffer_update.h index e8f574c5546..f36899b884a 100644 --- a/intern/cycles/kernel/split/kernel_buffer_update.h +++ b/intern/cycles/kernel/split/kernel_buffer_update.h @@ -38,11 +38,11 @@ CCL_NAMESPACE_BEGIN * RAY_REGENERATED rays. * - QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be empty. */ -ccl_device void kernel_buffer_update(KernelGlobals *kg) +ccl_device void kernel_buffer_update(KernelGlobals *kg, + ccl_local_param unsigned int *local_queue_atomics) { - ccl_local unsigned int local_queue_atomics; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics = 0; + *local_queue_atomics = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -188,7 +188,7 @@ ccl_device void kernel_buffer_update(KernelGlobals *kg) QUEUE_ACTIVE_AND_REGENERATED_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics, + local_queue_atomics, kernel_split_state.queue_data, kernel_split_params.queue_index); } diff --git a/intern/cycles/kernel/split/kernel_direct_lighting.h b/intern/cycles/kernel/split/kernel_direct_lighting.h index dfe461fb357..3d062cf0e2b 100644 --- a/intern/cycles/kernel/split/kernel_direct_lighting.h +++ b/intern/cycles/kernel/split/kernel_direct_lighting.h @@ -40,11 +40,11 @@ CCL_NAMESPACE_BEGIN * shadow_blocked function must be executed, after this kernel call * Before this kernel call the QUEUE_SHADOW_RAY_CAST_DL_RAYS will be empty. */ -ccl_device void kernel_direct_lighting(KernelGlobals *kg) +ccl_device void kernel_direct_lighting(KernelGlobals *kg, + ccl_local_param unsigned int *local_queue_atomics) { - ccl_local unsigned int local_queue_atomics; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics = 0; + *local_queue_atomics = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -130,7 +130,7 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg) QUEUE_SHADOW_RAY_CAST_DL_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics, + local_queue_atomics, kernel_split_state.queue_data, kernel_split_params.queue_index); #endif diff --git a/intern/cycles/kernel/split/kernel_do_volume.h b/intern/cycles/kernel/split/kernel_do_volume.h index 18da6e8aa3a..b1df45d6bb2 100644 --- a/intern/cycles/kernel/split/kernel_do_volume.h +++ b/intern/cycles/kernel/split/kernel_do_volume.h @@ -25,10 +25,7 @@ ccl_device void kernel_do_volume(KernelGlobals *kg) kernel_split_params.queue_index[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = 0; } /* Fetch use_queues_flag. */ - ccl_local char local_use_queues_flag; - if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_use_queues_flag = *kernel_split_params.use_queues_flag; - } + char local_use_queues_flag = *kernel_split_params.use_queues_flag; ccl_barrier(CCL_LOCAL_MEM_FENCE); int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h index bb948ad24b0..e4bf513ffdc 100644 --- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h +++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h @@ -52,13 +52,13 @@ CCL_NAMESPACE_BEGIN * - QUEUE_SHADOW_RAY_CAST_AO_RAYS will be filled with rays marked with * flag RAY_SHADOW_RAY_CAST_AO */ -ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobals *kg) +ccl_device void kernel_holdout_emission_blurring_pathtermination_ao( + KernelGlobals *kg, + ccl_local_param BackgroundAOLocals *locals) { - ccl_local unsigned int local_queue_atomics_bg; - ccl_local unsigned int local_queue_atomics_ao; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics_bg = 0; - local_queue_atomics_ao = 0; + locals->queue_atomics_bg = 0; + locals->queue_atomics_ao = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -253,7 +253,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics_bg, + &locals->queue_atomics_bg, kernel_split_state.queue_data, kernel_split_params.queue_index); @@ -263,7 +263,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao(KernelGlobal QUEUE_SHADOW_RAY_CAST_AO_RAYS, enqueue_flag_AO_SHADOW_RAY_CAST, kernel_split_params.queue_size, - &local_queue_atomics_ao, + &locals->queue_atomics_bg, kernel_split_state.queue_data, kernel_split_params.queue_index); #endif diff --git a/intern/cycles/kernel/split/kernel_indirect_background.h b/intern/cycles/kernel/split/kernel_indirect_background.h index 96ca0f094b1..100f5996f83 100644 --- a/intern/cycles/kernel/split/kernel_indirect_background.h +++ b/intern/cycles/kernel/split/kernel_indirect_background.h @@ -18,7 +18,6 @@ CCL_NAMESPACE_BEGIN ccl_device void kernel_indirect_background(KernelGlobals *kg) { - ccl_global char *ray_state = kernel_split_state.ray_state; int thread_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); diff --git a/intern/cycles/kernel/split/kernel_lamp_emission.h b/intern/cycles/kernel/split/kernel_lamp_emission.h index f61643cceef..c669d79ddcd 100644 --- a/intern/cycles/kernel/split/kernel_lamp_emission.h +++ b/intern/cycles/kernel/split/kernel_lamp_emission.h @@ -29,10 +29,7 @@ ccl_device void kernel_lamp_emission(KernelGlobals *kg) } #endif /* Fetch use_queues_flag. */ - ccl_local char local_use_queues_flag; - if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_use_queues_flag = *kernel_split_params.use_queues_flag; - } + char local_use_queues_flag = *kernel_split_params.use_queues_flag; ccl_barrier(CCL_LOCAL_MEM_FENCE); int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); diff --git a/intern/cycles/kernel/split/kernel_next_iteration_setup.h b/intern/cycles/kernel/split/kernel_next_iteration_setup.h index ad1f6c78e8f..056fb1d8c08 100644 --- a/intern/cycles/kernel/split/kernel_next_iteration_setup.h +++ b/intern/cycles/kernel/split/kernel_next_iteration_setup.h @@ -44,11 +44,11 @@ CCL_NAMESPACE_BEGIN * - QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with * RAY_TO_REGENERATE and more RAY_UPDATE_BUFFER rays. */ -ccl_device void kernel_next_iteration_setup(KernelGlobals *kg) +ccl_device void kernel_next_iteration_setup(KernelGlobals *kg, + ccl_local_param unsigned int *local_queue_atomics) { - ccl_local unsigned int local_queue_atomics; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics = 0; + *local_queue_atomics = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -161,7 +161,7 @@ ccl_device void kernel_next_iteration_setup(KernelGlobals *kg) QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics, + local_queue_atomics, kernel_split_state.queue_data, kernel_split_params.queue_index); } diff --git a/intern/cycles/kernel/split/kernel_queue_enqueue.h b/intern/cycles/kernel/split/kernel_queue_enqueue.h index f4a4657d23f..e2e841f36d3 100644 --- a/intern/cycles/kernel/split/kernel_queue_enqueue.h +++ b/intern/cycles/kernel/split/kernel_queue_enqueue.h @@ -35,17 +35,16 @@ CCL_NAMESPACE_BEGIN * - QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with * RAY_TO_REGENERATE, RAY_UPDATE_BUFFER, RAY_HIT_BACKGROUND rays. */ -ccl_device void kernel_queue_enqueue(KernelGlobals *kg) +ccl_device void kernel_queue_enqueue(KernelGlobals *kg, + ccl_local_param QueueEnqueueLocals *locals) { /* We have only 2 cases (Hit/Not-Hit) */ - ccl_local unsigned int local_queue_atomics[2]; - int lidx = ccl_local_id(1) * ccl_local_size(0) + ccl_local_id(0); int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); if(lidx == 0) { - local_queue_atomics[0] = 0; - local_queue_atomics[1] = 0; + locals->queue_atomics[0] = 0; + locals->queue_atomics[1] = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -62,18 +61,18 @@ ccl_device void kernel_queue_enqueue(KernelGlobals *kg) unsigned int my_lqidx; if(queue_number != -1) { - my_lqidx = get_local_queue_index(queue_number, local_queue_atomics); + my_lqidx = get_local_queue_index(queue_number, locals->queue_atomics); } ccl_barrier(CCL_LOCAL_MEM_FENCE); if(lidx == 0) { - local_queue_atomics[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = + locals->queue_atomics[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = get_global_per_queue_offset(QUEUE_ACTIVE_AND_REGENERATED_RAYS, - local_queue_atomics, + locals->queue_atomics, kernel_split_params.queue_index); - local_queue_atomics[QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS] = + locals->queue_atomics[QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS] = get_global_per_queue_offset(QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, - local_queue_atomics, + locals->queue_atomics, kernel_split_params.queue_index); } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -83,7 +82,7 @@ ccl_device void kernel_queue_enqueue(KernelGlobals *kg) my_gqidx = get_global_queue_index(queue_number, kernel_split_params.queue_size, my_lqidx, - local_queue_atomics); + locals->queue_atomics); kernel_split_state.queue_data[my_gqidx] = ray_index; } } diff --git a/intern/cycles/kernel/split/kernel_scene_intersect.h b/intern/cycles/kernel/split/kernel_scene_intersect.h index 33d0df7a2cb..66f549f59b7 100644 --- a/intern/cycles/kernel/split/kernel_scene_intersect.h +++ b/intern/cycles/kernel/split/kernel_scene_intersect.h @@ -26,10 +26,7 @@ CCL_NAMESPACE_BEGIN ccl_device void kernel_scene_intersect(KernelGlobals *kg) { /* Fetch use_queues_flag */ - ccl_local char local_use_queues_flag; - if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_use_queues_flag = *kernel_split_params.use_queues_flag; - } + char local_use_queues_flag = *kernel_split_params.use_queues_flag; ccl_barrier(CCL_LOCAL_MEM_FENCE); int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0); diff --git a/intern/cycles/kernel/split/kernel_shader_eval.h b/intern/cycles/kernel/split/kernel_shader_eval.h index 43872c6f388..fc966b77b2c 100644 --- a/intern/cycles/kernel/split/kernel_shader_eval.h +++ b/intern/cycles/kernel/split/kernel_shader_eval.h @@ -22,12 +22,12 @@ CCL_NAMESPACE_BEGIN * It also identifies the rays of state RAY_TO_REGENERATE and enqueues them * in QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. */ -ccl_device void kernel_shader_eval(KernelGlobals *kg) +ccl_device void kernel_shader_eval(KernelGlobals *kg, + ccl_local_param unsigned int *local_queue_atomics) { /* Enqeueue RAY_TO_REGENERATE rays into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. */ - ccl_local unsigned int local_queue_atomics; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics = 0; + *local_queue_atomics = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -47,7 +47,7 @@ ccl_device void kernel_shader_eval(KernelGlobals *kg) QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics, + local_queue_atomics, kernel_split_state.queue_data, kernel_split_params.queue_index); diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h index a1eb0d1eccd..4243e18de72 100644 --- a/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h +++ b/intern/cycles/kernel/split/kernel_shadow_blocked_ao.h @@ -19,12 +19,7 @@ CCL_NAMESPACE_BEGIN /* Shadow ray cast for AO. */ ccl_device void kernel_shadow_blocked_ao(KernelGlobals *kg) { - int lidx = ccl_local_id(1) * ccl_local_id(0) + ccl_local_id(0); - - ccl_local unsigned int ao_queue_length; - if(lidx == 0) { - ao_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS]; - } + unsigned int ao_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS]; ccl_barrier(CCL_LOCAL_MEM_FENCE); int ray_index = QUEUE_EMPTY_SLOT; diff --git a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h index 2e5629944dc..bb8f0157965 100644 --- a/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h +++ b/intern/cycles/kernel/split/kernel_shadow_blocked_dl.h @@ -19,12 +19,7 @@ CCL_NAMESPACE_BEGIN /* Shadow ray cast for direct visible light. */ ccl_device void kernel_shadow_blocked_dl(KernelGlobals *kg) { - int lidx = ccl_local_id(1) * ccl_local_id(0) + ccl_local_id(0); - - ccl_local unsigned int dl_queue_length; - if(lidx == 0) { - dl_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS]; - } + unsigned int dl_queue_length = kernel_split_params.queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS]; ccl_barrier(CCL_LOCAL_MEM_FENCE); int ray_index = QUEUE_EMPTY_SLOT; diff --git a/intern/cycles/kernel/split/kernel_split_data_types.h b/intern/cycles/kernel/split/kernel_split_data_types.h index 365d78c9f99..748197b7183 100644 --- a/intern/cycles/kernel/split/kernel_split_data_types.h +++ b/intern/cycles/kernel/split/kernel_split_data_types.h @@ -111,6 +111,17 @@ __device__ SplitParams __split_param_data; # define kernel_split_params (__split_param_data) #endif /* __KERNEL_CUDA__ */ +/* Local storage for queue_enqueue kernel. */ +typedef struct QueueEnqueueLocals { + uint queue_atomics[2]; +} QueueEnqueueLocals; + +/* Local storage for holdout_emission_blurring_pathtermination_ao kernel. */ +typedef struct BackgroundAOLocals { + uint queue_atomics_bg; + uint queue_atomics_ao; +} BackgroundAOLocals; + CCL_NAMESPACE_END #endif /* __KERNEL_SPLIT_DATA_TYPES_H__ */ diff --git a/intern/cycles/kernel/split/kernel_subsurface_scatter.h b/intern/cycles/kernel/split/kernel_subsurface_scatter.h index e282ac00a63..709a296c9a0 100644 --- a/intern/cycles/kernel/split/kernel_subsurface_scatter.h +++ b/intern/cycles/kernel/split/kernel_subsurface_scatter.h @@ -17,13 +17,12 @@ CCL_NAMESPACE_BEGIN -ccl_device void kernel_subsurface_scatter(KernelGlobals *kg) +ccl_device void kernel_subsurface_scatter(KernelGlobals *kg, + ccl_local_param unsigned int* local_queue_atomics) { #ifdef __SUBSURFACE__ - - ccl_local unsigned int local_queue_atomics; if(ccl_local_id(0) == 0 && ccl_local_id(1) == 0) { - local_queue_atomics = 0; + *local_queue_atomics = 0; } ccl_barrier(CCL_LOCAL_MEM_FENCE); @@ -89,7 +88,7 @@ ccl_device void kernel_subsurface_scatter(KernelGlobals *kg) QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, kernel_split_params.queue_size, - &local_queue_atomics, + local_queue_atomics, kernel_split_state.queue_data, kernel_split_params.queue_index); diff --git a/source/blender/blenkernel/BKE_blender.h b/source/blender/blenkernel/BKE_blender.h index 1fe425b7e72..040df054ec5 100644 --- a/source/blender/blenkernel/BKE_blender.h +++ b/source/blender/blenkernel/BKE_blender.h @@ -38,13 +38,17 @@ extern "C" { #endif +struct UserDef; + void BKE_blender_free(void); void BKE_blender_globals_init(void); void BKE_blender_globals_clear(void); -void BKE_blender_version_string(char *version_str, size_t maxncpy, short version, short subversion, bool v_prefix, bool include_subversion); +void BKE_blender_version_string( + char *version_str, size_t maxncpy, + short version, short subversion, bool v_prefix, bool include_subversion); -void BKE_blender_userdef_free(void); +void BKE_blender_userdef_free(struct UserDef *userdef); void BKE_blender_userdef_refresh(void); /* set this callback when a UI is running */ diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index bb69eac2924..0180e68faed 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -154,16 +154,14 @@ static void keymap_item_free(wmKeyMapItem *kmi) * When loading a new userdef from file, * or when exiting Blender. */ -void BKE_blender_userdef_free(void) +void BKE_blender_userdef_free(UserDef *userdef) { - wmKeyMap *km; - wmKeyMapItem *kmi; - wmKeyMapDiffItem *kmdi; - bAddon *addon, *addon_next; - uiFont *font; - - for (km = U.user_keymaps.first; km; km = km->next) { - for (kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { +#define U _invalid_access_ /* ensure no accidental global access */ +#ifdef U /* quiet warning */ +#endif + + for (wmKeyMap *km = userdef->user_keymaps.first; km; km = km->next) { + for (wmKeyMapDiffItem *kmdi = km->diff_items.first; kmdi; kmdi = kmdi->next) { if (kmdi->add_item) { keymap_item_free(kmdi->add_item); MEM_freeN(kmdi->add_item); @@ -174,14 +172,15 @@ void BKE_blender_userdef_free(void) } } - for (kmi = km->items.first; kmi; kmi = kmi->next) + for (wmKeyMapItem *kmi = km->items.first; kmi; kmi = kmi->next) { keymap_item_free(kmi); + } BLI_freelistN(&km->diff_items); BLI_freelistN(&km->items); } - - for (addon = U.addons.first; addon; addon = addon_next) { + + for (bAddon *addon = userdef->addons.first, *addon_next; addon; addon = addon_next) { addon_next = addon->next; if (addon->prop) { IDP_FreeProperty(addon->prop); @@ -190,18 +189,20 @@ void BKE_blender_userdef_free(void) MEM_freeN(addon); } - for (font = U.uifonts.first; font; font = font->next) { + for (uiFont *font = userdef->uifonts.first; font; font = font->next) { BLF_unload_id(font->blf_id); } BLF_default_set(-1); - BLI_freelistN(&U.autoexec_paths); + BLI_freelistN(&userdef->autoexec_paths); + + BLI_freelistN(&userdef->uistyles); + BLI_freelistN(&userdef->uifonts); + BLI_freelistN(&userdef->themes); + BLI_freelistN(&userdef->user_keymaps); - BLI_freelistN(&U.uistyles); - BLI_freelistN(&U.uifonts); - BLI_freelistN(&U.themes); - BLI_freelistN(&U.user_keymaps); +#undef U } /** diff --git a/source/blender/blenkernel/intern/blender_undo.c b/source/blender/blenkernel/intern/blender_undo.c index 396c06f96d1..e3a5edb2049 100644 --- a/source/blender/blenkernel/intern/blender_undo.c +++ b/source/blender/blenkernel/intern/blender_undo.c @@ -389,7 +389,7 @@ bool BKE_undo_save_file(const char *filename) Main *BKE_undo_get_main(Scene **r_scene) { Main *mainp = NULL; - BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL, 0); + BlendFileData *bfd = BLO_read_from_memfile(G.main, G.main->name, &curundo->memfile, NULL, BLO_READ_SKIP_NONE); if (bfd) { mainp = bfd->main; diff --git a/source/blender/blenkernel/intern/blendfile.c b/source/blender/blenkernel/intern/blendfile.c index 146c67576ef..8b472249939 100644 --- a/source/blender/blenkernel/intern/blendfile.c +++ b/source/blender/blenkernel/intern/blendfile.c @@ -227,7 +227,7 @@ static void setup_app_data( if (bfd->user) { /* only here free userdef themes... */ - BKE_blender_userdef_free(); + BKE_blender_userdef_free(&U); U = *bfd->user; @@ -430,13 +430,13 @@ int BKE_blendfile_read_userdef(const char *filepath, ReportList *reports) BlendFileData *bfd; int retval = BKE_BLENDFILE_READ_FAIL; - bfd = BLO_read_from_file(filepath, reports, 0); + bfd = BLO_read_from_file(filepath, reports, BLO_READ_SKIP_NONE); if (bfd) { if (bfd->user) { retval = BKE_BLENDFILE_READ_OK_USERPREFS; /* only here free userdef themes... */ - BKE_blender_userdef_free(); + BKE_blender_userdef_free(&U); U = *bfd->user; MEM_freeN(bfd->user); diff --git a/source/blender/blenloader/BLO_readfile.h b/source/blender/blenloader/BLO_readfile.h index e07d567ce61..52b8d15b987 100644 --- a/source/blender/blenloader/BLO_readfile.h +++ b/source/blender/blenloader/BLO_readfile.h @@ -74,6 +74,7 @@ typedef struct BlendFileData { /* skip reading some data-block types (may want to skip screen data too). */ typedef enum eBLOReadSkip { + BLO_READ_SKIP_NONE = 0, BLO_READ_SKIP_USERDEF = (1 << 0), } eBLOReadSkip; diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc index 4c84ac417ef..b6071b10757 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes.cc @@ -433,7 +433,7 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob) } /* Object data. */ - if (ob->data) { + if (ob->data != NULL) { /* type-specific data... */ switch (ob->type) { case OB_MESH: /* Geometry */ @@ -491,14 +491,25 @@ void DepsgraphNodeBuilder::build_object(Scene *scene, Object *ob) build_animdata(&ob->id); /* particle systems */ - if (ob->particlesystem.first) { + if (ob->particlesystem.first != NULL) { build_particles(scene, ob); } - /* grease pencil */ - if (ob->gpd) { + /* Grease pencil. */ + if (ob->gpd != NULL) { build_gpencil(ob->gpd); } + + /* Object that this is a proxy for. */ + if (ob->proxy) { + ob->proxy->proxy_from = ob; + build_object(scene, ob->proxy); + } + + /* Object dupligroup. */ + if (ob->dup_group != NULL) { + build_group(scene, ob->dup_group); + } } void DepsgraphNodeBuilder::build_object_transform(Scene *scene, Object *ob) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc index f4a191067ca..2141f7f6499 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_nodes_scene.cc @@ -84,18 +84,6 @@ void DepsgraphNodeBuilder::build_scene(Main *bmain, Scene *scene) { /* object itself */ build_object(scene, ob); - - /* object that this is a proxy for */ - // XXX: the way that proxies work needs to be completely reviewed! - if (ob->proxy) { - ob->proxy->proxy_from = ob; - build_object(scene, ob->proxy); - } - - /* Object dupligroup. */ - if (ob->dup_group) { - build_group(scene, ob->dup_group); - } } FOREACH_SCENE_OBJECT_END diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 9ac656fbe26..da788297a2f 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -396,30 +396,52 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o OperationKey ob_ubereval_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_OBJECT_UBEREVAL); /* parenting */ - if (ob->parent) { + if (ob->parent != NULL) { /* parent relationship */ build_object_parent(ob); /* local -> parent */ - add_relation(local_transform_key, parent_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObLocal -> ObParent]"); + add_relation(local_transform_key, + parent_transform_key, + DEPSREL_TYPE_COMPONENT_ORDER, + "[ObLocal -> ObParent]"); } /* object constraints */ - if (ob->constraints.first) { - OperationKey constraint_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_CONSTRAINTS); + if (ob->constraints.first != NULL) { + OperationKey constraint_key(&ob->id, + DEPSNODE_TYPE_TRANSFORM, + DEG_OPCODE_TRANSFORM_CONSTRAINTS); /* constraint relations */ // TODO: provide base op // XXX: this is broken - build_constraints(scene, &ob->id, DEPSNODE_TYPE_TRANSFORM, "", &ob->constraints, NULL); + build_constraints(scene, + &ob->id, + DEPSNODE_TYPE_TRANSFORM, + "", + &ob->constraints, + NULL); /* operation order */ - add_relation(base_op_key, constraint_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObBase-> Constraint Stack]"); - add_relation(constraint_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "[ObConstraints -> Done]"); + add_relation(base_op_key, + constraint_key, + DEPSREL_TYPE_COMPONENT_ORDER, + "[ObBase-> Constraint Stack]"); + add_relation(constraint_key, + final_transform_key, + DEPSREL_TYPE_COMPONENT_ORDER, + "[ObConstraints -> Done]"); // XXX - add_relation(constraint_key, ob_ubereval_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval"); - add_relation(ob_ubereval_key, final_transform_key, DEPSREL_TYPE_COMPONENT_ORDER, "Temp Ubereval"); + add_relation(constraint_key, + ob_ubereval_key, + DEPSREL_TYPE_COMPONENT_ORDER, + "Temp Ubereval"); + add_relation(ob_ubereval_key, + final_transform_key, + DEPSREL_TYPE_COMPONENT_ORDER, + "Temp Ubereval"); } else { /* NOTE: Keep an eye here, we skip some relations here to "streamline" @@ -448,7 +470,10 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o // XXX: This should be hooked up by the build_animdata code if (needs_animdata_node(&ob->id)) { ComponentKey adt_key(&ob->id, DEPSNODE_TYPE_ANIMATION); - add_relation(adt_key, local_transform_key, DEPSREL_TYPE_OPERATION, "Object Animation"); + add_relation(adt_key, + local_transform_key, + DEPSREL_TYPE_OPERATION, + "Object Animation"); } @@ -494,25 +519,48 @@ void DepsgraphRelationBuilder::build_object(Main *bmain, Scene *scene, Object *o if (key != NULL) { ComponentKey geometry_key((ID *)ob->data, DEPSNODE_TYPE_GEOMETRY); ComponentKey key_key(&key->id, DEPSNODE_TYPE_GEOMETRY); - add_relation(key_key, geometry_key, DEPSREL_TYPE_GEOMETRY_EVAL, "Shapekeys"); + add_relation(key_key, + geometry_key, + DEPSREL_TYPE_GEOMETRY_EVAL, + "Shapekeys"); } } - /* particle systems */ - if (ob->particlesystem.first) { + /* Particle systems. */ + if (ob->particlesystem.first != NULL) { build_particles(scene, ob); } - /* grease pencil */ - if (ob->gpd) { + /* Grease pencil. */ + if (ob->gpd != NULL) { build_gpencil(ob->gpd); } + + /* Object that this is a proxy for. */ + if (ob->proxy != NULL) { + ob->proxy->proxy_from = ob; + build_object(bmain, scene, ob->proxy); + /* TODO(sergey): This is an inverted relation, matches old depsgraph + * behavior and need to be investigated if it still need to be inverted. + */ + ComponentKey ob_pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); + ComponentKey proxy_pose_key(&ob->proxy->id, DEPSNODE_TYPE_EVAL_POSE); + add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy"); + } + + /* Object dupligroup. */ + if (ob->dup_group != NULL) { + build_group(bmain, scene, ob, ob->dup_group); + } } void DepsgraphRelationBuilder::build_object_parent(Object *ob) { - /* XXX: for now, need to use the component key (not just direct to the parent op), or else the matrix doesn't get reset */ - // XXX: @sergey - it would be good if we got that backwards flushing working when tagging for updates + /* XXX: for now, need to use the component key (not just direct to the parent op), + * or else the matrix doesn't get reset/ + */ + // XXX: @sergey - it would be good if we got that backwards flushing working + // when tagging for updates. //OperationKey ob_key(&ob->id, DEPSNODE_TYPE_TRANSFORM, DEG_OPCODE_TRANSFORM_PARENT); ComponentKey ob_key(&ob->id, DEPSNODE_TYPE_TRANSFORM); diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc index f0d70e3871b..2e2182609d5 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations_scene.cc @@ -77,25 +77,7 @@ void DepsgraphRelationBuilder::build_scene(Main *bmain, Scene *scene) /* scene objects */ FOREACH_SCENE_OBJECT(scene, ob) { - /* object itself */ build_object(bmain, scene, ob); - - /* object that this is a proxy for */ - if (ob->proxy) { - ob->proxy->proxy_from = ob; - build_object(bmain, scene, ob->proxy); - /* TODO(sergey): This is an inverted relation, matches old depsgraph - * behavior and need to be investigated if it still need to be inverted. - */ - ComponentKey ob_pose_key(&ob->id, DEPSNODE_TYPE_EVAL_POSE); - ComponentKey proxy_pose_key(&ob->proxy->id, DEPSNODE_TYPE_EVAL_POSE); - add_relation(ob_pose_key, proxy_pose_key, DEPSREL_TYPE_TRANSFORM, "Proxy"); - } - - /* Object dupligroup. */ - if (ob->dup_group) { - build_group(bmain, scene, ob, ob->dup_group); - } } FOREACH_SCENE_OBJECT_END diff --git a/source/blender/depsgraph/intern/depsgraph_types.h b/source/blender/depsgraph/intern/depsgraph_types.h index effd34a0eb9..c9c4329769d 100644 --- a/source/blender/depsgraph/intern/depsgraph_types.h +++ b/source/blender/depsgraph/intern/depsgraph_types.h @@ -44,9 +44,6 @@ #include <string> #include <vector> -using std::string; -using std::vector; - struct bAction; struct ChannelDriver; struct ModifierData; @@ -56,6 +53,9 @@ struct FCurve; namespace DEG { +using std::string; +using std::vector; + /* Evaluation Operation for atomic operation */ // XXX: move this to another header that can be exposed? typedef function<void(struct EvaluationContext *)> DepsEvalOperationCb; @@ -89,52 +89,52 @@ typedef enum eDepsNode_Type { /* **** Generic Types **** */ /* "Current Scene" - basically whatever kicks off the evaluation process. */ - DEPSNODE_TYPE_ROOT = 1, + DEPSNODE_TYPE_ROOT, /* Time-Source */ - DEPSNODE_TYPE_TIMESOURCE = 2, + DEPSNODE_TYPE_TIMESOURCE, /* ID-Block reference - used as landmarks/collection point for components, * but not usually part of main graph. */ - DEPSNODE_TYPE_ID_REF = 3, + DEPSNODE_TYPE_ID_REF, /* Isolated sub-graph - used for keeping instanced data separate from * instances using them. */ - DEPSNODE_TYPE_SUBGRAPH = 4, + DEPSNODE_TYPE_SUBGRAPH, /* **** Outer Types **** */ /* Parameters Component - Default when nothing else fits * (i.e. just SDNA property setting). */ - DEPSNODE_TYPE_PARAMETERS = 11, + DEPSNODE_TYPE_PARAMETERS, /* Generic "Proxy-Inherit" Component * XXX: Also for instancing of subgraphs? */ - DEPSNODE_TYPE_PROXY = 12, + DEPSNODE_TYPE_PROXY, /* Animation Component * * XXX: merge in with parameters? */ - DEPSNODE_TYPE_ANIMATION = 13, + DEPSNODE_TYPE_ANIMATION, /* Transform Component (Parenting/Constraints) */ - DEPSNODE_TYPE_TRANSFORM = 14, + DEPSNODE_TYPE_TRANSFORM, /* Geometry Component (DerivedMesh/Displist) */ - DEPSNODE_TYPE_GEOMETRY = 15, + DEPSNODE_TYPE_GEOMETRY, /* Sequencer Component (Scene Only) */ - DEPSNODE_TYPE_SEQUENCER = 16, + DEPSNODE_TYPE_SEQUENCER, /* **** Evaluation-Related Outer Types (with Subdata) **** */ /* Pose Component - Owner/Container of Bones Eval */ - DEPSNODE_TYPE_EVAL_POSE = 21, + DEPSNODE_TYPE_EVAL_POSE, /* Bone Component - Child/Subcomponent of Pose */ - DEPSNODE_TYPE_BONE = 22, + DEPSNODE_TYPE_BONE, /* Particle Systems Component */ - DEPSNODE_TYPE_EVAL_PARTICLES = 23, + DEPSNODE_TYPE_EVAL_PARTICLES, /* Material Shading Component */ - DEPSNODE_TYPE_SHADING = 24, + DEPSNODE_TYPE_SHADING, /* Cache Component */ - DEPSNODE_TYPE_CACHE = 25, + DEPSNODE_TYPE_CACHE, } eDepsNode_Type; /* Identifiers for common operations (as an enum). */ diff --git a/source/blender/editors/render/render_preview.c b/source/blender/editors/render/render_preview.c index f173d19780b..3fb09123131 100644 --- a/source/blender/editors/render/render_preview.c +++ b/source/blender/editors/render/render_preview.c @@ -199,7 +199,7 @@ static Main *load_main_from_memory(const void *blend, int blend_size) BlendFileData *bfd; G.fileflags |= G_FILE_NO_UI; - bfd = BLO_read_from_memory(blend, blend_size, NULL, 0); + bfd = BLO_read_from_memory(blend, blend_size, NULL, BLO_READ_SKIP_NONE); if (bfd) { bmain = bfd->main; diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h index 3bed4dac2cf..84209a0e3c8 100644 --- a/source/blender/windowmanager/WM_types.h +++ b/source/blender/windowmanager/WM_types.h @@ -543,7 +543,15 @@ typedef struct wmOperatorType { * canceled due to some external reason, cancel is called * - see defines below for return values */ int (*invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT; + + /* Called when a modal operator is canceled (not used often). + * Internal cleanup can be done here if needed. */ void (*cancel)(struct bContext *, struct wmOperator *); + + /* Modal is used for operators which continuously run, eg: + * fly mode, knife tool, circle select are all examples of modal operators. + * Modal operators can handle events which would normally access other operators, + * they keep running until they don't return `OPERATOR_RUNNING_MODAL`. */ int (*modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT; /* verify if the operator can be executed in the current context, note diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 6564cbeaefd..205e4b6b7f5 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -629,18 +629,21 @@ bool WM_file_read(bContext *C, const char *filepath, ReportList *reports) /** - * called on startup, (context entirely filled with NULLs) - * or called for 'New File' - * both startup.blend and userpref.blend are checked - * the optional parameter custom_file points to an alternative startup page - * custom_file can be NULL + * Called on startup, (context entirely filled with NULLs) + * or called for 'New File' both startup.blend and userpref.blend are checked. + * + * \param from_memory: Ignore on-disk startup file, use bundled ``datatoc_startup_blend`` instead. + * Used for "Restore Factory Settings". + * \param filepath_startup_override: Optional path pointing to an alternative blend file (may be NULL). */ -int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const char *custom_file) +int wm_homefile_read( + bContext *C, ReportList *reports, + bool from_memory, const char *filepath_startup_override) { ListBase wmbase; - char startstr[FILE_MAX]; - char prefstr[FILE_MAX]; - int success = 0; + char filepath_startup[FILE_MAX]; + char filepath_userdef[FILE_MAX]; + bool success = false; /* Indicates whether user preferences were really load from memory. * @@ -655,7 +658,7 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c eBLOReadSkip skip_flags = 0; /* options exclude eachother */ - BLI_assert((from_memory && custom_file) == 0); + BLI_assert((from_memory && filepath_startup_override) == 0); if ((G.f & G_SCRIPT_OVERRIDE_PREF) == 0) { BKE_BIT_TEST_SET(G.f, (U.flag & USER_SCRIPT_AUTOEXEC_DISABLE) == 0, G_SCRIPT_AUTOEXEC); @@ -668,24 +671,24 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c G.relbase_valid = 0; if (!from_memory) { const char * const cfgdir = BKE_appdir_folder_id(BLENDER_USER_CONFIG, NULL); - if (custom_file) { - BLI_strncpy(startstr, custom_file, FILE_MAX); + if (filepath_startup_override) { + BLI_strncpy(filepath_startup, filepath_startup_override, FILE_MAX); if (cfgdir) { - BLI_make_file_string(G.main->name, prefstr, cfgdir, BLENDER_USERPREF_FILE); + BLI_make_file_string(G.main->name, filepath_userdef, cfgdir, BLENDER_USERPREF_FILE); } else { - prefstr[0] = '\0'; + filepath_userdef[0] = '\0'; } } else if (cfgdir) { - BLI_make_file_string(G.main->name, startstr, cfgdir, BLENDER_STARTUP_FILE); - BLI_make_file_string(G.main->name, prefstr, cfgdir, BLENDER_USERPREF_FILE); + BLI_make_file_string(G.main->name, filepath_startup, cfgdir, BLENDER_STARTUP_FILE); + BLI_make_file_string(G.main->name, filepath_userdef, cfgdir, BLENDER_USERPREF_FILE); } else { - startstr[0] = '\0'; - prefstr[0] = '\0'; - from_memory = 1; + filepath_startup[0] = '\0'; + filepath_userdef[0] = '\0'; + from_memory = true; } } @@ -693,32 +696,32 @@ int wm_homefile_read(bContext *C, ReportList *reports, bool from_memory, const c wm_window_match_init(C, &wmbase); /* load preferences before startup.blend */ - if (!from_memory && BLI_exists(prefstr)) { - int done = BKE_blendfile_read_userdef(prefstr, NULL); + if (!from_memory && BLI_exists(filepath_userdef)) { + int done = BKE_blendfile_read_userdef(filepath_userdef, NULL); if (done != BKE_BLENDFILE_READ_FAIL) { read_userdef_from_memory = false; skip_flags |= BLO_READ_SKIP_USERDEF; - printf("Read new prefs: %s\n", prefstr); + printf("Read prefs: %s\n", filepath_userdef); } } if (!from_memory) { - if (BLI_access(startstr, R_OK) == 0) { - success = (BKE_blendfile_read(C, startstr, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL); + if (BLI_access(filepath_startup, R_OK) == 0) { + success = (BKE_blendfile_read(C, filepath_startup, NULL, skip_flags) != BKE_BLENDFILE_READ_FAIL); } if (BLI_listbase_is_empty(&U.themes)) { if (G.debug & G_DEBUG) - printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", startstr); - success = 0; + printf("\nNote: No (valid) '%s' found, fall back to built-in default.\n\n", filepath_startup); + success = false; } } - if (success == 0 && custom_file && reports) { - BKE_reportf(reports, RPT_ERROR, "Could not read '%s'", custom_file); + if (success == false && filepath_startup_override && reports) { + BKE_reportf(reports, RPT_ERROR, "Could not read '%s'", filepath_startup_override); /*We can not return from here because wm is already reset*/ } - if (success == 0) { + if (success == false) { success = BKE_blendfile_read_from_memory( C, datatoc_startup_blend, datatoc_startup_blend_size, NULL, skip_flags, true); diff --git a/source/blender/windowmanager/intern/wm_init_exit.c b/source/blender/windowmanager/intern/wm_init_exit.c index 055196a84ab..ae103bf6cfd 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.c +++ b/source/blender/windowmanager/intern/wm_init_exit.c @@ -576,7 +576,7 @@ void WM_exit_ext(bContext *C, const bool do_python) ED_file_exit(); /* for fsmenu */ UI_exit(); - BKE_blender_userdef_free(); + BKE_blender_userdef_free(&U); RNA_exit(); /* should be after BPY_python_end so struct python slots are cleared */ diff --git a/source/blender/windowmanager/wm_files.h b/source/blender/windowmanager/wm_files.h index 396907a3f6d..954d35722f3 100644 --- a/source/blender/windowmanager/wm_files.h +++ b/source/blender/windowmanager/wm_files.h @@ -35,7 +35,9 @@ struct wmOperatorType; /* wm_files.c */ void wm_history_file_read(void); -int wm_homefile_read(struct bContext *C, struct ReportList *reports, bool from_memory, const char *filepath); +int wm_homefile_read( + struct bContext *C, struct ReportList *reports, + bool from_memory, const char *filepath_startup_override); void wm_file_read_report(bContext *C); void WM_OT_save_homefile(struct wmOperatorType *ot); diff --git a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp index dd93a6ff424..0c206dfce3d 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_ghost.cpp @@ -355,7 +355,7 @@ static BlendFileData *load_game_data(const char *progname, char *filename = NULL BLI_strncpy(bfd->main->name, progname, sizeof(bfd->main->name)); } } else { - bfd= BLO_read_from_file(progname, &reports); + bfd= BLO_read_from_file(progname, &reports, BLO_READ_SKIP_NONE); } if (!bfd && filename) { |